Delen via


Disable-PSSessionConfiguration

Hiermee schakelt u sessieconfiguraties op de lokale computer uit.

Syntax

Disable-PSSessionConfiguration
       [[-Name] <String[]>]
       [-Force]
       [-NoServiceRestart]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

Description

Deze cmdlet is alleen beschikbaar op het Windows-platform.

De Disable-PSSessionConfiguration cmdlet schakelt sessieconfiguraties op de lokale computer uit, waardoor alle gebruikers de sessieconfiguraties niet kunnen gebruiken om een door de gebruiker beheerde sessies (PSSessions) op de lokale computer te maken. Dit is een geavanceerde cmdlet die is ontworpen om te worden gebruikt door systeembeheerders voor het beheren van aangepaste sessieconfiguraties voor hun gebruikers.

Vanaf PowerShell 3.0 stelt de Disable-PSSessionConfiguration cmdlet de instelling Ingeschakeld van de sessieconfiguratie (WSMan:\localhost\Plugins\<SessionConfiguration>\Enabled) in op False.

In PowerShell 2.0 voegt de Disable-PSSessionConfiguration cmdlet een Deny_All vermelding toe aan de beveiligingsdescriptor van een of meer geregistreerde sessieconfiguraties.

Zonder parameters Disable-PSSessionConfiguration schakelt u de Microsoft.PowerShell-configuratie uit, de standaardconfiguratie die wordt gebruikt voor sessies. Tenzij de gebruiker een andere configuratie opgeeft, kunnen lokale en externe gebruikers effectief geen sessies maken die verbinding maken met de computer.

Als u alle sessieconfiguraties op de computer wilt uitschakelen, gebruikt u Disable-PSRemoting.

Voorbeelden

Voorbeeld 1: De standaardconfiguratie uitschakelen

In dit voorbeeld wordt de configuratie van de Microsoft.PowerShell-sessie uitgeschakeld.

Disable-PSSessionConfiguration

Voorbeeld 2: Alle geregistreerde sessieconfiguraties uitschakelen

In dit voorbeeld worden alle geregistreerde sessieconfiguraties op de computer uitgeschakeld.

Disable-PSSessionConfiguration -Name *

Voorbeeld 3: Sessieconfiguraties op naam uitschakelen

In dit voorbeeld worden alle sessieconfiguraties uitgeschakeld met namen die beginnen met Microsoft. De parameter Force onderdrukt alle gebruikersprompts uit de cmdlet.

Disable-PSSessionConfiguration -Name Microsoft* -Force

Voorbeeld 4: Sessieconfiguraties uitschakelen met behulp van de pijplijn

In dit voorbeeld worden de MaintenanceShell- en Beheer Shell-sessieconfiguraties uitgeschakeld. De pijplijnoperator (|) verzendt de resultaten van een Get-PSSessionConfiguration naar Disable-PSSessionConfiguration.

Get-PSSessionConfiguration -Name MaintenanceShell, AdminShell | Disable-PSSessionConfiguration

Voorbeeld 5: Effecten van het uitschakelen van een sessieconfiguratie

In dit voorbeeld ziet u de machtigingen voor en na het uitvoeren Disable-PSSessionConfiguration en het effect van het uitschakelen van een sessieconfiguratie.

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 : PSSessionOpenFailed

Notitie

Als u de configuratie uitschakelt, voorkomt u niet dat u de configuratie wijzigt met behulp van de Set-PSSessionConfiguration cmdlet. Hiermee voorkomt u alleen het gebruik van de configuratie.

Parameters

-Confirm

Hiermee wordt u gevraagd om bevestiging voordat u de cmdlet uitvoert.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Hiermee dwingt u de opdracht uit te voeren zonder dat u om bevestiging van de gebruiker wordt gevraagd.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

Hiermee geeft u een matrix van namen van sessieconfiguraties die moeten worden uitgeschakeld. Voer een of meer configuratienamen in. Jokertekens zijn toegestaan. U kunt ook een tekenreeks met een configuratienaam of een sessieconfiguratieobject doorsluisen naar Disable-PSSessionConfiguration.

Als u deze parameter weglaat, Disable-PSSessionConfiguration schakelt u de configuratie van de Microsoft.PowerShell-sessie uit.

Type:String[]
Position:0
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:True

-NoServiceRestart

Wordt gebruikt om te voorkomen dat de WSMan-service opnieuw wordt opgestart. Het is niet nodig om de service opnieuw op te starten om de configuratie uit te schakelen.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Hiermee wordt weergegeven wat er zou gebeuren als u de cmdlet uitvoert. De cmdlet wordt niet uitgevoerd.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Invoerwaarden

Microsoft.PowerShell.Commands.PSSessionConfigurationCommands

U kunt een sessieconfiguratieobject doorsluisen naar deze cmdlet.

String

U kunt een tekenreeks met de naam van een sessieconfiguratie doorsluisen naar deze cmdlet.

Uitvoerwaarden

None

Deze cmdlet retourneert geen uitvoer.

Notities

Deze cmdlet is alleen beschikbaar op Windows-platforms.

Als u deze cmdlet wilt uitvoeren, moet u PowerShell starten met behulp van de optie Als administrator uitvoeren.