Disable-PSSessionConfiguration

Prevent all users of the computer from using the session configuration in a session. Disable-PSRemoting is a proxy for Disable-PSSessionConfiguration.
This is an advanced cmdlet designed for use by system administrators to manage custom session configurations for their users.

Syntax
      Disable-PSSessionConfiguration [[-Name] string[]]
        [-Force] [-Confirm] [-WhatIf] [CommonParameters]

Key
   -Name string
       The name(s) of session configurations to enable.
       Enter one or more configuration names. Wildcards are permitted.
       You can also pipe a configuration name (a string or a session configuration object.)
        
       If you omit this parameter, Disable-PSSessionConfiguration will
       disable the Microsoft.PowerShell session configuration.

   -force
       Suppress all user prompts.
       By default, you are prompted to confirm each operation.

   -confirm
       Prompt for confirmation before executing the command.

   -whatIf
       Describe what would happen if you executed the command without actually
       executing the command.

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

The Disable-PSSessionConfiguration cmdlet adds a "deny all" setting to the security descriptor of one or more registered session configurations. As a result, you can unregister, view, and change the configurations, but you cannot use them in a session.

Without parameters, Disable-PSSessionConfiguration disables the Microsoft.PowerShell configuration, which is the default configuration that is 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.

Note that Disable-PSRemoting / Disable-PSSessionConfiguration will not undo every change made by Enable-PSSessionConfiguration. It will set the permission Everyone=AccessDenied and BUILTIN\Administrators = AccessAllowed.

Examples

Disable the Microsoft.PowerShell session configuration:

PS C:> Disable-PSSessionConfiguration

Disable all registered session configurations on the computer:

PS C:> disable-pssessionConfiguration -name *

Disable all session configurations that have names that begin with "Microsoft":

PS C:> disable-pssessionConfiguration -name Microsoft* -force

Disable the MaintenanceShell and AdminShell session configurations, via pipe from Get-PSSessionConfiguration:

PS C:> Get-PSSessionConfiguration -name MaintenanceShell, AdminShell | Disable-PSSessionConfiguration

Disable all session configurations that have names that begin with "Microsoft":

PS C:> disable-pssessionConfiguration -name Microsoft* -force

“Economics is about how people make choices; sociology is about how they have no choices to make” ~ David Hackett Fisher

Related:

Enable-PSSessionConfiguration - Enable PS session configuration
Get-PSSessionConfiguration - Get the registered PS session configuration


© Copyright SS64.com 1999-2014
Some rights reserved