Disable-PSRemoting
Hiermee voorkomt u dat PowerShell-eindpunten externe verbindingen ontvangen.
Syntaxis
Disable-PSRemoting
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
De Disable-PSRemoting
cmdlet blokkeert externe toegang tot alle configuraties van windows PowerShell-sessie-eindpunten op de lokale computer. Dit omvat alle eindpunten die zijn gemaakt door PowerShell 6 of hoger.
Gebruik de Enable-PSRemoting
cmdlet om externe toegang opnieuw in te schakelen voor alle sessieconfiguraties. Dit omvat alle eindpunten die zijn gemaakt door PowerShell 6 of hoger. Als u externe toegang tot geselecteerde sessieconfiguraties wilt inschakelen, gebruikt u de parameter AccessMode van de Set-PSSessionConfiguration
cmdlet.
U kunt ook de Enable-PSSessionConfiguration
en Disable-PSSessionConfiguration
cmdlets gebruiken om sessieconfiguraties voor alle gebruikers in en uit te schakelen. Zie about_Session_Configurations (Engelstalig) voor meer informatie over sessieconfiguraties.
Notitie
Zelfs na het uitvoeren Disable-PSRemoting
kunt u nog steeds loopback-verbindingen maken op de lokale computer. Een loopback-verbinding is een externe PowerShell-sessie die afkomstig is van en verbinding maakt met dezelfde lokale computer. Externe sessies van externe bronnen blijven geblokkeerd. Voor loopback-verbindingen moet u impliciete referenties gebruiken in de parameter EnableNetworkAccess . Zie New-PSSession voor meer informatie over loopback-verbindingen.
Als u deze cmdlet wilt uitvoeren, start u Windows PowerShell met de optie Als administrator uitvoeren.
Voorbeelden
Voorbeeld 1: Externe toegang tot alle sessieconfiguraties voorkomen
In dit voorbeeld voorkomt u externe toegang tot alle configuraties van powerShell-sessie-eindpunten op de computer.
Disable-PSRemoting
WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting
or Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these
steps:
1. Stop and disable the WinRM service.
2. Delete the listener that accepts requests on any IP address.
3. Disable the firewall exceptions for WS-Management communications.
4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to
members of the Administrators group on the computer.
Voorbeeld 2: Externe toegang tot alle sessieconfiguraties voorkomen zonder bevestigingsprompt
In dit voorbeeld voorkomt u dat alle configuraties van powerShell-sessie-eindpunten op de computer worden geconfigureerd zonder dat u hierom wordt gevraagd.
Disable-PSRemoting -Force
WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting
or Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these
steps:
1. Stop and disable the WinRM service.
2. Delete the listener that accepts requests on any IP address.
3. Disable the firewall exceptions for WS-Management communications.
4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to
members of the Administrators group on the computer.
Voorbeeld 3: Effecten van het uitvoeren van deze cmdlet
In dit voorbeeld ziet u het effect van het gebruik van de Disable-PSRemoting
cmdlet. Als u deze opdrachtreeks wilt uitvoeren, start u PowerShell met de optie Als administrator uitvoeren.
Nadat de sessieconfiguraties zijn uitgeschakeld, probeert de New-PSSession
cmdlet een externe sessie naar de lokale computer te maken (ook wel een 'loopback' genoemd). Omdat externe toegang is uitgeschakeld op de lokale computer, mislukt de opdracht.
Disable-PSRemoting -Force
New-PSSession -ComputerName localhost
WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting
or Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these steps:
1. Stop and disable the WinRM service.
2. Delete the listener that accepts requests on any IP address.
3. Disable the firewall exceptions for WS-Management communications.
4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to
members of the Administrators group on the computer.
New-PSSession : [localhost] Connecting to remote server localhost failed with the following error
message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ New-PSSession -ComputerName localhost -ConfigurationName PowerShell.6
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Management.A\u2026tion.RemoteRunspace:RemoteRunspace)
[New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
Voorbeeld 4: Effecten van het uitvoeren van deze cmdlet en Enable-PSRemoting
In dit voorbeeld ziet u het effect op de sessieconfiguraties van het gebruik van de Disable-PSRemoting
en Enable-PSRemoting
cmdlets.
Disable-PSRemoting
wordt gebruikt om externe toegang tot alle configuraties van powerShell-sessie-eindpunten uit te schakelen. De parameter Force onderdrukt alle gebruikersprompts. De Get-PSSessionConfiguration
en Format-Table
cmdlets geven de sessieconfiguraties op de computer weer.
In de uitvoer ziet u dat alle externe gebruikers met een netwerktoken geen toegang hebben tot de eindpuntconfiguraties. Beheerdersgroep op de lokale computer heeft toegang tot de eindpuntconfiguraties zolang ze lokaal verbinding maken (ook wel loopback genoemd) en impliciete referenties gebruiken.
Disable-PSRemoting -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -AutoSize
Enable-PSRemoting -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -AutoSize
Name Permission
---- ----------
microsoft.powershell NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell.workflow NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell32 NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.ServerManager NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
WithProfile NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
Name Permission
---- ----------
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell.workflow BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
microsoft.ServerManager BUILTIN\Administrators AccessAllowed
WithProfile BUILTIN\Administrators AccessAllowed
Met Enable-PSRemoting
de cmdlet wordt externe toegang opnieuw ingeschakeld voor alle configuraties van powerShell-sessie-eindpunten op de computer. De parameter Force onderdrukt alle gebruikersprompts en start de WinRM-service opnieuw zonder te vragen. In de nieuwe uitvoer ziet u dat de AccessDenied-beveiligingsdescriptors zijn verwijderd uit alle sessieconfiguraties.
Voorbeeld 5: Loopback-verbindingen met uitgeschakelde configuraties van sessie-eindpunten
In dit voorbeeld ziet u hoe eindpuntconfiguraties zijn uitgeschakeld en ziet u hoe u een geslaagde loopback-verbinding maakt met een uitgeschakeld eindpunt. Disable-PSRemoting
schakelt alle configuraties van het PowerShell-sessieeindpunt uit.
Disable-PSRemoting -Force
New-PSSession -ComputerName localhost
WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting
or Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these steps:
1. Stop and disable the WinRM service.
2. Delete the listener that accepts requests on any IP address.
3. Disable the firewall exceptions for WS-Management communications.
4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to
members of the Administrators group on the computer.
New-PSSession : [localhost] Connecting to remote server localhost failed with the following error message : Access is
denied. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ New-PSSession -ComputerName localhost
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
gTransportException
+ FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
New-PSSession -ComputerName localhost -EnableNetworkAccess
Id Name Transport ComputerName ComputerType State ConfigurationName Availability
-- ---- --------- ------------ ------------ ----- ----------------- ------------
1 Runspace1 WSMan localhost RemoteMachine Opened powershell.6 Available
Het eerste gebruik van New-PSSession
pogingen om een externe sessie te maken op de lokale computer. Dit type verbinding gaat via de netwerkstack en is geen loopback. Als gevolg hiervan mislukt de verbindingspoging naar het uitgeschakelde eindpunt met een access-fout.
Het tweede gebruik van New-PSSession
probeert ook een externe sessie te maken op de lokale computer.
In dit geval lukt het omdat het een loopback-verbinding is die de netwerkstack omzeilt.
Er wordt een loopback-verbinding gemaakt wanneer aan de volgende voorwaarden wordt voldaan:
- De computernaam waarmee verbinding moet worden gemaakt, is 'localhost'.
- Er worden geen referenties doorgegeven. De huidige aangemelde gebruiker (impliciete referenties) wordt gebruikt voor de verbinding.
- De parameter EnableNetworkAccess-switch wordt gebruikt.
Zie het document New-PSSession voor meer informatie over loopback-verbindingen.
Voorbeeld 6: Externe toegang tot sessieconfiguraties met aangepaste beveiligingsdescriptors voorkomen
In dit voorbeeld ziet u dat de Disable-PSRemoting
cmdlet externe toegang uitschakelt tot alle sessieconfiguraties met sessieconfiguraties met aangepaste beveiligingsdescriptors.
Register-PSSessionConfiguration
maakt de configuratie van de testsessie . Met de parameter FilePath geeft u een sessieconfiguratiebestand op waarmee de sessie wordt aangepast. De parameter ShowSecurityDescriptorUI geeft een dialoogvenster weer waarin machtigingen voor de sessieconfiguratie worden ingesteld. In het dialoogvenster Machtigingen maken we aangepaste machtigingen voor volledige toegang voor de aangegeven gebruiker.
De Get-PSSessionConfiguration
en Format-Table
cmdlets geven de sessieconfiguraties en de bijbehorende eigenschappen weer. In de uitvoer ziet u dat de configuratie van de testsessie interactieve toegang en speciale machtigingen toestaat voor de aangegeven gebruiker.
Disable-PSRemoting
schakelt externe toegang tot alle sessieconfiguraties uit.
Register-PSSessionConfiguration -Name Test -FilePath .\TestEndpoint.pssc -ShowSecurityDescriptorUI -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -Wrap
Disable-PSRemoting -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -Wrap
New-PSSession -ComputerName localhost -ConfigurationName Test
Name Permission
---- ----------
microsoft.powershell BUILTIN\Administrators AccessAllowed
Test NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed,
DOMAIN01\User01 AccessAllowed
WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting
or Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these steps:
1. Stop and disable the WinRM service.
2. Delete the listener that accepts requests on any IP address.
3. Disable the firewall exceptions for WS-Management communications.
4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to
members of the Administrators group on the computer.
Name Permission
---- ----------
microsoft.powershell NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
Test NT AUTHORITY\NETWORK AccessDenied, NTAUTHORITY\INTERACTIVE AccessAllowed,
BUILTIN\Administrators AccessAllowed, DOMAIN01\User01 AccessAllowed
[Server01] Connecting to remote server failed with the following error message : Access is denied. For more information, see the about_Rem
ote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
Get-PSSessionConfiguration
De en Format-Table
cmdlets laten nu zien dat een AccessDenied-beveiligingsdescriptor voor alle netwerkgebruikers wordt toegevoegd aan alle sessieconfiguraties, inclusief de configuratie van de testsessie. Hoewel de andere beveiligingsdescriptors niet worden gewijzigd, heeft de beveiligingsdescriptor 'network_deny_all' voorrang. Dit wordt geïllustreerd door de poging om verbinding te New-PSSession
maken met de testsessieconfiguratie.
Voorbeeld 7: Externe toegang opnieuw inschakelen voor geselecteerde sessieconfiguraties
In dit voorbeeld ziet u hoe u externe toegang alleen opnieuw inschakelt voor geselecteerde sessieconfiguraties. Nadat alle sessieconfiguraties zijn uitgeschakeld, schakelen we een specifieke sessie opnieuw in.
De Set-PSSessionConfiguration
cmdlet wordt gebruikt om de microsoft te wijzigen. ServerManager-sessieconfiguratie . Met de parameter AccessMode met de waarde Remote wordt externe toegang tot de configuratie opnieuw ingeschakeld.
Disable-PSRemoting -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -AutoSize
Set-PSSessionConfiguration -Name Microsoft.ServerManager -AccessMode Remote -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -AutoSize
WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting
or Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these steps:
1. Stop and disable the WinRM service.
2. Delete the listener that accepts requests on any IP address.
3. Disable the firewall exceptions for WS-Management communications.
4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to
members of the Administrators group on the computer.
Name Permission
---- ----------
microsoft.powershell NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell.workflow NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell32 NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.ServerManager NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
WithProfile NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
Name Permission
---- ----------
microsoft.powershell NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell.workflow NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell32 NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.ServerManager BUILTIN\Administrators AccessAllowed
WithProfile NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed
Parameters
-Confirm
Hiermee wordt u gevraagd om bevestiging voordat u de cmdlet uitvoert.
Type: | SwitchParameter |
Aliassen: | cf |
Position: | Named |
Default value: | False |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | 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 |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-WhatIf
Hiermee wordt weergegeven wat er zou gebeuren als u de cmdlet uitvoert. De cmdlet wordt niet uitgevoerd.
Type: | SwitchParameter |
Aliassen: | wi |
Position: | Named |
Default value: | False |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
Invoerwaarden
None
U kunt geen objecten doorsluisen naar deze cmdlet.
Uitvoerwaarden
None
Deze cmdlet retourneert geen uitvoer.
Notities
Als u de sessieconfiguraties uitschakelt, worden niet alle wijzigingen ongedaan gemaakt die zijn aangebracht door de
Enable-PSRemoting
ofEnable-PSSessionConfiguration
cmdlets. Mogelijk moet u de volgende wijzigingen handmatig ongedaan maken.- Stop en schakel de WinRM-service uit.
- Verwijder de listener die aanvragen accepteert op elk IP-adres.
- Schakel de firewall-uitzonderingen voor WS-Management-communicatie uit.
- Herstel de waarde van localAccountTokenFilterPolicy naar 0, waardoor externe toegang wordt beperkt tot leden van de groep Administrators op de computer.
Een sessieconfiguratie is een groep instellingen waarmee de omgeving voor een sessie wordt gedefinieerd. Elke sessie die verbinding maakt met de computer, moet een van de sessieconfiguraties gebruiken die zijn geregistreerd op de computer. Door externe toegang tot alle sessieconfiguraties te weigeren, voorkomt u effectief dat externe gebruikers sessies tot stand brengen die verbinding maken met de computer.
In Windows PowerShell 2.0
Disable-PSRemoting
voegt u een Deny_All vermelding toe aan de beveiligingsdescriptors van alle sessieconfiguraties. Met deze instelling voorkomt u dat alle gebruikers door gebruikers beheerde sessies maken op de lokale computer. In Windows PowerShell 3.0Disable-PSRemoting
voegt u een Network_Deny_All vermelding toe aan de beveiligingsdescriptors van alle sessieconfiguraties. Met deze instelling voorkomt u dat gebruikers op andere computers door gebruikers beheerde sessies maken op de lokale computer, maar gebruikers van de lokale computer toestaan om door gebruikers beheerde loopbacksessies te maken.In Windows PowerShell 2.0
Disable-PSRemoting
is dit het equivalent vanDisable-PSSessionConfiguration -Name *
. In versies van Windows PowerShell 3.0 en hoger isDisable-PSRemoting
dit het equivalent vanSet-PSSessionConfiguration -Name \<Configuration name\> -AccessMode Local