jueves, 15 de febrero de 2018

WNDOWS. PS. Check Services

To do a html report of services status, you could do:


get-service | ConvertTo-Html -Property Name,Status | foreach { 
if ($_ -like "*<td>Running</td>*") {$_ -replace "<tr>", "<tr bgcolor=green>"} 
else {$_ -replace "<tr>", "<tr bgcolor=red>"}} > c:get-service.html
The result:

For a normal consult:

If you want start one service down automaticaly


Get-Service BITS | %{ if ( $_.Status -eq "Stopped" ) {Start-Service BITS}}





by GoN | Published: February 15, 2018 | Last Updated: April 10, 2018

No hay comentarios: