Friday 31 October 2014

PowerShell and Remote Services

Some quick notes on how to work with services on remote machines with PowerShell ....

Get all remote services on a target machine ...

Get-Service -ComputerName DB01


Get a specific service on a target machine ...

Get-Service -ComputerName DB01 -Name MSSQLSERVER


Get services based on part of the name on a target machine ...

Get-Service -ComputerName DB01  | Where name -match "sql"


Start a service on a target machine ...

Start-Service -InputObject `
               $(Get-Service -ComputerName DB01 -Name MSSQLSERVER)


Restart a service on a target machine ...

Restart-Service -InputObject `
               $(Get-Service -ComputerName DB01 -Name MSSQLSERVER)


Stop a service on a target machine ...

Stop-Service -InputObject `
               $(Get-Service -ComputerName DB01 -Name MSSQLSERVER)

No comments:

Post a Comment