CmdID / PowerShell / Cmdlets / Unregister
Unregister-PSSessionConfiguration
Deletes registered session configurations from the computer. PowerShell reference
From the PowerShell reference 5 parameters
What it does
Deletes registered session configurations from the computer. The Unregister-PSSessionConfiguration cmdlet deletes registered session configurations from the computer. This cmdlet 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.
Unregister-PSSessionConfiguration [-Name] <String> [-Force] [-NoServiceRestart] [-WhatIf] [-Confirm] [<CommonParameters>]
Delete a session configuration
Unregister-PSSessionConfiguration -Name "MaintenanceShell"IdentifyDelete a session configuration and restart the WinRM service
Unregister-PSSessionConfiguration -Name MaintenanceShell -ForceIdentifyDelete all session configurations
Unregister-PSSessionConfiguration -Name *
Get-PSSessionConfiguration -Name * | Unregister-PSSessionConfigurationIdentifyUnregister without a restart
PS> Unregister-PSSessionConfiguration -Name "MaintenanceShell" -NoServiceRestart
PS> 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> New-PSSession -ConfigurationName "MaintenanceShell"
Id Name ComputerName State Configuration Availability
-- ---- ------------ ----- ------------- ------------
1 Session1 localhost Opened MaintenanceShell Available
PS> Restart-Service winrm
PS> 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 : PSSessionOpenFailedIdentifyTrips 1 Sigma rule: lowUnusually Long PowerShell CommandLine by oscd.community, Natalia Shornikova
Its page in the reference: Unregister-PSSessionConfiguration.
Parameters
-ForceIndicates 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.-NameSpecifies 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.-NoServiceRestartIndicates 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.-ConfirmPrompts you for confirmation before running the cmdlet.-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.