ค้นหาเว็บไซต์

ปิดการใช้งาน PSRemoting (Microsoft.PowerShell.Core)


ปิดการใช้งาน-PSRemoting

โมดูล :
Microsoft.PowerShell.Core

ป้องกันไม่ให้ปลายทาง PowerShell รับการเชื่อมต่อระยะไกล

ไวยากรณ์

Disable-PSRemoting
       [-Force]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

คำอธิบาย

cmdlet นี้ใช้ได้เฉพาะบนแพลตฟอร์ม Windows เท่านั้น

Disable-PSRemoting cmdlet บล็อกการเข้าถึงระยะไกลไปยัง PowerShell เวอร์ชัน 6 ทั้งหมดและการกำหนดค่าจุดสิ้นสุดเซสชันที่สูงกว่าบนคอมพิวเตอร์เฉพาะที่ ไม่ส่งผลต่อการกำหนดค่าปลายทางของ Windows PowerShell หากต้องการปิดใช้งานการกำหนดค่าจุดสิ้นสุดเซสชัน Windows PowerShell ให้เรียกใช้คำสั่ง Disable-PSRemoting จากภายในเซสชัน Windows PowerShell

หากต้องการเปิดใช้งานการเข้าถึงระยะไกลอีกครั้งสำหรับ PowerShell เวอร์ชัน 6 และการกำหนดค่าจุดสิ้นสุดเซสชันที่สูงกว่า ให้ใช้ cmdlet Enable-PSRemoting หากต้องการเปิดใช้งานการเข้าถึงระยะไกลอีกครั้งสำหรับการกำหนดค่าปลายทางเซสชัน Windows PowerShell ทั้งหมด ให้เรียกใช้ Enable-PSRemoting จากภายในเซสชัน Windows PowerShell

บันทึก

หากคุณต้องการปิดใช้งานการเข้าถึงระยะไกลของ PowerShell ทั้งหมดไปยังเครื่อง Windows ภายในเครื่อง คุณต้องเรียกใช้คำสั่งนี้ทั้งจากภายในเซสชัน PowerShell เวอร์ชัน 6 หรือสูงกว่า และจากภายในเซสชัน Windows PowerShell Windows PowerShell ได้รับการติดตั้งบนเครื่อง Windows ทั้งหมดตามค่าเริ่มต้น

หากต้องการปิดใช้งานและเปิดใช้งานการเข้าถึงระยะไกลอีกครั้งสำหรับการกำหนดค่าจุดสิ้นสุดเซสชันที่เฉพาะเจาะจง ให้ใช้ cmdlets Enable-PSSessionConfiguration และ Disable-PSSessionConfiguration หากต้องการตั้งค่าการกำหนดค่าการเข้าถึงเฉพาะของแต่ละปลายทาง ให้ใช้ Set-PSSessionConfiguration cmdlet ร่วมกับพารามิเตอร์ AccessMode สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการกำหนดค่าเซสชัน โปรดดู about_Session_Configurations

บันทึก

แม้หลังจากรัน Disable-PSRemoting แล้ว คุณยังคงสามารถสร้างการเชื่อมต่อแบบย้อนกลับบนเครื่องท้องถิ่นได้ การเชื่อมต่อแบบย้อนกลับคือเซสชันระยะไกลของ PowerShell ที่มาจากและเชื่อมต่อกับเครื่องเดียวกัน เซสชันระยะไกลจากแหล่งภายนอกยังคงถูกบล็อก สำหรับการเชื่อมต่อแบบย้อนกลับ คุณต้องใช้ข้อมูลประจำตัวโดยนัยพร้อมกับพารามิเตอร์ EnableNetworkAccess สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการเชื่อมต่อแบบย้อนกลับ โปรดดูที่ New-PSSession

