enumerating empty groups

  • Follow


Can anyone tell me how I can list all empty AD groups? I've tried several 
variations on:
get-adgroup -filter * -properties canonicalname,cn,members | where 
{$_.members -eq "{}"} | fl

with no success.

Thanks
-- 
Mark Salter
National Museum of Wales
0
Reply Utf 2/23/2010 10:37:01 AM

Salty wrote:
> Can anyone tell me how I can list all empty AD groups? I've tried several 
> variations on:
> get-adgroup -filter * -properties canonicalname,cn,members | where 
> {$_.members -eq "{}"} | fl
> 
> with no success.
> 
> Thanks

It should work with this:

Get-ADGroup -LdapFilter "(!(memberOf=*))" -Properties CanonicalName, CN, 
memberOf

But I can't actually get it to pay attention to that filter which is 
frustrating to say the least.

This should do it as a work-around:

Get-ADGroup -Filter * -Properties canonicalname, cn, members | ?{ 
$_.Members.Count -eq 0 } | FL

HTH

Chris
0
Reply Chris 2/23/2010 11:14:29 AM


Nice job. Thanks
-- 
Mark Salter


"Chris Dent" wrote:

> Salty wrote:
> > Can anyone tell me how I can list all empty AD groups? I've tried several 
> > variations on:
> > get-adgroup -filter * -properties canonicalname,cn,members | where 
> > {$_.members -eq "{}"} | fl
> > 
> > with no success.
> > 
> > Thanks
> 
> It should work with this:
> 
> Get-ADGroup -LdapFilter "(!(memberOf=*))" -Properties CanonicalName, CN, 
> memberOf
> 
> But I can't actually get it to pay attention to that filter which is 
> frustrating to say the least.
> 
> This should do it as a work-around:
> 
> Get-ADGroup -Filter * -Properties canonicalname, cn, members | ?{ 
> $_.Members.Count -eq 0 } | FL
> 
> HTH
> 
> Chris
> .
> 
0
Reply Utf 2/23/2010 12:41:01 PM

Hi Salty,

Use the -Empty parameter:

Get-QADGroup -SizeLimit 0 -Empty 


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



S> Can anyone tell me how I can list all empty AD groups? I've tried
S> several
S> variations on:
S> get-adgroup -filter * -properties canonicalname,cn,members | where
S> {$_.members -eq "{}"} | fl
S> with no success.
S> 
S> Thanks
S> 


0
Reply Shay 2/23/2010 1:15:22 PM

Shay Levy [MVP] wrote:
> Hi Salty,
> 
> Use the -Empty parameter:
> 
> Get-QADGroup -SizeLimit 0 -Empty
> 
> ---
> Shay Levy
> Windows PowerShell MVP
> http://blogs.microsoft.co.il/blogs/ScriptFanatic
> PowerShell Toolbar: http://tinyurl.com/PSToolbar
> 
> 
> 
> S> Can anyone tell me how I can list all empty AD groups? I've tried
> S> several
> S> variations on:
> S> get-adgroup -filter * -properties canonicalname,cn,members | where
> S> {$_.members -eq "{}"} | fl
> S> with no success.
> S> S> Thanks
> S>
> 

Get-ADGroup instead of Get-QADGroup, just to make things complicated :)

Chris
0
Reply Chris 2/23/2010 1:30:41 PM

4 Replies
796 Views

(page loaded in 0.138 seconds)

Similiar Articles:
















7/18/2012 9:18:46 AM


Reply: