Reputation: 139
I tried to find a way to join or use variable into a command.
I'm trying to create a command that accept parameters:
The command: aduser.ps1 John
aduser.ps1 script:
Param($User)
Get-AdUser -filter 'Name -like "*$user*"'
I had error and not sure what operator to use to join in the $user
variables, i tried + or & and not working for me.
Upvotes: 0
Views: 145
Reputation: 126752
Variables will not expand inside single quote strings, replace them with double quotes:
Get-AdUser -filter "Name -like '*$user*'"
Upvotes: 1