powershell to show address lists with less than 1 member?
I know there is powershell commands to show DLs with no members or less than,etc... Here is one I use often: Get-DistributionGroup | Where-Object { ([array](Get-DistributionGroupMember –identity $_.distinguishedname)).Count –lt 1 } What about a script to show address lists with less than 1 user? We have tons of custom address lists in our 2007 org and it would be nice to know when users are deleted, offices changes, etc... to know when we have an outdated address list. A regular report of address lists with 1 or less users would be perfect. I haven't been able to create one with the get-address list command.
August 2nd, 2010 11:24pm

Hiya, Possibly not the most efficient way, but this may suffice: $r=get-recipient -resultsize unlimited; foreach ($a in (Get-AddressList)) { if (($r | where { $_.AddressListMembership -contains $a.Identity }) -eq $null) { $a } } Steve -------- Blog: http://www.stevieg.org Twitter: http://twitter.com/stevegoodman
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2010 1:05am

Steve, I have very limited PS know how. Any way I can get this to output and send to email. This is what I've done and it's only sending 1 address list name in the email body, even though the script finds about 30 that are empty as it's running. thanks $r=get-recipient -resultsize unlimited; foreach ($a in (Get-AddressList)) { if (($r | where { $_.AddressListMembership -contains $a.Identity }) -eq $null) { $a } } Send-MailMessage -To "user@domain.com" -Body $a -Subject "Address Lists without Users" -SmtpServer "mailserver" -From "Empty_LISTS_Report@domain.com"
August 4th, 2010 7:28pm

Steve, I have very limited PS know how. Any way I can get this to output and send to email. This is what I've done and it's only sending 1 address list name in the email body, even though the script finds about 30 that are empty as it's running. thanks $r=get-recipient -resultsize unlimited; foreach ($a in (Get-AddressList)) { if (($r | where { $_.AddressListMembership -contains $a.Identity }) -eq $null) { $a } } Send-MailMessage -To "user@domain.com" -Body $a -Subject "Address Lists without Users" -SmtpServer "mailserver" -From "Empty_LISTS_Report@domain.com" Hiya, Try something like: $recipients=get-recipient -resultsize unlimited; [array]$emptyAddressLists=@{}; foreach ($addressList in (Get-AddressList)) { if (($recipients | where { $_.AddressListMembership -contains $addressList.Identity }) -eq $null) { $emptyAddressLists[$emptyAddressLists.Count-1]=$addressList; $emptyAddressLists=$emptyAddressLists+1; } } $emptyAddressLists | Select-Object Name,DisplayName,RecipientFilter | Export-Csv -Path .\Temp.csv -NoTypeInformation Send-MailMessage -To "user@domain.com" -Body "See attached file" -Subject "Address Lists without Users" -SmtpServer "mailserver" -From "Empty_LISTS_Report@domain.com" -Attachments .\Temp.csv SteveSteve Goodman Check out my Blog for more Exchange info or find me on Twitter
Free Windows Admin Tool Kit Click here and download it now
August 5th, 2010 10:25pm

Thanks Steve. I like the blog too. Keep up the good work!
August 6th, 2010 2:37am

Thanks for the kind comments! Glad I could help.Steve Goodman Check out my Blog for more Exchange info or find me on Twitter
Free Windows Admin Tool Kit Click here and download it now
August 7th, 2010 1:16am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics