title: Running a remote cmd command in PowerShell
body: <p>I uploaded some files to a remote host with PowerShell, by FTP. On this host runs <a href="https://en.wikipedia.org/wiki/Windows_Embedded_Compact_7" rel="nofollow noreferrer">Windows 7 Embedded</a>.</p>
  
  <p>It turns out there is EWF (Enhanced Write Filter). So after a restart the uploaded files were gone. For saving the changes it needs commit them in cmd (at the remote host) by: <code>ewfmgr d:-commit</code> How can I include this command in my PowerShell code?</p>
  
  <p>The code:</p>
  
  <pre><code>  Enable-PSRemoting -Force
          Set-Item wsman:\localhost\client\trustedhosts -Value * -Force
          Restart-Service WinRm
          Test-WSMan $line
          Invoke-Command -ComputerName $line -scriptblock {cmd.exe /c "ewfmgr d: -commit"} -credential $FTPCredential
  </code></pre>
  
  <p>When I run <code>Enable-PSRemoting -Force</code> manually on the remote computer, it works, but it is uncomfortable and take lots of time. Is there another way to do this once for many hosts simultaneously?</p>