Cannot instantiate Powershell V5 object

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
froaderick
Posts: 37
Last visit: Tue Oct 31, 2023 9:59 am

Cannot instantiate Powershell V5 object

Post 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
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Cannot instantiate Powershell V5 object

Post 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:
  1. C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe "C:\Program Files (x86)\Common Files\SAPIEN Debugger 2017\PWSHHelpCtrl2017V5.dll" /codebase
  2.  
  3. C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C\:Program Files (x86)\Common Files\SAPIEN Debugger 2017\PWSHHelpCtrl2017V5.dll" /codebase
DevinL
SAPIEN Technologies, Inc.
User avatar
froaderick
Posts: 37
Last visit: Tue Oct 31, 2023 9:59 am

Re: Cannot instantiate Powershell V5 object

Post by froaderick »

Thank you, i will try this and update the thread once i have a result.

Fred
User avatar
froaderick
Posts: 37
Last visit: Tue Oct 31, 2023 9:59 am

Re: Cannot instantiate Powershell V5 object

Post 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
User avatar
froaderick
Posts: 37
Last visit: Tue Oct 31, 2023 9:59 am

Re: Cannot instantiate Powershell V5 object

Post 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"
User avatar
froaderick
Posts: 37
Last visit: Tue Oct 31, 2023 9:59 am

Re: Cannot instantiate Powershell V5 object

Post 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.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Cannot instantiate Powershell V5 object

Post 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.
DevinL
SAPIEN Technologies, Inc.
User avatar
froaderick
Posts: 37
Last visit: Tue Oct 31, 2023 9:59 am

Re: Cannot instantiate Powershell V5 object

Post by froaderick »

Ok, i executed RegisterControls.exe as an admin and restarted PSS but i get the same message.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Cannot instantiate Powershell V5 object

Post 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.
DevinL
SAPIEN Technologies, Inc.
User avatar
froaderick
Posts: 37
Last visit: Tue Oct 31, 2023 9:59 am

Re: Cannot instantiate Powershell V5 object

Post by froaderick »

thank you!

I will check that out and see what happens.
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.