How to deploy OMS Log Analytics Agent and Dependency Agent to thousands of computers using PowerShell Workflow in parallel


workflow installOMS{
#fill in the computers.txt in temp folder as one computer per line with no delimeters
$computers = inlinescript
{
$BaselineFile = "$env:temp\computers.txt"
$lines = (Get-Content $BaselineFile)
$computers = foreach ($line in $lines) { $line.Trim()}
return $computers
}

parallel
{

inlinescript
{

try
{

$OPSINSIGHTS_WS_ID = "??????"

$OPSINSIGHTS_WS_KEY = "?????"

$arg1 = '/C:"setup.exe /qn ADD_OPINSIGHTS_WORKSPACE=1 '+ "OPINSIGHTS_WORKSPACE_ID=$OPSINSIGHTS_WS_ID " + "OPINSIGHTS_WORKSPACE_KEY=$OPSINSIGHTS_WS_KEY " +'AcceptEndUserLicenseAgreement=1"'

write-output $env:computername

$myoutfile1 = "$env:temp\MMASetup-AMD64.exe"
Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkId=828603" -OutFile $myoutfile1
Start-Process -FilePath $myoutfile1 -ArgumentList $arg1 -Wait

$arg2 = "/S"
$myoutfile2 = "$env:temp\InstallDependencyAgent-Windows.exe"
Invoke-WebRequest "https://aka.ms/dependencyagentwindows" -OutFile $myoutfile2
Start-Process -FilePath $myoutfile2 -ArgumentList $arg2 -Wait
}
catch
{
Write-Error -Message $_.Exception
throw $_.Exception
}

} -PSComputerName $computers

}
}


Comments (0)

Skip to main content