Author Posts

June 30, 2016 at 12:59 pm


Newbie question maybe...
I know that to find specific properties of an object I use this command:

Get-DistributionGroup support | fl *Object*

Is there a way to find any properties that have a specific value?
Like: I want to know every properties that have the value *support* in it...

June 30, 2016 at 2:15 pm

That'd be the Where-Object command.

Get-Something | Where { $_.Property -like '*value*' } | Format-Table

June 30, 2016 at 4:11 pm

Don Jones,

First, thanks for always replying.
Didn't worked for me...

The "$_.Property" I should change for the property that I want to check?
Tried that to get every properties with my name as a value:
Get-ADUser username | Where {$_.Property -like "*Vandr*"} | Format-Table
Nothing returned...
I expected to get returned: DistinguishedName, GivenName and Name

June 30, 2016 at 4:34 pm

This is really ugly and I'm sure there's a more efficient way of doing it, but this will technically achieve the output you're expecting:

$User = Get-ADUser username
$UserProps = $User | Get-Member -MemberType Properties | select -ExpandProperty Name
foreach ($Prop in $UserProps) {
    $Prop | ? {$User.$Prop -like 'Vandr*'}

June 30, 2016 at 4:45 pm

Wilson Acosta,

I don't know if there is a prettier way of doing this too...
Added something more to get the results that I want:

$User = Get-ADUser username
$UserProps = $User | Get-Member -MemberType Properties | select -ExpandProperty Name
$Properties = foreach ($Prop in $UserProps) {
    $Prop | Where {$User.$Prop -like "Vandr*"}
$Properties -join(",")
$User | select $Properties | Format-List

July 1, 2016 at 1:24 pm

Get-ADUser -Filter 'Name -like "*Vandr*"'

July 1, 2016 at 1:28 pm

random commandline,

That command only returns every user on AD that has "vandr" on it's name.