title: How to run multiple commands via Invoke-Command on remote server
body: <p>In the below example, only the <code>Get-Process</code> in my scriptblock is being executed. "deh" does not print for some reason</p>
  
  <pre><code>Invoke-Command -ComputerName mycomputer -Credential $mycreds -ScriptBlock {
      Get-Process
      Write-Host "deh"
  }
  </code></pre>
  
  <p>If I remove <code>-ComputerName</code> and execute on local, then it runs both commands just fine. </p>
  
  <p><strong>EDIT</strong>: </p>
  
  <p>Here I am trying to execute IIS cmdlets against remote server. The following command works</p>
  
  <pre><code>Invoke-Command -ComputerName mycomputer -ScriptBlock { 
      Trace-Command CommandDiscovery {
          Import-Module webAdministration
          Start-WebAppPool -Name DefaultAppPool
      } -PSHost 
  }
  </code></pre>
  
  <p>but this does not work</p>
  
  <pre><code>Invoke-Command -ComputerName mycomputer -ScriptBlock { 
      Import-Module webAdministration
      Start-WebAppPool -Name DefaultAppPool
  }
  </code></pre>
  
  <p>what is special about <code>Trace-Command</code> that it is helping Start-WebAppPool to work? this is really odd and I can't explain why this functionality.. </p>