Author Posts

January 19, 2017 at 2:00 pm

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.

January 19, 2017 at 2:30 pm

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

January 19, 2017 at 3:03 pm

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 (

January 19, 2017 at 4:20 pm

That worked great. Thanks for the help!! 🙂