I have a PowerShell remoting script that the test-path is always false from variable.
$pathname = "C:\temp"
$hostremote = "computer122" #example
example - does not work:
Invoke-Command -ComputerName $hostremote {Test-Path -Path '$pathname' }
example - works fine:
Invoke-Command -ComputerName $hostremote {Test-Path -Path 'C:\temp' }
I tried using " and that causes an error so as leaving the ' or " out. Got to be a simple powershell trick I am missing for such a simple thing.