Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-WSManInstance cmdlet.
What can I do with it?
Retrieve an instance of a management resource specified by a URI by using WS-Management.
Examples:
Display management information for the BITS service on the remote computer Test01.
Get-WSManInstance wmicimv2/win32_service -selectorset @{name=“BITS”} -computername Test01
Notice that you receive many properties for the BITS service.
Display management information for the WS-Management listener configuration on the remote computer Test01.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Test-WSMan cmdlet.
What can I do with it?
Test whether WS-Management is available on a computer.
Example:
Test whether WS-Management is available on Test01.
Test-WSMan -ComputerName Test01
You will notice you receive a response detailing wsmid, ProtocolVersion, ProductVendor and ProductVersion if the query is successful.
How could I have done this in PowerShell 1.
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
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Connect-WSMan cmdlet.
What can I do with it?
Create a connection to a remote computer using WS-Management .
Example:
Connect to the remote server Test01 using WS-Management . Use the WSMan provider to examine the WSMan Shell properties and change the value for MaxShellsPerUser to 10.
Connect-WSMan -ComputerName Test01 cd wsman: dir
cd .
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Set-WSManQuickConfig cmdlet.
What can I do with it?
Configure the local computer for use with WS-Management .
Example:
Configure the local computer to be enabled for remote management with WS-Management .
Set-WSManQuickConfig
This will produce output similar to the below; note the command was run on a Windows Server 2008 64bit system.
Set-WSManQuickConfig runs the following tasks: —– Starts the WinRM service if necessary.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Enable-PSSessionConfiguration cmdlet.
What can I do with it?
Re-enable access to a session configuration which has previously been disabled with Disable-PSSessionConfiguration.
Example:
View the permissions of the currently disabled BITSTransfer PSSessionConfiguration, re-enable it, then view the permissions again.
Get-PSSessionConfiguration -Name BITSTransfer | Format-Table -property Name,Permission -auto Enable-PSSessionConfiguration -Name BITSTransfer Get-PSSessionConfiguration -Name BITSTransfer | Format-Table -property Name,Permission -auto
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Unregister-PSSessionConfiguration cmdlet.
What can I do with it?
Delete PSSessionConfigurations on the local computer.
Example:
View the existing available PSSessionConfigurations with Get-PSSessionConfiguration, remove the BITSTransfer configuration and then confirm it has been removed.
Get-PSSessionConfiguration Unregister-PSSessionConfiguration -Name BITSTransfer Get-PSSessionConfiguration
You will see that you are prompted to both confirm and the action and the restart of the WinRM service.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Set-PSSessionConfiguration cmdlet.
What can I do with it?
Change the properties of a session configuration which has been registered with Register-PSSessionConfiguration.
Example:
Create a new PSSession Configuration called BITSTransfer using the startup script C:\Scripts\StartupScript.ps1. Use StartupScript.ps1 to import the PowerShell 2.0 BITS Transfer module so that those cmdlets are available to the user of the remote session.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Disable-PSSessionConfiguration cmdlet.
What can I do with it?
Deny access to a session configuration.
Example:
Examine the permissions of the previously created PSSessionConfiguration named BITSTransfer. Deny access to this session using Disable-PSSessionConfiguration. Use the Force parameter to supress prompts. Check what the permissions on the configuration have been changed to.
Get-PSSessionConfiguration -Name BITSTransfer | Format-Table -property Name,Permission -auto Disable-PSSessionConfiguration -Name BITSTransfer -Force Get-PSSessionConfiguration -Name BITSTransfer | Format-Table -property Name,Permission -auto
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Register-PSSessionConfiguration cmdlet.
What can I do with it?
Session configurations determine the settings used by remote PowerShell sessions to that computer. This cmdlet enables the creation of customised settings for particular session requirements.
Example:
Create a new PSSession Configuration called BITSTransfer using the startup script C:\Scripts\StartupScript.ps1. Use StartupScript.ps1 to import the PowerShell 2.0 BITS Transfer module so that those cmdlets are available to the user of the remote session.