Skip to content

Commit

Permalink
(MicrosoftDocsGH-8757) Clarify remoting in Managing Services (Microso…
Browse files Browse the repository at this point in the history
…ftDocs#8762)

Prior to this commit, the Managing Services sample in the conceptual
documentation included example code using the **ComputerName** parameter
for `Get-Service`, but that parameter was removed from the `*-Service`
cmdlets in PowerShell 6.0.

This commit updates the documentation to distinguish between Windows
PowerShell and PowerShell for managing remote services and clarifies
how to do so.
  • Loading branch information
michaeltlombardi committed Apr 25, 2022
1 parent e73d153 commit a6d911d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions reference/docs-conceptual/samples/Managing-Services.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,28 @@ Running lanmanserver Server
Stopped ServiceLayer ServiceLayer
```

You can use the ComputerName parameter of the Get-Service cmdlet to get the services on remote
computers. The ComputerName parameter accepts multiple values and wildcard characters, so you can
get the services on multiple computers with a single command. For example, the following command
gets the services on the Server01 remote computer.
## Getting Remote Services

With Windows PowerShell, you can use the **ComputerName** parameter of the `Get-Service` cmdlet to
get the services on remote computers. The **ComputerName** parameter accepts multiple values and
wildcard characters, so you can get the services on multiple computers with a single command. For
example, the following command gets the services on the Server01 remote computer.

```powershell
Get-Service -ComputerName Server01
```

Starting in PowerShell 6.0, the `*-Service` cmdlets do not have the **ComputerName** parameter. You
can still get services on remote computers with PowerShell remoting. For example, the following
command gets the services on the Server02 remote computer.

```powershell
Invoke-Command -ComputerName Server02 -ScriptBlock { Get-Service }
```

You can also manage services with the other `*-Service` cmdlets. For more information on PowerShell
remoting, see [about_Remote](/powershell/module/Microsoft.PowerShell.Core/about_Remote).

## Getting Required and Dependent Services

The Get-Service cmdlet has two parameters that are very useful in service administration. The
Expand Down Expand Up @@ -177,6 +190,7 @@ For more information, see [Set-Service](/powershell/module/Microsoft.PowerShell.

## See Also

- [about_Remote](/powershell/module/Microsoft.PowerShell.Core/about_Remote)
- [Get-Service](/powershell/module/Microsoft.PowerShell.Management/get-service)
- [Set-Service](/powershell/module/Microsoft.PowerShell.Management/set-service)
- [Restart-Service](/powershell/module/Microsoft.PowerShell.Management/restart-service)
Expand Down

0 comments on commit a6d911d

Please sign in to comment.