Very quick note to myself (if i will ever need to use system center orchestrator) and internet ;). I was helping out today one person on #PowerCLI. His scripts that were being fired up in system center orchestrator did not quit properly. We first wrote quite a long workaround 😉 but after an hour i asked that person to disconnect in different way.
Instead of :
disconnect-viserver -Confirm:$false
i recommended to use:
disconnect-viserver -Confirm:0
And it helped, his scripts no longer exit with errors, and all script sessions are closed after script is finished.