Skip to content

Instantly share code, notes, and snippets.

@jacobsimeon
Created January 2, 2013 21:44
Show Gist options
  • Save jacobsimeon/4438418 to your computer and use it in GitHub Desktop.
Save jacobsimeon/4438418 to your computer and use it in GitHub Desktop.
Manage windows services with powershell.
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"
@johnjohny1990
Copy link

when i start service get error 1053(timelyfashion).I create pipetime in registry but doesnt fix.how fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment