Installs OMS agent from the ZIP archive that is created of the unpacked agent MSI
Param( | |
[string]$AgentDownloadUrl="http://127.0.0.1/omsagent.zip", | |
[string]$WorkspaceId, | |
[string]$WorkspaceKey | |
) | |
try { | |
Write-Host "Downloading OMS agent" | |
Invoke-WebRequest -Uri $AgentDownloadUrl -OutFile omsagent.zip | |
Write-Host "Extracting OMS agent" | |
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
New-Item -Path omsagent -Type Directory -Force | |
$currDir = Get-Location | |
[System.IO.Compression.ZipFile]::ExtractToDirectory("$currDir\omsagent.zip", "$currDir\omsagent") | |
Set-Location "$currDir\omsagent\Extract" | |
Write-Host "Installing OMS agent" | |
.\Setup.exe /qn NOAPM=1 ADD_OPINSIGHTS_WORKSPACE=1 OPINSIGHTS_WORKSPACE_AZURE_CLOUD_TYPE=0 OPINSIGHTS_WORKSPACE_ID=$WorkspaceId OPINSIGHTS_WORKSPACE_KEY="$WorkspaceKey" AcceptEndUserLicenseAgreement=1 | |
Write-Host "Complete" | |
} | |
catch { | |
Write-Host "Process failed: $_.Exception" | |
} | |
finally { | |
Remove-Item -Path "$currDir\omsagent" -Recurse -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment