Invoke-Command Remote Variables PowerShell
Hello,
Invoke-Command is great to use one of the “fan out” parallel execution possibilities with PowerShell. Indeed, by default it can execute the same command on 32 servers, simultaneously, without knowing anything about threads or runspaces.
Invoke-Command Remote Variables PowerShell
One drawback of this great cmdlet is when you need to use a variable inside the script block that you want to execute remotely. If you don’t pass it as an argument, it will be empty and you can have a non expected behavior on the remote system.

ArgumentList
One of the solution is to pass the variable that you need on the remote system as an argument in Invoke-Command, and then use them as $args in the script block.

$Using
Another one is to use the $using scope in the script block:
$MyRemoteVariable = "Am I empty?"
Invoke-Command -ComputerName DC2-Core -ScriptBlock {$using:MyRemoteVariable}

And now you can use your local variables on a remote system.