Pages

Friday, 20 July 2012

Start Service on Remote Computer - PowerShell


Following script will start the service "Browser"


$sb={
$service=get-service browser
if ($Service.status -eq "Stopped") {
write-Host "Starting service on $env:Computername" -foreground Green
$service | Start-service -PassThru
}
else {
$service
}
}

To run the above script type following command:

invoke-command $sb -comp remotecomputername

Result will be as follows: 


2 comments: