# Custom Group List
$ServerNameGroup = Get-Content C:\temp\Server.txt
# Extract Group Members one by one.
foreach ($ADGroup in $ServerNameGroup){
# Check If Group Already have member to extract
If ((Get-ADGroupMember $ADGroup ).length -ne 0){
Get-ADGroupMember -Identity $ADGroup | select @{Name="ServerNameGroups";expression={$ADGroup}},name,objectClass |Out-File -Append C:\temp\Gropinfo.csv
} Else {
# Add Empty Group in Log.
"$ADGroup Member Value is Empty" |Out-File -Append C:\temp\Gropinfo.csv
}
}
No comments:
Post a Comment