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

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2