That $RegKey variable is not going to get expanded from a local variable before the script block is sent to the background job. Since the variable doesn't exist in that session it's going to resolve to null.

You can create a script block from local variables using [scriptblock]::create() and an expandable string:

Give us some more details...What have you put into the $Arguments variable used here?$Job = Start-Job -ScriptBlock $MyScript -ArgumentList $Arguments -Credential $CredentialHave you tried using the Get-Credential cmdlet to see if there is a problem with where you're creating the $Credential variable?$Credential = Get-CredentialAlso, you are creating the $Rep variable based on the local machine, but you're using it to determine if you should modify the remote machine's registry. Shouldn't you be checking for that path on the remote machine, too?