Created
January 18, 2018 23:14
-
-
Save owlfox/03083149c357360e6d8537b114432e14 to your computer and use it in GitHub Desktop.
Check if ntp service running and try to start it in powershell, if failed prompt!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sname="w32time" | |
#check if the service running | |
if((Get-service $sname | Where-Object {$_.status -eq "running"} ) -eq $Null){ | |
#Not Running, restart it | |
Stop-service $sname | |
Start-service $sname | |
} | |
sleep 30 | |
#still not Running, prompt | |
if((Get-service $sname | Where-Object {$_.status -eq "running"} ) -eq $Null){ | |
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") #load messagebox lib | |
[System.Windows.Forms.MessageBox]::Show($sname + " is not running, please contact with Admin.") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment