This PowerShell script allows you to export the recipients of a dynamic distribution group in XLSX format.
This PowerShell script allows you to export the recipients of a dynamic distribution group in XLSX format using the ImportExcel
module.
- PowerShell 5.1 or higher
ImportExcel
module
If the ImportExcel
module is not already installed, you can install it by running the following command:
Install-Module -Name ImportExcel -Scope CurrentUser
Clone this repository or download the PowerShell script.
Open PowerShell and navigate to the directory containing the script.
Run the script, replacing "NameOfYourGroup" with the name of your dynamic distribution group.
$dynamicGroup = Get-DynamicDistributionGroup -Identity "NomDeVotreGroupe"
$recipients = Get-Recipient -RecipientPreviewFilter $dynamicGroup.RecipientFilter -OrganizationalUnit $dynamicGroup.RecipientContainer
$recipients | Export-Excel -Path "$PWD\fichier.xlsx" -WorksheetName "Destinataires"
Get-DynamicDistributionGroup -Identity "NomDeVotreGroupe"
: This command retrieves the specified dynamic distribution group.
Get-Recipient -RecipientPreviewFilter $dynamicGroup.RecipientFilter -OrganizationalUnit $dynamicGroup.RecipientContainer
: This command retrieves the recipients based on the group's recipient preview filter.
Export-Excel -Path "$PWD\fichier.xlsx" -WorksheetName "Destinataires"
: This command exports the recipients to an XLSX file named fichier.xlsx
in the current working directory.
Script written by David Bouhadana.
- Blog: M365 journey
This project is licensed under GNU GPL 3. You are free to use, modify, and distribute this code as long as the modifications and derived versions are also licensed under GNU GPL 3. For more information, please refer to the full license text GNU GPL 3.