Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Executing program on remote computer help

$
0
0

The script block you pass to Invoke-Command does not inherit any variables from your local scope. In this case, $RemoteDll is an uninitialized (null) value when the command runs on the remote computer. You need to pass the value as an argument, and write the script block to accept positional parameters (either by name, or in the automatic $args array). For example:

$RemoteDll = "c:\program files (x86)\test\location\application.dll"

invoke-command -computername 'test-pc01' -ScriptBlock { & 'regsvr32' $args[0] } -ArgumentList $RemoteDll

Viewing all articles
Browse latest Browse all 13067

Trending Articles