Restart Grey SCOM Agent – Opsmgr 2007 R2

First you need to get a list of Agent. Here you can use the Powershell to get the displayname. Now you have the list. You can create a very simpel bat file, one for stop service and one for start service.

The Powershell Script

$rootMS =’RootMangementServer_FQDN’

#Initializing the Ops Mgr 2007 Powershell provider
add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client” -ErrorVariable errSnapin ;
set-location “OperationsManagerMonitoring::” -ErrorVariable errSnapin ;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin ;
set-location $rootMS -ErrorVariable errSnapin ;

$WCC = get-monitoringclass -name “Microsoft.SystemCenter.Agent”

$MO = Get-MonitoringObject -monitoringclass:$WCC | where {$_.IsAvailable -eq $false}

$MO | select DisplayName


The Bat File to stop service
SC Hostname1 Stop HealthService
SC Hostname2 Stop HealthService
SC Hostname100 Stop HealthService

The Bat File to start service
SC Hostname1 Start HealthService
SC Hostname2 Start HealthService
SC Hostname100 Start HealthService


Note: In between the two bat files, you can create script to delete the Heath Service State folder. Then you manually have flushed the Heath Service


Comments are closed.