PowerShell 2.0: One Cmdlet at a Time 40 Set-PSSessionConfiguration

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. Use Get-PSSessionConfiguration to confirm the creation.

The contents of the StartupScript contains the command to import the BITSTransfer module – you could easily add other code in here to futher customise the session.

Now change the properties of that session with Set-PSSessionConifguration. Clear the startup script settings and set the MaximumReceivedObjectSizeMB to 50 MB. Confirm the changes with Get-PSSessionConfiguration .

Register-PSSessionConfiguration -name BITSTransfer -StartupScript C:\Scripts\StartupScript.ps1 Get-PSSessionConfiguration Set-PSSessionConfiguration -name BITSTransfer -StartupScript $null -MaximumReceivedObjectSizeMB 50 Get-PSSessionConfiguration

You will notice that you are prompted to both confirm the change and to restart the WinRM service.

How could I have done this in PowerShell 1.0?

Remoting did not exist in PowerShell 1.0, you would have needed to use Remote Desktop to run an interactive session on a remote server.

1000 things 1% better!