Powershell -like won't compare to variable -
in powershell, can this:
$useraccount = get-aduser -filter { name -like "*smith*"}
and find user(s), when this:
$namefilter = "smith" $useraccount = get-aduser -filter { name -like "*$namefilter*"}
nothing found. why?
-filter
looks accepts script block where-object, it's string. if use curly braces syntax, tends treat literal string, variables won't expand.
try:
$useraccount = get-aduser -filter "name -like '*$namefilter*'"
Comments
Post a Comment