cmdlet นี้ใช้ได้เฉพาะบนแพลตฟอร์ม Windows เท่านั้น ไม่พร้อมใช้งานบน PowerShell เวอร์ชัน Linux หรือ macOS หากต้องการเรียกใช้ cmdlet นี้ ให้เริ่ม PowerShell ด้วยตัวเลือก เรียกใช้ในฐานะผู้ดูแลระบบ

ตัวอย่าง

ตัวอย่างที่ 1: ป้องกันการเข้าถึงการกำหนดค่าเซสชัน PowerShell ทั้งหมดจากระยะไกล

ตัวอย่างนี้ป้องกันการเข้าถึงระยะไกลไปยังการกำหนดค่าปลายทางเซสชัน PowerShell ทั้งหมดบนคอมพิวเตอร์

Disable-PSRemoting

WARNING: PowerShell remoting has been disabled only for PowerShell 6+ configurations and does not affect
 Windows PowerShell remoting configurations. Run this cmdlet in Windows PowerShell to affect all PowerShell
 remoting configurations.

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.

ตัวอย่างที่ 2: ป้องกันการเข้าถึงการกำหนดค่าเซสชัน PowerShell ทั้งหมดจากระยะไกลโดยไม่ต้องพร้อมท์การยืนยัน

ตัวอย่างนี้ป้องกันการเข้าถึงระยะไกลการกำหนดค่าจุดสิ้นสุดเซสชัน PowerShell ทั้งหมดบนคอมพิวเตอร์โดยไม่ต้องพร้อมท์

Disable-PSRemoting -Force

WARNING: PowerShell remoting has been disabled only for PowerShell 6+ configurations and does not affect
 Windows PowerShell remoting configurations. Run this cmdlet in Windows PowerShell to affect all PowerShell
 remoting configurations.

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.

ตัวอย่างที่ 3: ผลของการเรียกใช้ cmdlet นี้

ตัวอย่างนี้แสดงผลของการใช้ cmdlet Disable-PSRemoting หากต้องการเรียกใช้ลำดับคำสั่งนี้ ให้เริ่ม PowerShell ด้วยตัวเลือก เรียกใช้ในฐานะผู้ดูแลระบบ

หลังจากปิดใช้งานการกำหนดค่าเซสชันแล้ว New-PSSession cmdlet จะพยายามสร้างเซสชันระยะไกลไปยังคอมพิวเตอร์ในระบบ (หรือที่เรียกว่า "loopback") เนื่องจากการเข้าถึงระยะไกลถูกปิดใช้งานบนเครื่องท้องถิ่น คำสั่งจึงล้มเหลว

Disable-PSRemoting -Force
New-PSSession -ComputerName localhost -ConfigurationName PowerShell.6

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

ตัวอย่างที่ 4: ผลของการเรียกใช้ cmdlet นี้และ Enable-PSRemoting

ตัวอย่างนี้แสดงผลต่อการกำหนดค่าเซสชันของการใช้ cmdlets Disable-PSRemoting และ Enable-PSRemoting

Disable-PSRemoting ใช้เพื่อปิดใช้งานการเข้าถึงระยะไกลไปยังการกำหนดค่าจุดสิ้นสุดเซสชัน PowerShell ทั้งหมด พารามิเตอร์ บังคับ จะระงับการแจ้งเตือนของผู้ใช้ทั้งหมด Get-PSSessionConfiguration และ Format-Table cmdlet จะแสดงการกำหนดค่าเซสชันบนคอมพิวเตอร์

ผลลัพธ์แสดงให้เห็นว่าผู้ใช้ระยะไกลทั้งหมดที่มีโทเค็นเครือข่ายถูกปฏิเสธไม่ให้เข้าถึงการกำหนดค่าอุปกรณ์ปลายทาง กลุ่มผู้ดูแลระบบบนคอมพิวเตอร์เฉพาะที่ได้รับอนุญาตให้เข้าถึงการกำหนดค่าปลายทางได้ ตราบใดที่พวกเขากำลังเชื่อมต่อภายในเครื่อง (หรือที่เรียกว่าลูปแบ็ค) และใช้ข้อมูลรับรองโดยนัย

