Skip to content

Commit ed225b5

Browse files
sdwheelerCopilotmichaeltlombardi
authored
Add note about using Invoke-Command for remoting (#12735)
* Add note about using Invoke-Command for remoting * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>
1 parent c97c99a commit ed225b5

28 files changed

+303
-148
lines changed

reference/7.4/Microsoft.PowerShell.Management/Get-Service.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 03/20/2024
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/get-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
aliases:
@@ -108,10 +108,10 @@ Status is only one property of service objects. To see all of the properties, ty
108108
This example gets services that have dependent services.
109109

110110
```powershell
111-
Get-Service |
112-
Where-Object {$_.DependentServices} |
111+
Get-Service | Where-Object {$_.DependentServices} |
113112
Format-List -Property Name, DependentServices, @{
114-
Label="NoOfDependentServices"; Expression={$_.DependentServices.Count}
113+
Label = "NoOfDependentServices"
114+
Expression = {$_.DependentServices.Count}
115115
}
116116
```
117117

@@ -140,7 +140,7 @@ This example shows that when you sort services in ascending order by the value o
140140
property, stopped services appear before running services. This happens because the value of
141141
**Status** is an enumeration, in which `Stopped` has a value of `1`, and `Running` has a value of
142142
`4`. For more information, see
143-
[ServiceControllerStatus](/dotnet/api/system.serviceprocess.servicecontrollerstatus).
143+
[ServiceControllerStatus](xref:System.ServiceProcess.ServiceControllerStatus).
144144

145145
To list running services first, use the **Descending** parameter of the `Sort-Object` cmdlet.
146146

@@ -338,9 +338,16 @@ PowerShell includes the following aliases for `Get-Service`:
338338

339339
This cmdlet is only available on Windows platforms.
340340

341-
Beginning in PowerShell 6.0, the following properties are added to the **ServiceController**
342-
objects: **UserName**, **Description**, **DelayedAutoStart**, **BinaryPathName**, and
343-
**StartupType** .
341+
PowerShell 6.0 introduced the following changes:
342+
343+
- The **ServiceController** objects now include the following properties:
344+
- **UserName**
345+
- **Description**
346+
- **DelayedAutoStart**
347+
- **BinaryPathName**
348+
- **StartupType**
349+
- The command no longer includes the **ComputerName** parameter. To use this command on a remote computer,
350+
use the `Invoke-Command` to target a remote system.
344351

345352
This cmdlet can display services only when the current user has permission to see them. If this
346353
cmdlet does not display services, you might not have permission to see them.
@@ -363,10 +370,12 @@ services. The **Status** property of a service is an enumerated value in which t
363370
statuses represent integer values. The sort is based on the integer value, not the name. `Running`
364371
appears before `Stopped` because `Stopped` has a value of `1`, and `Running` has a value of `4`. For
365372
more information, see
366-
[ServiceControllerStatus](/dotnet/api/system.serviceprocess.servicecontrollerstatus).
373+
[ServiceControllerStatus](xref:System.ServiceProcess.ServiceControllerStatus).
367374

368375
## RELATED LINKS
369376

377+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
378+
370379
[New-Service](New-Service.md)
371380

372381
[Restart-Service](Restart-Service.md)

reference/7.4/Microsoft.PowerShell.Management/New-Service.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 12/12/2022
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/new-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: New-Service
@@ -318,8 +318,13 @@ This cmdlet is only available on Windows platforms.
318318

319319
To run this cmdlet, start PowerShell by using the **Run as administrator** option.
320320

321+
Beginning in PowerShell 6.0, the command no longer includes the **ComputerName** parameter. To use
322+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
323+
321324
## RELATED LINKS
322325

326+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
327+
323328
[Get-Service](Get-Service.md)
324329

325330
[Restart-Service](Restart-Service.md)

reference/7.4/Microsoft.PowerShell.Management/Remove-Service.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 12/12/2022
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/remove-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Remove-Service
@@ -152,8 +152,13 @@ This cmdlet is only available on Windows platforms.
152152
153153
To run this cmdlet, start PowerShell by using the **Run as administrator** option.
154154
155+
Like the other `*-Service` cmdlets, this command doesn't have a **ComputerName** parameter. To use
156+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
157+
155158
## RELATED LINKS
156159

160+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
161+
157162
[Get-Service](Get-Service.md)
158163

159164
[Restart-Service](Restart-Service.md)

reference/7.4/Microsoft.PowerShell.Management/Restart-Service.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 09/03/2024
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/restart-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Restart-Service
@@ -269,8 +269,13 @@ This cmdlet is only available on Windows platforms.
269269
The service names appear in the **Name** column, and the display names appear in the
270270
**DisplayName** column.
271271

272+
Beginning in PowerShell 6.0, the command no longer includes the **ComputerName** parameter. To use
273+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
274+
272275
## RELATED LINKS
273276

277+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
278+
274279
[Get-Service](Get-Service.md)
275280

276281
[New-Service](New-Service.md)

reference/7.4/Microsoft.PowerShell.Management/Resume-Service.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 12/12/2022
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/resume-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Resume-Service
@@ -247,8 +247,13 @@ This cmdlet is only available on Windows platforms.
247247
The service names appear in the **Name** column, and the display names appear in the
248248
**DisplayName** column.
249249

250+
Beginning in PowerShell 6.0, the command no longer includes the **ComputerName** parameter. To use
251+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
252+
250253
## RELATED LINKS
251254

255+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
256+
252257
[Get-Service](Get-Service.md)
253258

254259
[New-Service](New-Service.md)

reference/7.4/Microsoft.PowerShell.Management/Set-Service.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,13 @@ a command doesn't work correctly, you might not have the required permissions.
508508
To find a service's service name or display name, use `Get-Service`. The service names are in the
509509
**Name** column and the display names are in the **DisplayName** column.
510510

511+
Beginning in PowerShell 6.0, the command no longer includes the **ComputerName** parameter. To use
512+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
513+
511514
## RELATED LINKS
512515

516+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
517+
513518
[Get-Service](Get-Service.md)
514519

515520
[New-Service](New-Service.md)

reference/7.4/Microsoft.PowerShell.Management/Start-Service.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 10/15/2024
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/start-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
aliases:
@@ -92,9 +92,10 @@ existing file.
9292

9393
This example shows how to start a service when the start type of the service is **Disabled**.
9494

95-
```
95+
```powershell
9696
PS> Start-Service tlntsvr
97-
Start-Service : Service 'Telnet (TlntSvr)' cannot be started due to the following error: Cannot start service TlntSvr on computer '.'.
97+
Start-Service : Service 'Telnet (TlntSvr)' cannot be started due to the following error: Cannot
98+
start service TlntSvr on computer '.'.
9899
At line:1 char:14
99100
+ Start-Service <<<< tlntsvr
100101
@@ -256,7 +257,8 @@ Accept wildcard characters: False
256257

257258
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
258259
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
259-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
260+
-WarningAction, and -WarningVariable. For more information, see
261+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
260262

261263
## INPUTS
262264

@@ -303,8 +305,13 @@ This cmdlet is only available on Windows platforms.
303305
work to do. When PowerShell starts a service that stops itself almost immediately, it displays the
304306
following message: `Service \<display-name\> start failed.`
305307

308+
Beginning in PowerShell 6.0, the command no longer includes the **ComputerName** parameter. To use
309+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
310+
306311
## RELATED LINKS
307312

313+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
314+
308315
[Get-Service](Get-Service.md)
309316

310317
[New-Service](New-Service.md)

reference/7.4/Microsoft.PowerShell.Management/Stop-Service.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 01/27/2023
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/stop-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
aliases:
@@ -51,15 +51,15 @@ to stop.
5151

5252
### Example 1: Stop a service on the local computer
5353

54-
```
54+
```powershell
5555
PS C:\> Stop-Service -Name "sysmonlog"
5656
```
5757

5858
This command stops the Performance Logs and Alerts (SysmonLog) service on the local computer.
5959

6060
### Example 2: Stop a service by using the display name
6161

62-
```
62+
```powershell
6363
PS C:\> Get-Service -DisplayName "telnet" | Stop-Service
6464
```
6565

@@ -69,7 +69,7 @@ an object that represents the Telnet service. The pipeline operator (`|`) pipes
6969

7070
### Example 3: Stop a service that has dependent services
7171

72-
```
72+
```powershell
7373
PS C:\> Get-Service -Name "iisadmin" | Format-List -Property Name, DependentServices
7474
PS C:\> Stop-Service -Name "iisadmin" -Force -Confirm
7575
```
@@ -297,8 +297,13 @@ To find the service names and display names of the services on your system, type
297297
service names appear in the **Name** column and the display names appear in the **DisplayName**
298298
column.
299299

300+
Beginning in PowerShell 6.0, the command no longer includes the **ComputerName** parameter. To use
301+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
302+
300303
## RELATED LINKS
301304

305+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
306+
302307
[Get-Service](Get-Service.md)
303308

304309
[New-Service](New-Service.md)

reference/7.4/Microsoft.PowerShell.Management/Suspend-Service.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 12/12/2022
5+
ms.date: 02/04/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/suspend-service?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Suspend-Service
@@ -50,25 +50,25 @@ object that represents the services that you want to suspend.
5050

5151
### Example 1: Suspend a service
5252

53-
```
54-
PS C:\> Suspend-Service -DisplayName "Telnet"
53+
```powershell
54+
Suspend-Service -DisplayName "Telnet"
5555
```
5656

5757
This command suspends the Telnet service (Tlntsvr) service on the local computer.
5858

5959
### Example 2: Display what would happen if you suspend services
6060

61-
```
62-
PS C:\> Suspend-Service -Name lanman* -WhatIf
61+
```powershell
62+
Suspend-Service -Name lanman* -WhatIf
6363
```
6464

6565
This command tells what would happen if you suspended the services that have a service name that
6666
starts with lanman. To suspend the services, rerun the command without the **WhatIf** parameter.
6767

6868
### Example 3: Get and suspend a service
6969

70-
```
71-
PS C:\> Get-Service schedule | Suspend-Service
70+
```powershell
71+
Get-Service schedule | Suspend-Service
7272
```
7373

7474
This command uses the `Get-Service` cmdlet to get an object that represents the Task Scheduler
@@ -77,8 +77,10 @@ This command uses the `Get-Service` cmdlet to get an object that represents the
7777

7878
### Example 4: Suspend all services that can be suspended
7979

80-
```
81-
PS C:\> Get-Service | Where-Object {$_.CanPauseAndContinue -eq "True"} | Suspend-Service -Confirm
80+
```powershell
81+
Get-Service |
82+
Where-Object {$_.CanPauseAndContinue -eq "True"} |
83+
Suspend-Service -Confirm
8284
```
8385

8486
This command suspends all of the services on the computer that can be suspended. It uses
@@ -270,8 +272,13 @@ This cmdlet is only available on Windows platforms.
270272
The service names appear in the **Name** column, and the display names appear in the
271273
**DisplayName** column.
272274

275+
Beginning in PowerShell 6.0, the command no longer includes the **ComputerName** parameter. To use
276+
this command on a remote computer, use the `Invoke-Command` to target a remote system.
277+
273278
## RELATED LINKS
274279

280+
[Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md)
281+
275282
[Get-Service](Get-Service.md)
276283

277284
[New-Service](New-Service.md)

0 commit comments

Comments
 (0)