Export (0) Print
Expand All

Unregister-PSSessionConfiguration

Updated: August 9, 2015

Unregister-PSSessionConfiguration

Deletes registered session configurations from the computer.

Syntax

Parameter Set: Default
Unregister-PSSessionConfiguration [-Name] <String> [-Force] [-NoServiceRestart] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The Unregister-PSSessionConfiguration cmdlet deletes registered session configurations from the computer. This is an advanced cmdlet that is designed for system administrators to manage customized session configurations for users.

To make the change effective, Unregister-PSSessionConfiguration restarts the WinRM service. To prevent the restart, specify the NoServiceRestart parameter.

If you accidentally delete the default Microsoft.PowerShell or Microsoft.PowerShell32 session configurations, use the Enable-PSRemoting cmdlet to restore them. For more information, see about_Session_Configurations.

Parameters

-Force

Indicates that the cmdlet does not prompt you for confirmation, and restarts the WinRM service without prompting. Restarting the service makes the configuration change effective.

To prevent a restart and suppress the restart prompt, use the NoServiceRestart parameter.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name<String>

Specifies the names of the session configurations to delete. Enter one session configuration name or a configuration name pattern. Wildcard characters are permitted. This parameter is required.

You can also pipe a session configurations to Unregister-PSSessionConfiguration.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-NoServiceRestart

Indicates that this cmdlet does not restart the WinRM service, and suppresses the prompt to restart the service.

By default, when you run an Unregister-PSSessionConfiguration command, you are prompted to restart the WinRM service to make the change effective. Until the WinRM service is restarted, users can still use the unregistered session configuration, even though Get-PSSessionConfiguration does not find it.

To restart the WinRM service without prompting, specify the Force parameter. To restart the WinRM service manually, use the Restart-Service cmdlet.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration

    You can pipe a session configuration object from Get-PSSessionConfiguration to this cmdlet.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

    This cmdlet does not return any objects.


Notes

  • To run this cmdlet on Windows Vista, Windows Server 2008, and later versions of the Windows operating system, you must start Windows PowerShell by using the Run as administrator option.

Examples

Example 1: Delete a session configuration

This command deletes the MaintenanceShell session configuration from the computer.


PS C:\> Unregister-PSSessionConfiguration -Name "MaintenanceShell"

Example 2: Delete a session configuration and restart the WinRM service

This command deletes the MaintenanceShell session configuration from the computer. The command specifies the Force parameter to suppress all user messages, and to restart the WinRM service without prompting.


PS C:\> Unregister-PSSessionConfiguration -Name MaintenanceShell -Force

Example 3: Delete all session configurations

These commands delete all of the session configurations on the computer. The commands have the same effect and can be used interchangeably.


PS C:\> Unregister-PSSessionConfiguration -Name *
PS C:\> Get-PSSessionConfiguration -Name * | Unregister-PSSessionConfiguration

Example 4: Unregister without a restart

This example shows the effect of using the NoServiceRestart parameter of Unregister-PSSessionConfiguration. This parameter is designed to prevent a service restart, which would disrupt any sessions on the computer.

The first command uses Unregister-PSSessionConfiguration to deletes the MaintenanceShell session configuration. However, because the command uses the NoServiceRestart parameter, the WinRM service is not restarted and the change is not yet completely effective.

The second command uses Get-PSSessionConfiguration to get the MaintenanceShell session. Because the session has been removed from the WS-Management resource table, Get-PSSessionConfiguration cannot return it.

The third command uses the New-PSSession cmdlet to create a session on the local computer that uses the MaintenanceShell configuration. The command succeeds.

The fourth command uses the Restart-Service cmdlet to restart the WinRM service.

The fifth command again uses the New-PSSession cmdlet to create a session that uses the MaintenanceShell configuration. This time, the session fails because the MaintenanceShell configuration has been deleted.


PS C:\> Unregister-PSSessionConfiguration -Name "MaintenanceShell" -NoServiceRestart
PS C:\> Get-PSSessionConfiguration -Name "MaintenanceShell"

Get-PSSessionConfiguration -Name MaintenanceShell : No Session Configuration matches criteria "MaintenanceShell".
+ CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

PS C:\> New-PSSession -ConfigurationName "MaintenanceShell"

Id Name      ComputerName    State    Configuration         Availability
-- ----      ------------    -----    -------------         ------------
1 Session1  localhost       Opened   MaintenanceShell      Available

PS C:\> Restart-Service winrm
PS C:\> New-PSSession -ConfigurationName MaintenanceShell

[localhost] Connecting to remote server failed with the following error message : The WS-Management service cannot process the request. The resource URI (http://schemas.microsoft.com/powershell/MaintenanceShell) was not found in the WS-Management catalog. The catalog contains the metadata that describes resources, or logical endpoints. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed

Related topics

Community Additions

ADD
Show:
© 2016 Microsoft