How do I find a value that is blank (or null)? Or that is NOT blank?

Concrete example (but this does not work):

Get-DistributionGroup | where { $_.ManagedBy -eq $null }

No red error message but not results (no output) either.

I thought this might work:

[PS] C:\>Get-DistributionGroup | where { !$ManagedBy }

This produced output but incorrect output. Groups were listed that definitely had a manager assigned.

In fact, I am looking for values that are NOT blank but that is not working either.

Anyone have an idea?

T

September 4th, 2015 1:39pm

This worked for me:

 get-distributiongroup | Where {$_.managedby -like '*'}

Free Windows Admin Tool Kit Click here and download it now
September 4th, 2015 1:46pm

How about

?{-not ([string]::IsNullOrEmpty($_.ManagedBy))}

September 4th, 2015 2:26pm

Get-DistributionGroup -filter {-not(managedBy -like "*")} 

Free Windows Admin Tool Kit Click here and download it now
September 4th, 2015 2:38pm

Yes, that seems to do the trick. Thanks again.
September 4th, 2015 2:40pm

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

Other recent topics Other recent topics