I'm trying to use Get-ADComputer
in Powershell to search using variables when I know part of the computer name.
If I only use a string with quotes, it works great:
Get-ADComputer -Filter {Name -Like "*mputername*"} | Select Name
If I create a string variable and THEN do the same search using the variable, it doesn't return anything. I think it has something to do with how the variable is being expanded next to the wildcard asterisks, but I'm stumped.
Set-Variable -Name 'partialName' -Value 'mputername'
Get-ADComputer -Filter {Name -Like "*$partialName*"} | Select Name
Can anyone help me?