透過管理者進行遠端登出使用者的功能

匿名
2025-02-12T05:44:44+00:00

您好,

透過管理者進行遠端登出使用者的功能。

本地端須透過powershell Remoting打開(指令:Enable-PSRemoting -force)

但目前有遇到一些問題,就是希望透過GPO的方式派送該機制,

並且想要透過僅能從WINDOWS AD SERVER

及特定使用者(如網域[系統管理員])進行操控,但該部分派發執行時需要管理者權限。

請問GPO或防火牆需如何設定?

謝謝

Windows Server 身分識別和存取使用者登入和配置檔

鎖定的問題。 此問題從 Microsoft 支援社群移轉。 您可以投票決定內容是否有幫助,但不能新增評論或回覆,亦不能追蹤問題。 為保障私隱,已移轉問題的使用者個人檔案會匿名處理。

0 則留言 沒有意見
{count} 票

1 個答案

排序方式: 有幫助
  1. 匿名
    2025-02-12T07:54:59+00:00

    您好

    1. 透過GPO啟用PowerShell遠端管理(PSRemoting)

    1.1 啟用PSRemoting服務

    設定路徑:
    Computer Configuration → Policies → Administrative Templates → Windows Components → Windows Remote Management (WinRM) → WinRM Service

    啟用服務:
    啟用 Allow remote server management through WinRM,並設定 IPv4 filter 為 *(或指定IP範圍)。

    設定監聽埠:
    在 Specify listening ports... 中設定 5985(HTTP)或 5986(HTTPS)。

    1.2 自動啟動WinRM服務

    設定路徑:
    Computer Configuration → Preferences → Control Panel Settings → Services

    新增服務:

    服務名稱:WinRM

    啟動模式:Automatic

    操作:Start service

    1.3 啟用PowerShell執行原則

    設定路徑:
    Computer Configuration → Policies → Administrative Templates → Windows Components → Windows PowerShell

    啟用指令:
    啟用 Turn on Script Execution,設定執行原則為 RemoteSigned 或 Unrestricted。

    1. 防火牆規則設定(限制來源IP與使用者)

    2.1 允許WinRM流量(5985/5986)

    設定路徑:
    Computer Configuration → Policies → Windows Settings → Security Settings → Windows Defender Firewall with Advanced Security → Inbound Rules

    新增規則:

    規則類型:Predefined → Windows Remote Management

    允許協議:TCP,端口 5985(HTTP)或 5986(HTTPS)。

    作用域(Scope):

    遠端IP:僅允許AD伺服器IP或特定網段(例如 10.0.0.0/24)。

    使用者與權限(Advanced):

    僅允許來自 Domain Admins 或自定義安全群組(例如 PSRemote-Admins)。

    2.2 禁止其他遠端管理協定(選配)

    關閉RDP/Telnet:
    在防火牆中禁用 3389(RDP)、23(Telnet)等非必要協定。

    1. 權限控管(限制僅特定使用者可執行)

    3.1 設定WinRM ACL(安全描述符)

    透過GPO執行PowerShell指令:
    Computer Configuration → Policies → Windows Settings → Scripts (Startup/Shutdown)

    新增啟動腳本(PowerShell):
    powershell

    限制僅允許「Domain Admins」或自定義群組訪問WinRM

    $SDDL = "O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;DA)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)"
    Set-PSSessionConfiguration -Name Microsoft.PowerShell -SecurityDescriptorSddl $SDDL -Force

    說明:

    BA:Built-in Administrators(本地管理員)

    DA:Domain Admins(網域管理員)

    移除 WD(Everyone)以禁止非授權使用者。

    3.2 限制PowerShell遠端命令執行

    設定JEA(Just Enough Administration)(進階選配):

    建立JEA角色,限制管理員僅能執行特定指令(如 Logoff)。

    透過GPO部署JEA組態檔至目標電腦。

    1. 部署與驗證

    4.1 強制更新GPO

    在目標電腦上執行:
    powershell
    gpupdate /force

    4.2 驗證遠端管理功能

    測試WinRM連線:
    powershell

    從AD伺服器測試連線到目標電腦

    Test-WsMan -ComputerName <目標電腦名稱>

    遠端登出使用者:
    powershell

    使用Invoke-Command遠端執行登出指令

    Invoke-Command -ComputerName <目標電腦名稱> -ScriptBlock { logoff.exe $args[0] } -ArgumentList <SessionID> -Credential (Get-Credential)

    4.3 檢查權限是否生效

    模擬未授權使用者測試:
    使用非管理員帳戶嘗試遠端連接,應返回 Access Denied

    Best regards

    Runjie Zhai

    0 則留言 沒有意見