Problème with variable



I try to use variable in -filter with * but i don’t find the good syntax maybe someone can help me ?

try this powershell :

display a users who have variable in his name

get-asuser -filter {name -like $group} not work NEED THIS

get-asuser -filter {name -like $group}work but without *

get-aduser -filter {name -like “sale”} work but i need replace sale by a variable …




i have find a replace “solution” :slight_smile:

put my variable in a new one with * after and before and it work … if someone have the “true” and proper syntax respond this post with

$test = “$group

get-asuser -filter {name -like $test} (result, get-aduser -filter -like sale, if group=sale)

Despite all the cmdlets’ help documentation on -Filter, braces aren’t the best syntax. Very restrictive in what you can / can’t do.

Get-ADUser -Filter "name -like '*$test*'"