Skip to content

Instantly share code, notes, and snippets.

@doshyt
Created October 1, 2018 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doshyt/e28c2511a04340e262a3b79605011399 to your computer and use it in GitHub Desktop.
Save doshyt/e28c2511a04340e262a3b79605011399 to your computer and use it in GitHub Desktop.
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