Disable-PSRemoting -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -AutoSize

Enable-PSRemoting -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -AutoSize

Name               Permission
----               ----------
PowerShell.6       NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed ...
PowerShell.6.2.0   NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed ...

Name               Permission
----               ----------
PowerShell.6       NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed ...
PowerShell.6.2.0   NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed ...

Enable-PSRemoting cmdlet จะเปิดใช้งานการเข้าถึงระยะไกลไปยังการกำหนดค่าปลายทางเซสชัน PowerShell ทั้งหมดบนคอมพิวเตอร์อีกครั้ง พารามิเตอร์ บังคับ จะระงับการแจ้งผู้ใช้ทั้งหมด และเริ่มบริการ WinRM ใหม่โดยไม่แจ้ง ผลลัพธ์ใหม่แสดงว่าตัวบอกเกี่ยวกับความปลอดภัย AccessDenied ถูกลบออกจากการกำหนดค่าเซสชันทั้งหมดแล้ว

ตัวอย่างที่ 5: การเชื่อมต่อแบบวนกลับที่มีการกำหนดค่าจุดสิ้นสุดเซสชันที่ถูกปิดใช้งาน

ตัวอย่างนี้สาธิตวิธีการปิดใช้งานการกำหนดค่าอุปกรณ์ปลายทาง และแสดงวิธีสร้างการเชื่อมต่อแบบย้อนกลับไปยังอุปกรณ์ปลายทางที่ปิดใช้งานได้สำเร็จ Disable-PSRemoting ปิดใช้งานการกำหนดค่าจุดสิ้นสุดเซสชัน PowerShell ทั้งหมด

Disable-PSRemoting -Force

WARNING: PowerShell remoting has been disabled only for PowerShell 6+ configurations and does not affect
 Windows PowerShell remoting configurations. Run this cmdlet in Windows PowerShell to affect all PowerShell
 remoting configurations.

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 -ComputerName localhost -ConfigurationName powershell.6 -Credential (Get-Credential)

PowerShell credential request
Enter your credentials.
User: UserName
Password for user UserName: ************

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.

New-PSSession -ComputerName localhost -ConfigurationName powershell.6 -EnableNetworkAccess

Id Name       Transport ComputerName  ComputerType   State   ConfigurationName   Availability
 -- ----       --------- ------------  ------------   -----   -----------------   ------------
 1  Runspace1  WSMan     localhost     RemoteMachine  Opened  powershell.6           Available

การใช้ New-PSSession ครั้งแรกจะพยายามสร้างเซสชันระยะไกลไปยังเครื่องท้องถิ่น พารามิเตอร์ ConfigurationName ใช้เพื่อระบุจุดสิ้นสุด PowerShell ที่ปิดใช้งาน ข้อมูลรับรองจะถูกส่งอย่างชัดเจนไปยังคำสั่งผ่านพารามิเตอร์ ข้อมูลรับรอง การเชื่อมต่อประเภทนี้ต้องผ่านสแต็กเครือข่ายและไม่ใช่การวนกลับ ด้วยเหตุนี้ ความพยายามเชื่อมต่อกับปลายทางที่ถูกปิดใช้งานจึงล้มเหลวโดยมีข้อผิดพลาด การเข้าถึงถูกปฏิเสธ

การใช้ New-PSSession ครั้งที่สองยังเป็นการพยายามสร้างเซสชันระยะไกลไปยังเครื่องท้องถิ่น ในกรณีนี้ จะสำเร็จเนื่องจากเป็นการเชื่อมต่อแบบย้อนกลับที่เลี่ยงผ่านสแต็กเครือข่าย

