title: How to run a CMD Through Invoke-Command
body: <pre><code>$remoteinst = "\Windows\Temp\MyFolder"
  $remotecomp = ComputerName
  $remotesess = New-PSSession $remotecomp
  $remotedir = "C:" + $remoteinst + "\Install.cmd"
  Invoke-Command -Session $remotesess -ScriptBlock {$remotedir}
  </code></pre>
  
  <p>I'm trying to run the Install.cmd file on a remote computer. I realised I can't pass commands through Enter-PSSession but I'm struggling to solve this issue.</p>