# Initialize array
$totalObj = @()
# Retrieve all DGs
$temp = Get-DistributionGroup -ResultSize Unlimited | select-Object name, managedby, @{n="Notes";e={(Get-Group $_).Notes}} |
# Loop through all distribution groups
ForEach-Object {
# Create instance of object of type .NET
$obj = New-Object System.Object
# Add the name of the DG to the object
#if ($i -eq 0) {
$obj | Add-Member -MemberType NoteProperty -Value $_.name -Name 'Distribution Group' -Force
#}
# Add list owner of the DG to the object
$obj | Add-Member -MemberType NoteProperty -Value $_.managedby -Name 'DG Manager' -Force
# Add notes of the DG to the object
$obj | Add-Member -MemberType NoteProperty -Value $_.Notes -Name 'Description' -Force
# Add the object to the array
$totalObj += $obj
}
# Pipe output to .csv file
$totalObj | Export-Csv c:\exchangescripts\ListMembers3-2012man.csv
No words wasted! Getting to the point about the work I do, the problems I deal with, and some links to posts about where I work.
Translate
Tuesday, March 27, 2012
PowerShell - Get Exchange Distribution Group Information
Today I was asked to create a list of our Exchange distribution groups showing the name of the group, list owner, and the notes field. Here is the script I used. The Get-Group PowerShell command is used to get the notes field. Output is sent to a csv file.
Subscribe to:
Post Comments (Atom)
Thank you so much.....worked perfectly!
ReplyDeleteI was also asked the same and I was happy happy to find your script, but I am still not able to get the Note's field to export. Any other suggestions? Thanks! Eydie
ReplyDelete