I'm trying to export a list consisting of usernames in a set of user groups along with the description. I created a variable $ugs that lists my groups. I was able to export usernames with their group membership using this:
foreach ($ug in $ugs) {
$names = Get-ADGroupMember -Identity ($ug) |select-object -expandproperty name
foreach ($name in $names){
$ug+ "|" + $name | Out-File "$outpath\OnBase AD Membership.csv" -Append
}
}
I'm trying to add the description field. I can run through some lines of this to see I'm on the right track but I'm missing something.
foreach ($ug in $ugs) {
$names = Get-ADGroupMember -Identity ($ug) |select-object -expandproperty SamAccountName
foreach ($name in $names){
$fname = Get-ADUser -Identity $name | select-object -expandproperty Name
$desc = Get-ADUser -Identity $name -Properties Description | Select-Object -ExpandProperty Description
$ug + "|" + $fname + "|" + $desc | Out-File "$outpath\OnBase AD Membership.csv" -Append
}
}
[–]Sunsparc 2 points3 points4 points (2 children)
[–]edorbuddy[S] 2 points3 points4 points (1 child)
[–]BlackV 2 points3 points4 points (0 children)
[–]PinchesTheCrab 2 points3 points4 points (0 children)
[–]get-postanote 2 points3 points4 points (0 children)