How to Invoke-Command and pass path to command as parameter
I'm tearing my hair out trying to invoke-command but pass the path to the
exe as a parameter
eg: I want to take this command
powershell Invoke-Command -ComputerName server -ScriptBlock {
param($command ) C:\windows\system32\getmac.exe /$command } -ArgumentList
?
and translate it into a form like this
powershell Invoke-Command -ComputerName server -ScriptBlock { param($path,
$command ) $path\getmac.exe /$command } -ArgumentList
C:\windows\system32,?
I've tried all manner of quoting, ampersands and other contortions but
can't get it to work. The above attempt results in
Unexpected token '\getmac.exe' in expression or statement. At line:1 char:97
(I don't really want to invoke getmac, this is the SO distilled version)
No comments:
Post a Comment