Skip to content

Agent Management

Emre Guclu edited this page Dec 3, 2020 · 3 revisions

Agent and Management Server management scripts.

HSLockdown on DCs

Runs HSLockodwn on multiple dcs. Requires Powershell Remoting.

 
Import-Module OperationsManager
 
$ProblemDCs="dc1","dc2","dc3"
 
$AddScriptBlock={
set-location "C:\Program Files\Microsoft Monitoring Agent\Agent"
.\HSLockdown.exe /A 'NT AUTHORITY\SYSTEM'
get-service -Name HealthService | Restart-Service -Verbose
}
 
Invoke-Command -ScriptBlock $AddScriptBlock -ComputerName $ProblemDCs

Agent and Gateway Failover

The following line lists scom Gateways with their failover servers.

Get-SCOMGatewayManagementServer | Select-Object -Property DisplayName, @{Name="PrimaryServer"; Expression={($_.GetPrimaryManagementServer()).DisplayName}},@{Name="FailOverServer"; Expression={($_.GetFailoverManagementServers()).DisplayName}}

List of Primary and Failover MS for SCOM agents

Get-SCOMAgent | select-object -Property DisplayName, PrimaryManagementServerName, @{Name='FailoverMS';Expression={($_.GetFailoverManagementServers()).Name}}

Figure out Connected agents

Run the below line on the management server to figure out which agents are connected.

 Get-NetTCPConnection -LocalPort 5723 | Format-Table -Property @{Name="LocalDNS";Expression={(resolve-dnsname $_.LocalAddress).NameHost}},LocalPort,@{Name="RemoteDNS";Expression={(resolve-dnsname $_.RemoteAddress).NameHost}},RemotePort,@{Name="ProcessName";Expression={(Get-Process -PID ($_.OwningProcess)).Name}},state 
 

Side bar

Clone this wiki locally