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:
https://social.technet.microsoft.com/Forums/exchange/en-US/8998f61e-6954-4b47-84e7-94413e361666/powershell-and-getmailbox-filter?forum=exchangesvradminlegacy

All credits go to TenOf11 (https://social.technet.microsoft.com/profile/tenof11/?ws=usercard-mini)

January 19, 2017 at 4:20 pm

That worked great. Thanks for the help!! 🙂