Scripting. Powershell, VMware, Windows, Active Directory & Exchange. All that kind of stuff…..
RSS icon Email icon Home icon
  • PowerShell 2.0: One Cmdlet at a Time #39 Register-PSSessionConfiguration

    Posted on January 14th, 2010 Jonathan Medd No comments

    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. 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.

    StartupScript

    Register-PSSessionConfiguration -name BITSTransfer
    -StartupScript C:\Scripts\StartupScript.ps1

    You will see that you are prompted for both confirmation and whether to restart the WinRM service.

    Register-PSSessionConfiguration

    To use this particular PSSession Configuration use the New-PSSession cmdlet with the ConfigurationName parameter and specify the name of the configuration BITSTransfer. Then connect to the session with the Enter-PSSession cmdlet and comfirm you have the BITS Transfer module by running Get-Module.

    New-PSSession -ConfigurationName BITSTransfer
    -ComputerName Test01
    Enter-PSSession -Id 1
    Get-Module

    Register-PSSessionConfiguration2

    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!

    Leave a reply