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