naifyboy123
asked on
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-DistributionGroupMemb er –identity $_.Name).Count –lt 1 }
I changed it to:
Get-DistributionGroup | Where-Object { (Get-DistributionGroupMemb er –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
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-DistributionGroupMemb
I changed it to:
Get-DistributionGroup | Where-Object { (Get-DistributionGroupMemb
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
ASKER
That syntax is exactly what i posted in my question
it doesn't work
it doesn't work
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
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
Try this:
Get-DistributionGroup | ?{!(Get-DistributionGroupMember -Identity $_)}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
none of the baove works and i dont have quest ad roles.
@Postmaster - i shows gourps with 1 member in them -
@Postmaster - i shows gourps with 1 member in them -
ASKER
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 -
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?
If you replace the "LessThan 1" with -LT 2 do you get lists with up to 2 members?
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
This code works very well for me. But reuqire Quest AD Roles. You could try installing it as its a freeware.
Good luck
Shaba
ASKER
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
thanks
all other suggestions did not work for me.
thanks everyone for your input along the way
http://www.howexchangeworks.com/2009/10/task-find-empty-distribution-groups-in.html
Get-DistributionGroup | Where-Object { (Get-DistributionGroupMemb