Invoke Command and passing Variable


hi all,

i trying pass variable using the invoke-command. think issue has me trying pass local variable remote machine , cannot figure out how remote machine see variable. issue line 5 (get-item $filename) appreciated.

$cred = get-credential
$strcomputer = "computer123"
$s = new-pssession -computer $strcomputer
$filename = c:\windows\system32\adis.dll
invoke-command -session $s -script {(get-item $filename).versioninfo.fileversion} -credential $cred

thanks
gaz

#require v3
edit line
get-item $using:filename

or

$file = 'c:\windows\system32\adis.dll' $dc = new-pssession -computername home invoke-command -session $dc -scriptblock {(get-item $args).versioninfo.fileversion} -argumentlist $file

https://blogs.msdn.microsoft.com/powershell/2009/12/29/how-to-pass-arguments-for-remote-commands/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

difference between wuauclt1.exe and wuauclt.exe

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL