PowerShell 2.0: One Cmdlet at a Time 47 Invoke-WSManAction

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Invoke-WSManAction cmdlet.

What can I do with it?

Invoke an action using WS-Management .

Examples:

Check the status of the BITS service on Test01, use WS-Management to stop the service, then check its status again.

Get-Service BITS -ComputerName Test01 Invoke-WSManAction -Action StopService -resourceuri wmicimv2/Win32_Service -SelectorSet @{Name=“BITS”} -ComputerName Test01 -Authentication Default Get-Service BITS -ComputerName Test01

You will notice that this example looks similar to how you would approach this task using Get-WMIObject. The return value of zero indicates it was successful.

How could I have done this in PowerShell 1.0?

Support for the use of WS-Management in PowerShell is provided as part of the 2.0 release.

1000 things 1% better!