• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3875
  • Last Modified:

Power Shell to find empty Distribution groups

Hi

I need to find empty distribution groups in Exchange 2007.
I found the following Power shell syntax but it returns groups that contain 1 user.

Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember –identity $_.Name).Count –lt 1 }

I changed it to:
Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember –identity $_.Name).Count –lt 0 }

but it still returns groups with members.

Can anyone please help me by providing the correct syntax i need to report on 'empty' groups with NO members.

Also, when outputting the list, the full detail (name) of each entriy is cut off and instead '...' is shown at the end.
i assume there a limit on how many characters are shown in each column.
Please help me get the full the detail in each column.

Thanks
0
naifyboy123
Asked:
naifyboy123
  • 4
  • 3
  • 2
  • +1
1 Solution
 
PostmasterCommented:
This is a good link:
http://www.howexchangeworks.com/2009/10/task-find-empty-distribution-groups-in.html

Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember –identity $_.Name).Count –lt 1 }

0
 
naifyboy123Author Commented:
That syntax is exactly what i posted in my question
it doesn't work
0
 
PostmasterCommented:
It works for me - shows all empty lists

Try adding "|ft displayname" to the end - this will show a table with only the displayname.

You can add more fields, but may need to widen your command screen
0
Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

 
soostibiCommented:
Try this:
Get-DistributionGroup | ?{!(Get-DistributionGroupMember -Identity $_)}

Open in new window

0
 
Shabarinath RamadasanInfrastructure ArchitectCommented:
Try this.

Get-QADGroup -SizeLimit 0 -Empty $true -GroupType Distribution

You need to have Quest AD roles.

Good luck
Shaba
1
 
naifyboy123Author Commented:
none of the baove works and i dont have quest ad roles.
@Postmaster - i shows gourps with 1 member in them -
0
 
naifyboy123Author Commented:

let me type that again - fingers not working today :)

none of the above works and i don't have quest ad roles.
@Postmaster - i shows groups with 1 member in them -
0
 
PostmasterCommented:
Are you using cut/paste from the provided scripts?

If you replace the "LessThan 1" with -LT 2   do you get lists with up to 2 members?
0
 
Shabarinath RamadasanInfrastructure ArchitectCommented:
get-qadgroup -sizelimit 0| where-object {(get-qadgroup -identity $_.name).members.count -eq 0}

This code works very well for me. But reuqire Quest AD Roles. You could try installing it as its a freeware.

Good luck
Shaba
0
 
naifyboy123Author Commented:
I installed Quest Active roles and ran your syntax. worked like a charm.
thanks
all other suggestions did not work for me.
thanks everyone for your input along the way
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now