$server = "SOME_SERVER"
$target = "8.8.8.8"
Invoke-Command -ComputerName $server -ScriptBlock { Test-Connection -ComputerName $target }
So I have this code and it's throwing me an error
Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
Strange thing is that if I change $target
to 8.8.8.8
in last line, everything's fine.
Can someone explain this to me, please? I've been struggling with this for like an hour and searched internet looking for an answer but didn't find any solution. Is this some kind of a bug in PowerShell?
BTW - if I invoke $target
, it's giving me 8.8.8.8
and the type is String, so...