I'm coming across this issue frequently during development. I have a module I'm working on and often need to Import-Module Blah-Force to bring in the latest changes and test it (like in ISE). This module has a RequiredModules of PoshRSJob and functions which use Start-RSJob and others.
If I run steps manually one by one like so, it works:
Import-Module Blah -Force
...
Start-Command
... Start-RSJob
I realised this is because there is a small delay when you run them like that. If I run them all at once with a delay it works:
Import-Module Blah -Force
Start-Sleep -Seconds 1
Start-Command
... Start-RSJob
But if they execute immediately after each other with no delay I get the above error. Every time!
Import-Module Blah -Force
Start-Command
... Start-RSJob
Any ideas why this is happening?