可以使用PowerShell脚本来进行Active Directory组成员的审核。以下是示例代码:
Import-Module ActiveDirectory
$groupName = "MyGroup"
$groupInfo = Get-ADGroup -Identity $groupName -Properties Members
$groupMembers = Get-ADGroupMember -Identity $groupName
$groupMembers | ForEach-Object { Write-Host "Member: $($_.Name)" }
$groupInfo.Members | ForEach-Object { $member = Get-ADUser -Identity $_ -Properties MemberOf if ($member.MemberOf -notcontains $groupName) { Write-Warning "$($member.Name)不属于$($groupName)" } }
该脚本会输出给定组的所有成员,并检查是否有不属于该组的用户。可以根据需要进行修改和调整。