<#
Thisscript can be used to list group members for Walmart SZ
Needto modify GroupName under C:\temp\GList.txt first
Formartcan be easy transfored
Date:2017-03-09
#>
Set-Content c:\temp\Groups.txt -Value"GroupName,Group Members"
Get-Content "C:\Temp\GList.txt" | ForEach-Object {
$g1= -Join ($_,",")
Add-Content -Path "c:\temp\Groups.txt" -Value $g1
$grp = "CN=" +$_+",OU=XXX,OU=XXX,OU=XXXX,OU=XXXX,DC=bbb,DC=ccc,DC=com"
write-host $_
$onegroup = [ADSI] "LDAP:// $grp"
foreach ($member in $onegroup.member)
{
$Uname = new-objectdirectoryservices.directoryentry("LDAP://$member")
Add-Content -Path"c:\temp\Groups.txt" -Value $u1
write-host $u1
}
}
import-csv c:\temp\Groups.txt -delimiter "," |export-csv c:\temp\GroupDetails.csv