[UPDATE] This issue got fixed in PowerGUI 2.2.
We have found that in some cases when you are using version 1.4.0 of QAD cmdlets inside PowerGUI Script Editor 2.1.1, and invoke a script with the cmdlets for the second time you may get the error: “Object reference not set to an instance of an object.”
This is obviously very unfortunate and we are working on fixing the issue. In the meantime there are a couple of workarounds you can use:
A. Run Script Editor in MTA mode (if you don’t know what STA/MTA mean – this means that you would likely not notice any difference – but as a side-effect it might affect some script editor add-ons or your scripts using WPF)
To do this, just modify the PowerGUI Script Editor shortcut:
and add the -MTA switch to the command line:
B. Alternatively, you can set PowerGUI Script Editor to reset PowerShell runspace each time you start debugging:
1. In PowerGUI Script Editor, on the Tools menu, click Options,
2. In Debug Options, select Reset PowerShell runspace each time debugging is started.
Again, we appologise for the inconvenience and are working on a perminent fix.