In some situations we have to Export all the Distribution group and all the members of it to a CSV file. There is no command let available to retrieve the distribution group and distribution group members in bulk. Pipe line won’t work in this case.
DisplayName
Alias
RecipientType
Recipient OU
Primary SMTP address
Distribution Group
Distribution Group Primary SMTP address
Distribution Group Managers
Distribution Group OU
Satheshwaran Manoharan wrote a script which will make Exchange Administrators life Easy to export distribution group and its members. After checking this Script I thought it would be cool, to be able, that I have a Option to delete all Distribution Groups witch has no Members in.
That’s why I started first to modify his Script.
First I added for the CSV export two more options (WhenCreated and WhenChanged), this helps me, to get more Informations about all Distribution Groups.
After running the Script .\DistributionGroupMemberReport.ps1 you will get the Menue bellow:
Output of CSV file look like Below
You can add some more entries if required
You can download the Script on my Github Page here!
Please Note! The Initial Script was written by Satheshwaran Manoharan
How to use this Script for Office 365
Local desktop . PowerShell – Run as Administrator
Make Sure your Execution Policy is set to RemoteSigned or Unrestricted
Set-ExecutionPolicy RemoteSigned |
my Case its unrestricted.
To Get Execution Policy Status
Get-ExecutionPolicy |
$UserCredential = Get-Credential |
$Session
=
New-PSSession
-ConfigurationName
Microsoft.Exchange
-ConnectionUri
https://outlook.office365.com/powershell-liveid/
-Credential
$UserCredential
-Authentication
Basic
-AllowRedirection
Import-PSSession $Session |
Now Run the Script – It should work.
Photo by Dmitry Tsellobenok on Unsplash
Pingback: Remove old EAS Devices - MSB365