Page 1 of 3

Cannot instantiate Powershell V5 object

Posted: Mon Apr 24, 2017 4:52 am
by froaderick
Product, version and build:
Powershell Studio 2016 5.2.129 64bit
Operating system:
Windows 10 1607 build 14392.953 64bit
PowerShell Version:
5.1.14393.953

Recently resinstalled Powershell Studio 2016 and every script i try to execute produces this error:

"Cannot instantiate Powershell V5 object: 80070002>> Script Ended."

Before the reinstall, these scripts ran fine.

Running the same scripts from the PS Console or ISE is fine.

Any help with troubleshooting would be greatly appreciated. Thanks

Re: Cannot instantiate Powershell V5 object

Posted: Mon Apr 24, 2017 10:30 am
by DevinL
Generally, this happens when PowerShell Studio has failed to register the controls for PowerShell properly.

To verify, we can register them manually from a PowerShell console with the following:

Code: Select all

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe "C:\Program Files (x86)\Common Files\SAPIEN Debugger 2017\PWSHHelpCtrl2017V5.dll" /codebase

C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C\:Program Files (x86)\Common Files\SAPIEN Debugger 2017\PWSHHelpCtrl2017V5.dll" /codebase

Re: Cannot instantiate Powershell V5 object

Posted: Mon Apr 24, 2017 10:44 am
by froaderick
Thank you, i will try this and update the thread once i have a result.

Fred

Re: Cannot instantiate Powershell V5 object

Posted: Tue Apr 25, 2017 10:30 am
by froaderick
Ok, i ran both commands and they successfully registered, however i still get the same message. I've also tried to reboot. I guess I can try to reinstall the software.

Fred

Re: Cannot instantiate Powershell V5 object

Posted: Wed Apr 26, 2017 4:43 am
by froaderick
Reinstalled the software and also re-ran the commands to register the objects but i still get the same message.

"RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can cause your assembly to interfere with other
applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed
assemblies. Please give your assembly a strong name and re-register it.
Types registered successfully"

"Cannot instantiate PowerShell V5 object: 80070002>> Script Ended"

Re: Cannot instantiate Powershell V5 object

Posted: Wed Apr 26, 2017 6:29 am
by froaderick
a little more information:

I installed Powershell Studio 2016 on my production laptop (also Win10 1607 PS version 5.1) and it works fine.

Also, on my development machine where the issue is occuring, within PS Studio i can open the console and execute commands. So it seems to be only when executing scripts via the main window.

Re: Cannot instantiate Powershell V5 object

Posted: Wed Apr 26, 2017 9:32 am
by DevinL
In that case, it's almost certainly an issue with this installation of PowerShell Studio not registering the controls properly. The console itself is just an embedded PowerShell object so it's not the same as executing the script via the main panel.

Try going into your installation directory for PowerShell Studio (default is C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio 2016\) and launching RegisterControls.exe. This will list the versions of PowerShell on your system, select the V5 engines, press OK, and restart PowerShell Studio.

Re: Cannot instantiate Powershell V5 object

Posted: Wed Apr 26, 2017 10:17 am
by froaderick
Ok, i executed RegisterControls.exe as an admin and restarted PSS but i get the same message.

Re: Cannot instantiate Powershell V5 object

Posted: Wed Apr 26, 2017 11:02 am
by DevinL
The RegisterControls.exe and regasm command we've tried so far are the two most common fixes for this situation. Since neither seems to be helping, I'll look into a more robust solution.

I like to say that I'm about to recommend a third party software to help remedy this situation and that I suggest making a backup or creating system restore point before continuing so that in case something does go wrong, you have a stable build to fall back on.

That being said, something that I use on my test machines when things of this nature occur is Revo Uninstaller. It's a free third-party software that is wonderful when it comes to uninstalling and removing leftover references as some uninstallers aren't the greatest at this. Try installing this software and using it to remove PowerShell Studio as well as any remaining registry/file references. After doing so, install the latest version of PowerShell Studio 2016 available to you and see if this remedies your situation.

Re: Cannot instantiate Powershell V5 object

Posted: Wed Apr 26, 2017 11:05 am
by froaderick
thank you!

I will check that out and see what happens.