hello,
I am wishing to get some ideas on how to resolve the following issue.
I need to scan the server OU and then check to see if the server has the healthservices server running.
If it is not running then try and start the serverices.
It all works great apart from when it tries to start the services and I then get stuck in a
"WARNING: Waiting for service 'Microsoft Monitoring Agent (HealthService)' to start..."
I have tried everything that I can think of but when this warning occurs I can do the following
let it just loop for ever saying the warning message
or stop the script
#Search all server in the DOMIAN and check the HealthServices is running. if it is not try and start it
$OUServices = Get-ADComputer -Filter * -SearchBase "OU=Servers,DC=domian,DC=dc" | Select-Object -ExpandProperty DNSHostName
Foreach ($servers in $OUServices) {
#servers with test in it to be skipped
if (($servers -like "*test.FQDN")) {
}
Else {
#Test connection
if (Test-Connection $servers -Count 1 -Quiet)
{
Write-host "$Servers is ONLINE"
$isok = Get-Service -Name HealthService -computername $servers -ErrorAction Ignore | Select-Object -ExpandProperty status
if ($isok -eq "Running")
{ write-host "$Servers MOM Service it is running" }
Else {
write-host "$Servers MOM Service is not running; Trying to START the SERVICE"
Try
#the below line is causing me the issues
{ Get-Service -Name HealthService -computername $servers | Start-Service -WarningAction Ignore }
Catch
{Write-Host "unable to start MOm on $Servers"
Break}
}
}
Else {
Write-Host "$Servers is OFFLINE"
}
}
}
I am wishing to get some ideas on how to resolve the following issue.
I need to scan the server OU and then check to see if the server has the healthservices server running.
If it is not running then try and start the serverices.
It all works great apart from when it tries to start the services and I then get stuck in a
"WARNING: Waiting for service 'Microsoft Monitoring Agent (HealthService)' to start..."
I have tried everything that I can think of but when this warning occurs I can do the following
let it just loop for ever saying the warning message
or stop the script
#Search all server in the DOMIAN and check the HealthServices is running. if it is not try and start it
$OUServices = Get-ADComputer -Filter * -SearchBase "OU=Servers,DC=domian,DC=dc" | Select-Object -ExpandProperty DNSHostName
Foreach ($servers in $OUServices) {
#servers with test in it to be skipped
if (($servers -like "*test.FQDN")) {
}
Else {
#Test connection
if (Test-Connection $servers -Count 1 -Quiet)
{
Write-host "$Servers is ONLINE"
$isok = Get-Service -Name HealthService -computername $servers -ErrorAction Ignore | Select-Object -ExpandProperty status
if ($isok -eq "Running")
{ write-host "$Servers MOM Service it is running" }
Else {
write-host "$Servers MOM Service is not running; Trying to START the SERVICE"
Try
#the below line is causing me the issues
{ Get-Service -Name HealthService -computername $servers | Start-Service -WarningAction Ignore }
Catch
{Write-Host "unable to start MOm on $Servers"
Break}
}
}
Else {
Write-Host "$Servers is OFFLINE"
}
}
}