CmdID / PowerShell / Cmdlets / Disable
Disable-PSSessionConfiguration
Disables session configurations on the local computer. PowerShell reference
From the PowerShell reference 5 parameters
What it does
Disables session configurations on the local computer. The Disable-PSSessionConfiguration cmdlet disables session configurations on the local computer, which prevents all users from using the session configurations to create a user-managed sessions (PSSessions) on the local computer. This is an advanced cmdlet that is designed to be used by system administrators to manage customized session configurations for their users. Starting in PowerShell 3.0, the Disable-PSSessionConfiguration cmdlet sets the Enabled setting of the session configuration (WSMan:\localhost\Plugins\<SessionConfiguration>\Enabled) to False. In PowerShell 2.0, the Disable-PSSessionConfiguration cmdlet adds a Deny_All entry to the security descriptor of one or more registered session configurations. Without parameters, Disable-PSSessionConfiguration disables the Microsoft.PowerShell configuration, the default configuration used for sessions. Unless the user specifies a different configuration, both local and remote users are effectively prevented from creating any sessions that connect to the computer. To disable all session configurations on the computer, use Disable-PSRemoting.
Disable-PSSessionConfiguration [[-Name] <String[]>] [-Force] [-NoServiceRestart] [-WhatIf] [-Confirm] [<CommonParameters>]
Disable the default configuration
Disable-PSSessionConfigurationIdentifyDisable all registered session configurations
Disable-PSSessionConfiguration -Name *IdentifyDisable session configurations by name
Disable-PSSessionConfiguration -Name Microsoft* -ForceIdentifyDisable session configurations by using the pipeline
Get-PSSessionConfiguration -Name MaintenanceShell, AdminShell | Disable-PSSessionConfigurationIdentifyEffects of disabling a session configuration
PS> Get-PSSessionConfiguration | Format-Table -Property Name, Permission -Auto
Name Permission
---- ----------
MaintenanceShell BUILTIN\Administrators AccessAllowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
PS> Disable-PSSessionConfiguration -Name MaintenanceShell -Force
PS> Get-PSSessionConfiguration | Format-Table -Property Name, Permission -Auto
Name Permission
---- ----------
MaintenanceShell Everyone AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
PS> New-PSSession -ComputerName localhost -ConfigurationName MaintenanceShell
[localhost] Connecting to remote server failed with the following error message : Access is denied.
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: Disable-PSSessionConfiguration.
Parameters
-ForceForces the command to run without asking for user confirmation.-NameSpecifies an array of names of session configurations to disable. Enter one or more configuration names. Wildcard characters are permitted. You can also pipe a string that contains a configuration name or a session configuration object to Disable-PSSessionConfiguration.
If you omit this parameter, Disable-PSSessionConfiguration disables the Microsoft.PowerShell session configuration.-NoServiceRestartUsed to prevent the restart of the WSMan service. It is not necessary to restart the service to disable the configuration.-ConfirmPrompts you for confirmation before running the cmdlet.-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.