簡體   English   中英

Windows Server AD 2022 - 使用 PowerShell 通過 GPO 將域用戶添加到本地組“遠程桌面用戶”

[英]Windows Server AD 2022 - Add a domain user to the local group "Remote Desktop Users" via GPO using PowerShell

我必須通過 GPO 將域用戶添加到本地組“遠程桌面用戶”。

由於我正在以自動方式構建域控制器映像,因此我想創建一個策略以將域用戶設置為使用 PowerShell 加入 Windows 客戶端計算機的每個域的遠程桌面用戶本地組的一部分。

我一直在嘗試通過 PowerShell 從 GPO 管理受限組,但沒有成功。 我找到了以下代碼,但它只返回一個 .xml,我可以從 GPO 檢查位於受限組中的組。 https://social.technet.microsoft.com/Forums/en-US/a956c361-3852-4ec2-a6e3-15475e67bdaa/listing-gpo-restricted-groups-with-powershell?forum=winserverpowershell

如果有辦法將 GPO 導出為 .XML 或任何其他格式並對其進行編輯並導入更改,那也可以。

我發現的另一個論壇,它是一個很好的解決方案,但它仍然是手動的,如下一個。 我想通過 PowerShell 自動執行這些步驟,但這很難做到。 https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/using-group-policy-preferences-to-manage-the-local-administrator/ba-p/259223

請問,有沒有人知道一些自動化的方法來創建一個包含域用戶到本地組的 GPO?

謝謝大家!

   Try **Invoke-Command** and **Add-LocalGroupMember**

ForEach ($ServerName in $Servers)
{    
   Invoke-command -ComputerName $ServerName -ScriptBlock {Add-LocalGroupMember -Group "Remote Desktop User" -Member "Admin02", "MicrosoftAccount\username@Outlook.com", "AzureAD\DavidChew@contoso.com", "CONTOSO\Admins"}
}

https://social.technet.microsoft.com/wiki/contents/articles/20402.active-directory-group-policy-restricted-groups.aspx

創建新 GPO:計算機配置/策略/Windows 設置/安全設置/受限組

或者如果需要通過 powershell 腳本創建 GPO使用組策略配置 PowerShell 啟動腳本

並啟動腳本:

Add-LocalGroupMember -Group "Remote Desktop User" -Member "Admin02", "MicrosoftAccount\username@Outlook.com", "AzureAD\DavidChew@contoso.com", "CONTOSO\Admins"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM