In the below example, only the Get-Process in my scriptblock is being executed. "deh" does not print for some reason
Invoke-Command -ComputerName mycomputer -Credential $mycreds -ScriptBlock {
    Get-Process
    Write-Host "deh"
}
If I remove -ComputerName and execute on local, then it runs both commands just fine. 
EDIT:
Here I am trying to execute IIS cmdlets against remote server. The following command works
Invoke-Command -ComputerName mycomputer -ScriptBlock { 
    Trace-Command CommandDiscovery {
        Import-Module webAdministration
        Start-WebAppPool -Name DefaultAppPool
    } -PSHost 
}
but this does not work
Invoke-Command -ComputerName mycomputer -ScriptBlock { 
    Import-Module webAdministration
    Start-WebAppPool -Name DefaultAppPool
}
what is special about Trace-Command that it is helping Start-WebAppPool to work? this is really odd and I can't explain why this functionality.. 
No, the Invoke-Command cmdlet takes a scriptblock  where you can put multiple commands. You should also be able to see the Write-Host output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With