การเชื่อมต่อแบบย้อนกลับจะถูกสร้างขึ้นเมื่อตรงตามเงื่อนไขต่อไปนี้:

  • ชื่อคอมพิวเตอร์ที่จะเชื่อมต่อคือ 'localhost'
  • ไม่มีการส่งผ่านข้อมูลประจำตัว ผู้ใช้ที่เข้าสู่ระบบในปัจจุบัน (ข้อมูลประจำตัวโดยนัย) ใช้สำหรับการเชื่อมต่อ
  • มีการใช้พารามิเตอร์สวิตช์ EnableNetworkAccess

สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการเชื่อมต่อแบบย้อนกลับ โปรดดูเอกสาร New-PSSession

ตัวอย่างที่ 6: การปิดใช้งานการกำหนดค่าปลายทางระยะไกลของ PowerShell ทั้งหมด

ตัวอย่างนี้แสดงให้เห็นว่าการรันคำสั่ง Disable-PSRemoting ไม่ส่งผลต่อการกำหนดค่าปลายทางของ Windows PowerShell อย่างไร Get-PSSessionConfiguration ทำงานภายใน Windows PowerShell แสดงการกำหนดค่าปลายทางทั้งหมด เราเห็นว่าการกำหนดค่าปลายทางของ Windows PowerShell ไม่ได้ถูกปิดใช้งาน

Disable-PSRemoting -Force
powershell.exe -command 'Get-PSSessionConfiguration'

WARNING: PowerShell remoting has been disabled only for PowerShell 6+ configurations and does not affect
 Windows PowerShell remoting configurations. Run this cmdlet in Windows PowerShell to affect all PowerShell
 remoting configurations.

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          : microsoft.powershell
PSVersion     : 5.1
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed, BUILTIN\Remote
                Management Users AccessAllowed

Name          : microsoft.powershell.workflow
PSVersion     : 5.1
StartupScript :
RunAsUser     :
Permission    : BUILTIN\Administrators AccessAllowed, BUILTIN\Remote Management Users AccessAllowed

Name          : microsoft.powershell32
PSVersion     : 5.1
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed, BUILTIN\Remote
                Management Users AccessAllowed

Name          : PowerShell.6
PSVersion     : 6.2
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators
                AccessAllowed, BUILTIN\Remote Management Users AccessAllowed

Name          : PowerShell.6.2.2
PSVersion     : 6.2
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators
                AccessAllowed, BUILTIN\Remote Management Users AccessAllowed

powershell.exe -command 'Disable-PSRemoting -Force'
powershell.exe -command 'Get-PSSessionConfiguration'

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          : microsoft.powershell
PSVersion     : 5.1
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators
                AccessAllowed, BUILTIN\Remote Management Users AccessAllowed

Name          : microsoft.powershell.workflow
PSVersion     : 5.1
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\NETWORK AccessDenied, BUILTIN\Administrators AccessAllowed, BUILTIN\Remote Management
                Users AccessAllowed

Name          : microsoft.powershell32
PSVersion     : 5.1
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators
                AccessAllowed, BUILTIN\Remote Management Users AccessAllowed

Name          : PowerShell.6
PSVersion     : 6.2
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators
                AccessAllowed, BUILTIN\Remote Management Users AccessAllowed

Name          : PowerShell.6.2.2
PSVersion     : 6.2
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators
                AccessAllowed, BUILTIN\Remote Management Users AccessAllowed

หากต้องการปิดใช้งานการกำหนดค่าปลายทางเหล่านี้ จะต้องเรียกใช้คำสั่ง Disable-PSRemoting จากภายในเซสชัน Windows PowerShell ขณะนี้ Get-PSSessionConfiguration ทำงานจากภายใน Windows PowerShell แสดงว่าการกำหนดค่าปลายทางทั้งหมดถูกปิดใช้งาน

ตัวอย่างที่ 7: ป้องกันการเข้าถึงระยะไกลไปยังการกำหนดค่าเซสชันที่มีตัวบอกเกี่ยวกับความปลอดภัยที่กำหนดเอง

