none
Unable to Install Self Hosted Integration Runtime MSI file with proxy details through powershell script RRS feed

  • Question

  • Hi Team,

    Currently i am trying to install the self hosted integration runtime MSI file through powershell script and able to configure it without proxy details. 

    But my requirement is that, I need to install with Proxy detail through powershell script.

    I am using the following powershell script for the install.

    Could you please help that how to configure the self hosted IRE with proxy detail from powershell script.

    Proxy server :http://company.com:8080

    Script details

    -------------------------------------------------------------------------------------------------

    $gatewayKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

    # init log setting
    $logLoc = "$env:SystemDrive\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension\"
    if (! (Test-Path($logLoc)))
    {
        New-Item -path $logLoc -type directory -Force
    }
    $logPath = "$logLoc\tracelog.log"
    "Start to excute gatewayInstall.ps1. `n" | Out-File $logPath

    function Now-Value()
    {
        return (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
    }

    function Throw-Error([string] $msg)
    {
    try 
    {
    throw $msg

    catch 
    {
    $stack = $_.ScriptStackTrace
    Trace-Log "DMDTTP is failed: $msg`nStack:`n$stack"
    }

    throw $msg
    }

    function Trace-Log([string] $msg)
    {
        $now = Now-Value
        try
        {
            "${now} $msg`n" | Out-File $logPath -Append
        }
        catch
        {
            #ignore any exception during trace
        }

    }

    function Run-Process([string] $process, [string] $arguments)
    {
    Write-Verbose "Run-Process: $process $arguments"

    $errorFile = "$env:tmp\tmp$pid.err"
    $outFile = "$env:tmp\tmp$pid.out"
    "" | Out-File $outFile
    "" | Out-File $errorFile

    $errVariable = ""

    if ([string]::IsNullOrEmpty($arguments))
    {
    $proc = Start-Process -FilePath $process -Wait -Passthru -NoNewWindow `
    -RedirectStandardError $errorFile -RedirectStandardOutput $outFile -ErrorVariable errVariable
    }
    else
    {
    $proc = Start-Process -FilePath $process -ArgumentList $arguments -Wait -Passthru -NoNewWindow `
    -RedirectStandardError $errorFile -RedirectStandardOutput $outFile -ErrorVariable errVariable
    }

    $errContent = [string] (Get-Content -Path $errorFile -Delimiter "!!!DoesNotExist!!!")
    $outContent = [string] (Get-Content -Path $outFile -Delimiter "!!!DoesNotExist!!!")

    Remove-Item $errorFile
    Remove-Item $outFile

    if($proc.ExitCode -ne 0 -or $errVariable -ne "")
    {
    Throw-Error "Failed to run process: exitCode=$($proc.ExitCode), errVariable=$errVariable, errContent=$errContent, outContent=$outContent."
    }

    Trace-Log "Run-Process: ExitCode=$($proc.ExitCode), output=$outContent"

    if ([string]::IsNullOrEmpty($outContent))
    {
    return $outContent
    }

    return $outContent.Trim()
    }

    #function Download-Gateway([string] $url, [string] $gwPath)
    #{
    #    try
    #    {
    #        $ErrorActionPreference = "Stop";
    #        $client = New-Object System.Net.WebClient
    #        $client.DownloadFile($url, $gwPath)
    #        Trace-Log "Download gateway successfully. Gateway loc: $gwPath"
    #    }
    #    catch
    #    {
    #        Trace-Log "Fail to download gateway msi"
    #        Trace-Log $_.Exception.ToString()
    #        throw
    #    }
    #}

    function Install-Gateway([string] $gwPath)
    {
    if ([string]::IsNullOrEmpty($gwPath))
        {
    Throw-Error "Gateway path is not specified"
        }

    if (!(Test-Path -Path $gwPath))
    {
    Throw-Error "Invalid gateway path: $gwPath"
    }

    Trace-Log "Start Gateway installation"
    Run-Process "msiexec.exe" "/i gateway.msi INSTALLTYPE=AzureTemplate /quiet /norestart"

    Start-Sleep -Seconds 30

    Trace-Log "Installation of gateway is successful"
    }

    function Get-RegistryProperty([string] $keyPath, [string] $property)
    {
    Trace-Log "Get-RegistryProperty: Get $property from $keyPath"
    if (! (Test-Path $keyPath))
    {
    Trace-Log "Get-RegistryProperty: $keyPath does not exist"
    }

    $keyReg = Get-Item $keyPath
    if (! ($keyReg.Property -contains $property))
    {
    Trace-Log "Get-RegistryProperty: $property does not exist"
    return ""
    }

    return $keyReg.GetValue($property)
    }

    function Get-InstalledFilePath()
    {
    $filePath = Get-RegistryProperty "hklm:\Software\Microsoft\DataTransfer\DataManagementGateway\ConfigurationManager" "DiacmdPath"
    if ([string]::IsNullOrEmpty($filePath))
    {
    Throw-Error "Get-InstalledFilePath: Cannot find installed File Path"
    }
        Trace-Log "Gateway installation file: $filePath"

    return $filePath
    }

    function Register-Gateway([string] $instanceKey)
    {
        Trace-Log "Register Agent"
    $filePath = Get-InstalledFilePath
    Run-Process $filePath "-era 8060"
    Run-Process $filePath "-k $instanceKey"
        Trace-Log "Agent registration is successful!"
    }



    Trace-Log "Log file: $logLoc"
    #$uri = "https://go.microsoft.com/fwlink/?linkid=839822"
    #Trace-Log "Gateway download fw link: $uri"
    $gwPath= "C:\Users\C58594\SelfHostedIRE\gateway.msi"
    Trace-Log "Gateway download location: $gwPath"


    #Download-Gateway $uri $gwPath
    Install-Gateway $gwPath

    Register-Gateway $gatewayKey

    -------------------------------------------------------------------------------------------------

    Regards,

    Shreenivas Mirajkar

    Tuesday, September 10, 2019 8:21 PM

All replies

  • Thanks for the script . 

    I think that the core of the installation is 

    Run-Process "msiexec.exe" "/i gateway.msi INSTALLTYPE=AzureTemplate /quiet /norestart"

    Can you please let us know as what is there in the AzureTemplate ? 

    . I am sure that is something which values of the key properties . 


    Thanks Himanshu

    Wednesday, September 11, 2019 7:41 PM
    Moderator
  • We have not heard back from you this . Please do let us know if your issue was resolved and it will great if you can share the resolution with the community . 

    If you are still facing the issue , please share more info with us and we will try to help you .

     

    Thanks Himanshu

    Thursday, September 12, 2019 4:52 PM
    Moderator
  • Hi Himanshu,

    Still issue is not resolved.

    function Register-Gateway([string] $instanceKey)
    {
        Trace-Log "Register Agent"
    $filePath = Get-InstalledFilePath
    Run-Process $filePath "-era 8060"
    Run-Process $filePath "-k $instanceKey"
        Trace-Log "Agent registration is successful!"
    }

    Above fuction will do the registration with Self-IRE and here -K mean gateway key but what argument i have to  refer here to pass proxy server detail which is i amdont aware.

    i am trying like 

    function Register-Gateway([string] $instanceKey)

    {
        Trace-Log "Register Agent"

    $proxyserver="Company.com:8080"
    $filePath = Get-InstalledFilePath
    Run-Process $filePath "-era 8060"
    Run-Process $filePath "-k $instanceKey"

    Run-Process $filePath "-p $proxyserver"  
        Trace-Log "Agent registration is successful!"
    }

    So here i strucked and still this is not resolved working on this.

    you can help me on how to pass  proxy detail here >>Run-Process $filePath "-p $proxyserver"  

    Regards,

    Shreenivs Mirajkar


    Thursday, September 12, 2019 7:16 PM