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 .
The larger your organisation gets so do the number of users within your Active Directory and consequently the chances of employing people with the same name. Unless you have good naming policies from the start you may well end up with an untidy directory and if you are using Exchange an address book where it is hard to distinguish between people with the same Display Name.
The below script will generate you a report listing all users whose Display Name matches that of somebody else and for instance what a new Display Name would look like if you added their department field in brackets after their name - of course you could use another field entirely to distinguish them.
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
The first two sessions of the UK PowerShell User Group for 2010 will be online sessions.
The first event will take place on Tuesday 26th Jan 2010 7.30pm GMT. We will be looking at the Windows 2008 R2 cmdlets and provider for Active Directory.
Sign up details are available on Richard Siddaway’s blog.
The second event will take place on Tuesday 9th Feb 2010 7.30pm GMT. We will be looking at WMI and WQL.
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.