Created
January 2, 2013 21:44
-
-
Save jacobsimeon/4438418 to your computer and use it in GitHub Desktop.
Manage windows services with powershell.
This file contains hidden or 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
function StartService($ServiceName, $Computer){ | |
Write-Output "Getting status of $ServiceName on $Computer" | |
$Service = Get-Service -Name $ServiceName -computername $Computer | |
if($Service.Status -eq "Running"){ | |
Write-Output "$ServiceName is already running on $Computer" | |
} else { | |
Write-Output "Starting $ServiceName on $Computer" | |
$Service.Start() | |
} | |
} | |
StartService -Service 'OnFileAppServer$Stage' -Computer "msapps01dr.onfile.com" | |
StartService -Service 'OnFile.FileServer$Stage' -Computer "msapps01dr.onfile.com" | |
function StopService($ServiceName, $Computer){ | |
Write-Output "Getting status of $ServiceName on $Computer" | |
$Service = Get-Service -Name $ServiceName -computername $Computer | |
if($Service.Status -eq "Running"){ | |
Write-Output "Stopping $ServiceName on $Computer" | |
$Service.Stop() | |
} else { | |
Write-Output "$ServiceName is not running on $Computer" | |
} | |
} | |
StopService -Service 'OnFileAppServer$Stage' -Computer "msapps01dr.onfile.com" | |
StopService -Service 'OnFile.FileServer$Stage' -Computer "msapps01dr.onfile.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when i start service get error 1053(timelyfashion).I create pipetime in registry but doesnt fix.how fix it?