The script is perfect. I just need to add an attribute (EmployeeNumber) for a user for the "DetailedMember sReport". I'm just getting started learning powershell,but I could really use the report soon. I see where it's exporting everything below. I just don't know how to get it to Also include an Attribute of the user. I tried just adding in -EmployeeNumber but it's just blank., I'm quite sure it's the wrong place for an attribute. *thanks for whoever worked on this script. It's pretty awesome. --------------- --------------- --------------- --------------- --------------- --------------- ------ #Print Detailed Output Function Print_Output { if($Print -eq 1) { $Result=@{'Disp layName'=$Displ ayName;'Primary SmtpAddress'=$E mailAddress;'Al ias'=$Alias;'Me mbers'=$Member; 'EmployeeNumber '=$EmployeeNumb er;'MemberEmail '=$MemberEmail; 'MemberType'=$R ecipientTypeDet ail} $Results= New-Object PSObject -Property $Result $Results | Select-Object DisplayName,Pri marySmtpAddress ,Alias,Members, EmployeeNumber, MemberEmail,Mem berType | Export-Csv -Path $ExportCSV -Notype -Append
Hi, Apart from the above code changes, you need to store EmployeeID in $EmployeeNumber. To get EmployeeID, you require to call the AzureAD module. So, you need to add the below code in your downloaded script. in line 99: $EmployeeNumber =(Get-AzureADUs er -ObjectId $MemberEmail).E xtensionPropert y["employeeId"] in line 216: Connect-AzureAD After this change, you will get the desired output. If you need further assistance, let me know. Note: If the distribution group has another group as member, then Get-AzureADUser code will fail. If you want to generate report without PowerShell, I'd suggest you to try Office 365 reporting Tool by AdminDroid.
I have the script in my c:\test folder. in powershell (opened as administrator) I cd \test I run it in office 365 PS with .\getdistributiongroupmembers. ps1 it asks for my email credentials (I am a global admin). It runs a bit and I get: Get-Content : Cannot find path 'C:\test\Recipi entTypeDetails. txt' because it does not exist. At C:\test\getdist ributiongroupme mbers.ps1:221 char:22 + ... ntTypeArray=Get -Content -Path .\RecipientType Details.txt -ErrorAction ... + ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\test\Recipi entTypeDetails. txt:String) [Get-Content], ItemNotFound Exception + FullyQualifiedE rrorId : PathNotFound,Mi crosoft.PowerSh ell.Commands.Ge tContentCommand it ends and there's no other file in the test folder.
i did some googling and it said to check get-location, which comes back with c:\test I edited line 221 and others that had .\recpient..... to "c:\test\recip...." and also wthout the quotes. Same error. I am an admin on the local PC which is in a workgroup.
Hi mikeRenna, Do you have RecipientTypeDetails.txt in the specified folder? Note: RecipientTypeDe tails.txt comes along with script when you download the script zip. If the txt file is not available, please download the script again.
It shows zero members for a distribution group that has only one member, what that only member is another distribution group. Request to add feature so that it should take into account if a member is also a distribution group. For example, I have two distribution groups. Group1, and Group2. Group2 is a member and the only member of Group1. This script will show that Group1 has zero members, but it in fact has another member, that member is Group2. Thanks for the script!
Hi, We tested this script in our test environment(DL1 has only one member, which is DL2). The exported report is showing the correct result. Can you check again? If the issue persists, let us know.