get-adgroup filter name like

Hi, I’m trying to get the following to work using text from a textbox and It’s not liking the variable I’m using.

$1 = $textbox4.text
get-adgroup -Filter {name -like "*$1*"} -Properties * -SearchBase "ou=esd,dc=dom2,dc=sch,dc=com" | select name 

Any ideas. Thanks for any help in advance.

What’s wrong with it? Do you get errors? If yes - it would have been pretty helpful to post these errors as well.

Tony Rodal,

I’ve just faced a similar problem.
Try this:

$1 = $textbox4.text
get-adgroup -Filter "name -like '*$1*'" -Properties * -SearchBase "ou=esd,dc=dom2,dc=sch,dc=com" | select name

Found the answer on the last post of this topic on Technet:

All credits go to TenOf11 (TenOf11's Profile)

That worked great. Thanks for the help!! :slight_smile: