Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Power Shell to find empty Distribution groups

Posted on 2011-05-03
10
Medium Priority
?
3,619 Views
Last Modified: 2012-05-11
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
Comment
Question by:naifyboy123
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 16

Expert Comment

by:Postmaster
ID: 35670814
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
 

Author Comment

by:naifyboy123
ID: 35674635
That syntax is exactly what i posted in my question
it doesn't work
0
 
LVL 16

Expert Comment

by:Postmaster
ID: 35677186
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
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
LVL 13

Expert Comment

by:soostibi
ID: 35688452
Try this:
Get-DistributionGroup | ?{!(Get-DistributionGroupMember -Identity $_)}

Open in new window

0
 
LVL 14

Accepted Solution

by:
Shabarinath Ramadasan earned 2000 total points
ID: 35693721
Try this.

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

You need to have Quest AD roles.

Good luck
Shaba
1
 

Author Comment

by:naifyboy123
ID: 35695500
none of the baove works and i dont have quest ad roles.
@Postmaster - i shows gourps with 1 member in them -
0
 

Author Comment

by:naifyboy123
ID: 35695501

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
 
LVL 16

Expert Comment

by:Postmaster
ID: 35695545
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
 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
ID: 35696780
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
 

Author Closing Comment

by:naifyboy123
ID: 35703350
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
how to add IIS SMTP to handle application/Scanner relays into office 365.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question