Author Posts

January 1, 2012 at 12:00 am

by link12 at 2012-12-03 11:11:45

I'm trying to get a report built out for our Exchange distrubtion groups, both dynamic and regular. I have this so far for regular.

#$a = Get-DistributionGroup (remarked for now until I can get a small test working)

### This is only for standard Distribtuion Groups.

$a = get-content "c:\stuff\scripts\listtest.txt"
foreach ($i in $a) {
$c = Get-DistributionGroupMember $i
$i,$c.count
}

I would like this into a CSV file, but have not been successful. My shell out put for the above code is

name (from text file)
user count from within the group

I'm basically looking for a CSV with the following

Name of DL, Count of Users, Is this Dynamic or Standard

Just looking for some guidance on this one.

by RichardSiddaway at 2012-12-05 04:41:22

Try something like this

$data = @()
$dls = "AAAA", "BBB"

foreach ($dl in $dls) {

$data += New-Object -TypeName PSObject -Property @{
Name = $dl
Count = (Get-DistributionGroupMember -Identity $dl | Measure-Object).Count
}
}

$data | Export-Csv -Path mydllist.csv -NoTypeInformation

by link12 at 2012-12-05 05:30:56

Great, works good!! Thanks

by RichardSiddaway at 2012-12-05 09:41:40

You are very welcome