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
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
Post a Comment