ตัวอย่างนี้แสดงให้เห็นว่า cmdlet Disable-PSRemoting ปิดใช้งานการเข้าถึงระยะไกลไปยังการกำหนดค่าเซสชันทั้งหมดที่มีการกำหนดค่าเซสชันด้วยตัวบอกเกี่ยวกับความปลอดภัยที่กำหนดเอง

Register-PSSessionConfiguration สร้างการกำหนดค่าเซสชัน ทดสอบ พารามิเตอร์ FilePath ระบุไฟล์การกำหนดค่าเซสชันที่ปรับแต่งเซสชัน พารามิเตอร์ ShowSecurityDescriptorUI จะแสดงกล่องโต้ตอบที่ตั้งค่าสิทธิ์สำหรับการกำหนดค่าเซสชัน ในกล่องโต้ตอบสิทธิ์ เราสร้างสิทธิ์การเข้าถึงแบบเต็มแบบกำหนดเองสำหรับผู้ใช้ที่ระบุ

Get-PSSessionConfiguration และ Format-Table cmdlet จะแสดงการกำหนดค่าเซสชันและคุณสมบัติต่างๆ ผลลัพธ์แสดงให้เห็นว่าการกำหนดค่าเซสชัน ทดสอบ อนุญาตการเข้าถึงแบบโต้ตอบและการอนุญาตพิเศษสำหรับผู้ใช้ที่ระบุ

Disable-PSRemoting ปิดใช้งานการเข้าถึงการกำหนดค่าเซสชันทั้งหมดจากระยะไกล

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
----               ----------
PowerShell.6       NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed,
                   BUILTIN\Remote Management Users AccessAllowed
PowerShell.6.2.0   NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed,
                   BUILTIN\Remote Management Users AccessAllowed
Test               NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed,
                   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
----               ----------
PowerShell.6       NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed,
                   BUILTIN\Administrators AccessAllowed, BUILTIN\Remote Management Users AccessAllowed
PowerShell.6.2.0   NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed,
                   BUILTIN\Administrators AccessAllowed, BUILTIN\Remote Management Users AccessAllowed
