[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.
I tried alternative B … but without success. Whenever I run Get-ADObject the second time I get the “Object reference not set to an instance” exception.
I’am using Powergui V2.4.0.1659 and still have the problem.
Setting the debug option doesn’t work.
Rene,
Thanks for bringing this up. Looks like we do indeed have an issue.
Could you try to:
1. Go to Tools / Options / Debug Options,
2. Set the “Run all scripts in the same runspace” option (I know that this is the opposite of what the above post recommends ;)),
3. Restart PowerGUI Script Editor.
Has this fixed the issue?
Dmitry
Dmitry,
I have two working options:
1. -MTA switch
2. Set “Runs all scripts in the same runspace”.
The the option “Reset Powershell runspace each time debugging is started” still give the error:
“Get-QADUser : Object reference not set to an instance of an object.”
Thanks
Rene,
Yes, “Reset Powershell runspace each time debugging is started” does not work – looks like QAD cmdlets 1.4 do not re-initialize properly – so please stick with the other option for now.
Thanks for reporting the issue. We will be fixing it in future versions.
Dmitry
I fighted with that issue, did a trace using procmon etc… & found that it may be related to many stuff. Then I end up by deleting the user profile. (just take care to save the needed elements before).
Stupid issue Solved in my case.