Hi, I am stump, which is not hard to do. i have a list of groups and i want to list the users in those groups and then in the next column lists all the citrix only groups for each user. hopefully im describing that correctly. Heres what i have but it is not listing the users groups. I am not sure how to proceed.
$CurrentDate = Get-Date $CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm-ss') $Groupname = "Distribution Lists" $excel = New-Object -comobject Excel.Application $excel.visible = $True $wbook = $excel.Workbooks.Add() $wsheet = $wbook.Worksheets.Item(1) $wsheet.Cells.Item(1,1) = "Groupname" $wsheet.Cells.Item(1,2) = "Member" $wsheet.Cells.Item(1,3) = "ACID" $wsheet.Cells.Item(1,4) = "Department" $range = $wsheet.UsedRange $range.Interior.ColorIndex = 19 $range.Font.ColorIndex = 11 $range.Font.Bold = $True $intRow = 2 $groups = get-adgroup -Filter * -properties * -Searchbase "OU=Citrix,OU=Permission,OU=Groups,OU=Home Office,OU=domain,DC=Domain,DC=com" $targetFile = "c:\temp\$groupname $CurrentDate.csv" Add-Content $targetFile "Group;Member;ACID;Department" foreach ($group in $groups){ $groupMembers = get-adgroupmember $group -Recursive | Get-ADUser -Properties Department, DistinguishedName| Where-Object { $_.Enabled -eq 'True' } | Select-Object Name, samaccountname, department, distinguishedname, @{n='MemberOf';e={$_.MemberOf -replace '^cn=([^,]+).+$','$1' -join '; '} foreach ($groupMember in $groupMembers){ $groupName = $group.Name $memberName = $groupMember.Name $acid = $groupMember.samaccountname $groups = $usergroups #$department = $groupMember.department $department = $groupMember.memberof #$DistinguishedName = $gropmember.distinguishedname $line = "($groupName)--------($memberName)-----($acid)-------($department)------($usergroups)" add-content $targetFile $line $wsheet.Cells.Item($intRow,1) = $groupName $wsheet.Cells.Item($intRow,2) = $memberName $wsheet.Cells.Item($intRow,3) = $acid $wsheet.Cells.Item($intRow,4) = $groups $wsheet.Cells.Item($intRow,5) = $DistinguishedName $intRow++ } } $WorkBook.EntureColumn.AutoFit() $excel.SaveAs("DL" + "name.xlsx") $excel.Close()