scipt to test svc status on multiple computers output to html and refresh


script to:

1) test net logon svc on multiple computers

2) output results html iframe  computers service not running

3) be able have script update every 30 seconds

hi,

here's bunch of examples can use build from:

get-content .\computerlist.txt | foreach-object {      write-output "computername $_"  }   get-content .\computerlist.txt | foreach-object {      if (test-connection -computername $_ -count 1 -quiet) {          write-output "$_ up"      } else {          write-output "$_ down"      }  }   get-content .\computerlist.txt | foreach-object {      $servicestate = get-service -name netlogon -computername $_      if ($servicestate.status -eq 'running') {          write-output 'service running'      } else {          write-output 'service not running'      }  }   get-content .\computerlist.txt | foreach-object {      get-service -name netlogon -computername $_ |         select-object machinename,name,status  } | convertto-html | out-file .\servicestatus.html   $count = 0 {      write-output $count     $count++     start-sleep -seconds 30  } until ( $count -eq 10 )   {      write-output "this loop doesn't end. you'll need press ctrl+c stop this."     start-sleep -seconds 30  } while ($true)

links documentation additional explanation , examples:

http://ss64.com/ps/get-content.html

http://ss64.com/ps/convertto-html.html

http://ss64.com/ps/test-connection.html

http://ss64.com/ps/foreach-object.html

http://ss64.com/ps/if.html

http://ss64.com/ps/out-file.html

http://ss64.com/ps/get-service.html

http://ss64.com/ps/write-output.html

http://ss64.com/ps/do.html

http://ss64.com/ps/select-object.html


don't retire technet! - (don't give yet - 12,950+ strong , growing)



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group