点击查看代码
$logpath= "C:\LocalTemp\AdGroupInfo.csv"
Add-Content -Path $logpath "GroupName,CanonicalName,MemberOf.Count,Member.Count"
$b=Get-ADGroup -Filter * -Properties *
$b|ForEach-Object {
if($_.Member.Count -eq 0 -and $_.MemberOf.Count -eq 0)
{
$str=$_.CN+','+$_.CanonicalName+','+$_.MemberOf.Count+','+$_.Member.Count
Add-Content -Path $logpath $str
}
}