Skip to content

Updating Agents

Emre Guclu edited this page Dec 28, 2020 · 4 revisions

Updating using PSremoting

Following line updates the agent to UR7 using PSSession

Invoke-Command -session $2016rtms -ScriptBlock {invoke-expression 'C:\Windows\system32\msiexec.exe /p C:\temp\ur7\KB4492182-AMD64-Agent.msp /qn'}

Following line gets the latest success event for agent update using pssesion

Invoke-Command -session $2016rtms -ScriptBlock {Get-EventLog -LogName Application -Source MsiInstaller -InstanceId 1022 -Message *System?Center?2016?Operations?Manager?Update?Rollup ?7* -Newest 1 | Select-Object -Property TimeGenerated,Message}

Update using Scom Management pack by Kevin Holman

The following example filters specific agent versions to apply and installs using credentials. If you need to run with localsystem you can comment out the $cred line and remove the -taskcredential parameter in the Start-SCOMtask line.

Prerequisite: you need to install the management pack SCOM Management – MP

import-module operationsmanager
$Update = "invoke-expression 'C:\Windows\system32\msiexec.exe /p \\FileShare\KB4580254-AMD64-Agent.msp /qn'"
$Overrides=@{
     'ScriptBody' = $update
}
$cred = Get-Credential
$Task = Get-SCOMTask -DisplayName "Execute any PowerShell"
$UpdateHelpers = get-scomclass | where {$_.Name -eq 'SCOM.Management.Agent.Class'} |Get-SCOMClassInstance | `
where { ($_.'[SCOM.Management.Agent.Class].AgentVersion'.Value) -in @('8.0.10918.0','8.0.11025.0') -and $_.IsAvailable -eq $true}
$result = Start-SCOMTask -Task $Task -Instance $UpdateHelpers -Override $Overrides -TaskCredentials $cred