PowerShell 2.0: One Cmdlet at a Time 49 New-WSManInstance

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

What can I do with it?

Create an instance of a management resource for use with WS-Management.

Example:

Create an instance of a management resource for use with WS-Management using HTTPS.

You need to specify a certificate for use with this listener since it is HTTPS. For testing purposes it is possible to create a self-signed certificate within IIS. Open the Create Self-Signed Certificate Wizard and enter a name.

Export it to C:\Temp

Import the pfx file into the Personal Certificate Store

For the New-WSManInstance cmdlet you will require the thumprint of this certificate, you can find this using PowerShell and the Certificate Provider.

Get-Childitem -path cert:\CurrentUser\My | Format-List FriendlyName,Thumbprint

Creation of the new WSManInstance using HTTPS is as follows:

New-WSManInstance winrm/config/Listener -SelectorSet @{Address="*";Transport=“HTTPS”} -ValueSet @{Hostname=“Test01”;CertificateThumbprint=“01F7EB07A4531750D920CE6A588BF5”}

You can verify this remotely using the Get-WSManInstance cmdlet.

Get-WSManInstance winrm/config/listener -selectorset @{Address="*";Transport=“https”} -computername Test01

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!