I use the following to find a computer in AD and works fine.
Get-ADComputer -Filter "name -eq 'pcname'"
But I need to use $pc = "pcname" first before searching it like below but it does not work. How to do that ? thanks.
$pc = "pcname"
Get-ADComputer -Filter "name -eq $pc"