The following script will ask for inputs from the user and display the distribution group membership report either on the console or redirect it to a CSV file based on the selected option. The full script can be found at the TechNet Script center at https://gallery.technet.microsoft.com/office/Export-all-distribution-707c27eb written by Satheshwaran Manoharan.
In this script, a Switch
statement is used to check two conditions. A few variables and an empty array called $Displayout
has been declared, which are used later in the script to store the output that is redirected to a CSV file based on the user's inputs. The New-Object cmdlet is used to create a new instance of the Windows PowerShell object and add the required custom properties using the Add-member cmdlet.
In the second section, the results have been added to the empty array that we have declared $Displayout
, which will be piped to the Export-CSV cmdlet to export the output to a CSV file.
Finally, if the script...