0
我有这个跨越域的脚本。Powershell从组中删除用户
它查找从域A一用户的SID,然后检查域名用于何处此SID存在,然后特定群体添加域A SID到同一组域B.
#Connects to Domain A with admin credentials
Connect-QADService -Service DomainA.local -Credential domaina\
#gets username to work with
$user = Read-Host "Enter the users DomainA Username" Set-QADUser $user
#figures out the specific groups that need to be updated with the Domain A user
$UserXGroups = (Get-QADUser -Identity $user).MemberOf | Get-QADGroup | where {$_.Name -like "SG-*XX*" -or $_.Name -like "XX_*"} | select Name, DN, NTAccountName
#find DomainA user
$DomainAAccount = Read-Host "Confirm the users DomainA Username"
$Domainuser = Get-QADUser $DomainAAccount -Service DomainA.local
#Adds DomainA user to DomainB groups
Connect-QADService -Service DomainB.com -Credential domainb\
foreach($i in $UserXXGroups){
Add-QADGroupMember -Identity $i.Name -Member $DomainAuser | Out-Null
$i.NTAccountName
}
Write-Host "DomainA\$user added to above DomainB groups"
我想在将域A用户添加到域B组之前,我想要删除所有组域B的特定组。
,因为我们将使用域A作为主并添加用户到域B组基于什么在标签上域A
这是否有道理的成员?可以澄清,如果需要....任何帮助表示赞赏。
只有我们寻找,但肯定这是正确的特定群体:)在这种情况下 – user2707263
只需添加一个在没有匹配: $ user.memberof | Get-QADGroup |其中{$ _。name -notmatch'groupA'} |删除-QADGroupMember - 成员$用户 –