Test               NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed,
                   BUILTIN\Administrators AccessAllowed, User01 AccessAllowed

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 Test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OpenError: (System.Management.A\u2026tion.RemoteRunspace:RemoteRunspace)
 [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed

ขณะนี้ Get-PSSessionConfiguration และ Format-Table cmdlet แสดงว่าตัวบอกเกี่ยวกับความปลอดภัย AccessDenied สำหรับผู้ใช้เครือข่ายทั้งหมดถูกเพิ่มลงในการกำหนดค่าเซสชันทั้งหมด รวมถึง ทดสอบ การกำหนดค่าเซสชัน แม้ว่าตัวบอกเกี่ยวกับความปลอดภัยอื่นๆ จะไม่เปลี่ยนแปลง แต่ตัวบอกเกี่ยวกับความปลอดภัย "network_deny_all" จะมีความสำคัญกว่า นี่แสดงให้เห็นโดยความพยายามในการใช้ New-PSSession เพื่อเชื่อมต่อกับการกำหนดค่าเซสชัน ทดสอบ

ตัวอย่างที่ 8: เปิดใช้งานการเข้าถึงระยะไกลอีกครั้งสำหรับการกำหนดค่าเซสชันที่เลือก

ตัวอย่างนี้แสดงวิธีเปิดใช้งานการเข้าถึงระยะไกลอีกครั้งเฉพาะกับการกำหนดค่าเซสชันที่เลือกเท่านั้น หลังจากปิดใช้งานการกำหนดค่าเซสชันทั้งหมดแล้ว เราจะเปิดใช้งานเซสชันเฉพาะอีกครั้ง

Set-PSSessionConfiguration cmdlet ใช้เพื่อเปลี่ยนการกำหนดค่าเซสชัน PowerShell.6 พารามิเตอร์ AccessMode ที่มีค่า Remote จะทำให้สามารถเข้าถึงการกำหนดค่าจากระยะไกลได้อีกครั้ง

Disable-PSRemoting -Force
Get-PSSessionConfiguration | Format-Table -Property Name, Permission -AutoSize

Set-PSSessionConfiguration -Name PowerShell.6 -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
----                 ----------
PowerShell.6         NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Adm ...
PowerShell.6.2.0     NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Adm ...

Name                 Permission
----                 ----------
PowerShell.6         NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed, BUILTIN\ ...
PowerShell.6.2.0     NT AUTHORITY\NETWORK AccessDenied, NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Adm ...

พารามิเตอร์

-Confirm

แจ้งให้คุณยืนยันก่อนเรียกใช้ cmdlet

พิมพ์ :

SwitchParameter

นามแฝง :

cf

ตำแหน่ง:

ตั้งชื่อ

ค่าเริ่มต้น:

False

ที่จำเป็น:

False

ยอมรับอินพุตไปป์ไลน์:

False

ยอมรับอักขระตัวแทน:

False

-Force

บังคับให้คำสั่งทำงานโดยไม่ต้องขอการยืนยันจากผู้ใช้

พิมพ์ :

SwitchParameter

ตำแหน่ง:

ตั้งชื่อ

ค่าเริ่มต้น:

None

ที่จำเป็น:

False

ยอมรับอินพุตไปป์ไลน์:

False

ยอมรับอักขระตัวแทน:

False

-WhatIf

แสดงสิ่งที่จะเกิดขึ้นหาก cmdlet ทำงาน cmdlet ไม่ทำงาน

พิมพ์ :

SwitchParameter

นามแฝง :

wi

ตำแหน่ง:

ตั้งชื่อ

ค่าเริ่มต้น:

False

ที่จำเป็น:

False

ยอมรับอินพุตไปป์ไลน์:

False

ยอมรับอักขระตัวแทน:

False

อินพุต

ไม่มี

คุณไม่สามารถไปป์วัตถุกับ cmdlet นี้

เอาท์พุต

ไม่มี

cmdlet นี้ส่งคืนไม่มีผลลัพธ์

หมายเหตุ

cmdlet นี้ใช้ได้เฉพาะบนแพลตฟอร์ม Windows เท่านั้น

  • การปิดใช้งานการกำหนดค่าเซสชันจะไม่เลิกทำการเปลี่ยนแปลงทั้งหมดที่เกิดขึ้นโดย cmdlet ของ Enable-PSRemoting หรือ Enable-PSSessionConfiguration คุณอาจต้องเลิกทำการเปลี่ยนแปลงต่อไปนี้ด้วยตนเอง

    1. หยุดและปิดใช้งานบริการ WinRM
    2. ลบ Listener ที่ยอมรับคำขอเกี่ยวกับที่อยู่ IP ใดๆ
    3. ปิดใช้งานข้อยกเว้นไฟร์วอลล์สำหรับการสื่อสาร WS-Management
    4. คืนค่าของ LocalAccountTokenFilterPolicy เป็น 0 ซึ่งจำกัดการเข้าถึงระยะไกลให้กับสมาชิกของกลุ่มผู้ดูแลระบบบนคอมพิวเตอร์
  • การกำหนดค่าจุดสิ้นสุดเซสชันคือกลุ่มของการตั้งค่าที่กำหนดสภาพแวดล้อมสำหรับเซสชัน ทุกเซสชันที่เชื่อมต่อกับคอมพิวเตอร์ต้องใช้การกำหนดค่าปลายทางเซสชันอย่างใดอย่างหนึ่งที่ลงทะเบียนบนคอมพิวเตอร์ ด้วยการปฏิเสธการเข้าถึงระยะไกลสำหรับการกำหนดค่าปลายทางเซสชันทั้งหมด คุณจะป้องกันไม่ให้ผู้ใช้ระยะไกลสร้างเซสชันที่เชื่อมต่อกับคอมพิวเตอร์ได้อย่างมีประสิทธิภาพ

บทความที่เกี่ยวข้อง