Skip to content

Instantly share code, notes, and snippets.

@belotn
Created March 26, 2014 16:07
Show Gist options
  • Save belotn/9786866 to your computer and use it in GitHub Desktop.
Save belotn/9786866 to your computer and use it in GitHub Desktop.
Change failure settings for unconfigured service
get-xaserver |% {
gwmi Win32_Service -ComputerNAme $_.ServerName -Filter 'Name="cpsvc"' |% {
if(sc.exe \\$($_.__SERVER) qfailure $($_.name) | select-string 'FAILURE'){
"$($_.__SERVER) OK"
}else{
sc.Exe \\$($_.__SERVER) failure $($_.name) reset= 86400 actions= restart/60000/restart/60000
"$($_.SERVER) Set"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment