powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Disable-PSSessionConfiguration



NAME
Disable-PSSessionConfiguration

SYNOPSIS
Denies access to the session configurations on the local computer.

SYNTAX
Disable-PSSessionConfiguration [[-Name] ] [-Force] [-Confirm] [-WhatIf] []


DESCRIPTION
The Disable-PSSessionConfiguration cmdlet prevents all users of the computer from using the session configuration i
n a session. This is an advanced cmdlet that is designed to be used by system administrators to manage customized s
ession configurations for their users.

The Disable-PSSessionConfiguration cmdlet adds a "deny all" setting to the security descriptor of one or more regis
tered 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 de
fault 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.

To disable all session configurations on the computer, use Disable-PSRemoting.


PARAMETERS
-Force []
Suppresses all user prompts. By default, you are prompted to confirm each operation.

Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false

-Name
Specifies the names of session configurations to disable. Enter one or more configuration names. Wildcards are
permitted. You can also pipe a string that contains a configuration name or a session configuration object to D
isable-PSSessionConfiguration.

If you omit this parameter, Disable-PSSessionConfiguration disables the Microsoft.PowerShell session configurat
ion.

Required? false
Position? 1
Default value Microsoft.PowerShell
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? true

-Confirm []
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf []
Describes what would happen if you executed the command without actually executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS
Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration, System.String
You can pipe a session configuration object or a string that contains the name of a session configuration to Di
sable-PSSessionConfiguration.


OUTPUTS
None
This cmdlet does not return any objects.


NOTES


To run this cmdlet on Windows Vista, Windows Server 2008, and later versions of Windows, you must start Windows
PowerShell with the "Run as administrator" option.


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Disable-PSSessionConfiguration


Description
-----------
This command disables the Microsoft.PowerShell session configuration.





-------------------------- EXAMPLE 2 --------------------------

C:\PS>disable-pssessionConfiguration -name *


Description
-----------
This command disables all registered session configurations on the computer.





-------------------------- EXAMPLE 3 --------------------------

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


Description
-----------
This command disables all session configurations that have names that begin with "Microsoft". The command uses the
Force parameter to suppress all user prompts from the command.





-------------------------- EXAMPLE 4 --------------------------

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


Description
-----------
This command disables the MaintenanceShell and AdminShell session configurations.

The command uses a pipeline operator (|) to send the results of a Get-PSSessionConfiguration command to Disable-PSS
essionConfiguration.





-------------------------- EXAMPLE 5 --------------------------

C:\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

C:\PS> Disable-PSSessionConfiguration -name MaintenanceShell -force

C:\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

C:\PS> Set-PSSessionConfiguration -name MaintenanceShell -MaximumReceivedDataSizePerCommandMB 60

ParamName ParamValue
--------- ----------
psmaximumreceived... 60

"Restart WinRM service"
WinRM service need to be restarted to make the changes effective. Do you want to run the command "restart-service w
inrm"?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y


C:\PS> new-pssession -computername localhost -configurationName MaintenanceShell

[localhost] Connecting to remote server failed with the following error message : Access is denied. For more inform
ation, see the about_Remote_Troubl
eshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransport
Exception
+ FullyQualifiedErrorId : PSSessionOpenFailed


Description
-----------
This example shows the effect of disabling a session configuration.

The first command uses the Get-SessionConfiguration and Format-Table cmdlets to display only the Name and Permissio
n properties of the session configuration objects. This table format makes it easier to see the values of the objec
ts. The results show that members of the Administrators group are permitted to use the session configurations.

The second command uses the Disable-PSSessionConfiguration cmdlet to disable the MaintenanceShell session configura
tion. The command uses the Force parameter to suppress all user prompts.

The third command repeats the first command. The results show that you can still get the object that represents the
MaintenanceShell session configuration even though everyone is denied access to it. The "AccessDenied" entry takes
precedence over all other entries in the security descriptor.

The fourth command uses the Set-PSSessionConfiguration cmdlet to increase the MaximumDataSizePerCommandMB setting o
n the MaintenanceShell session configuration to 60. The results show that the command was successful even though ev
eryone is denied access to the configuration.

The fifth command attempts to use the MaintenanceShell session configuration in a session. It uses the New-PSSessio
n cmdlet to create a new session and the ConfigurationName parameter to specify the MaintenanceShell configuration.
The results show that the New-PSSession command fails because the user is denied access to the configuration.






RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=144299
about_Session_Configurations
Enable-PSSessionConfiguration
Get-PSSessionConfiguration
Register-PSSessionConfiguration
Set-PSSessionConfiguration
Unregister-PSSessionConfiguration
WS-Management Provider