PowerShell host cannot be instantiated...

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.
Locked
User avatar
dave_wills77
Posts: 44
Joined: Wed Nov 15, 2006 10:52 pm

PowerShell host cannot be instantiated...

Post by dave_wills77 »

I'm using PrimalScript 4.1 Professional, version 4.1.529I'm playing about in an "Untitled.ps1" script, and get this error:"PowerShell host cannot be instantiated, please check your installation"with this line of code:"$voice=new-object -com "SAPI.spvoice"", when I right-click on "SAPI.spvoice" and choose "Help" from the pop-up.I've installed, and can access the RTM version of Powershell, and I'm not sure if the error is telling my installation of PrimalScript is messed up, or my installation of Powershell is messed up, or I just need to configure something.Let me know if you need more info...Thanks!!!Dave

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

PowerShell host cannot be instantiated...

Post by jhicks »

Put these two lines in a ps1 file in Primal Script. Save the file. Press f7 to run.$Var=Get-WmiObject "win32_operatingsystem"$Var.captionDoes PowerShell run or do you get the same error? If you right click on the cmdlet name in a PowerShell script, you should get help. What OS are you running?

User avatar
dave_wills77
Posts: 44
Joined: Wed Nov 15, 2006 10:52 pm

PowerShell host cannot be instantiated...

Post by dave_wills77 »

Thank you for replying!I have XP SP2 with all available current patches installed.I did as you suggested. A Powershell window opened with this:"Microsoft Windows XP ProfessionalPS C:Documents and Settingsms862bMy DocumentsScripts>".When I right-click "Get-WmiObject", and choose "Help" I get the same error described before:"PowerShell host cannot be instantiated, please check your installation"When I check Computer Management Event Viewer, I have both "PowerShell" and "Windows Powershell" listed. "Windows Powershell" has no entries, however "Powershell" has many, most of which look something like this:"The description for Event ID ( 400 ) in Source ( PowerShell ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Available, None, NewEngineState=AvailablePreviousEngineState=NoneSequenceNumber=8HostName=ConsoleHostHostVersion=1.0.0.0" "I also found an earlier entry in the "Powershell" event log:"The description for Event ID ( 103 ) in Source ( PowerShell ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: There were errors in loading the format data file: Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0FileSystem.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0FileSystem.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0Help.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0Help.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0PowerShellCore.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0PowerShellCore.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0PowerShellTrace.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0PowerShellTrace.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0Registry.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0Registry.format.ps1xml cannot be loaded. You have elected to not run this software now."., ExceptionClass=RuntimeException ErrorCategory=NotSpecified ErrorId=ErrorsUpdatingFormats ErrorMessage=There were errors in loading the format data file: Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0FileSystem.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0FileSystem.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0Help.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0Help.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0PowerShellCore.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0PowerShellCore.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0PowerShellTrace.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0PowerShellTrace.format.ps1xml cannot be loaded. You have elected to not run this software now.".Microsoft.PowerShell.Core, C:Program FilesWindows PowerShellv1.0Registry.format.ps1xml : File skipped because of validation exception: "The file C:Program FilesWindows PowerShellv1.0Registry.format.ps1xml cannot be loaded. You have elected to not run this software now.". Severity=Warning SequenceNumber=1 HostName=ConsoleHost HostVersion=1.0.9567.1 HostId=b62efb85-250b-457d-b6e8-7bec548339cd EngineVersion= RunspaceId= PipelineId= CommandName= CommandType= ScriptName= CommandPath= CommandLine=AdditionalInfo: Name=;Value= Name=;Value="I'm going to uninstall, reinstall, and see if that fixes it. By the way, I'm local administrator, domain admin member, too, so it shouldn't be a permissions issue.Thank you again for responding.David

User avatar
dave_wills77
Posts: 44
Joined: Wed Nov 15, 2006 10:52 pm

PowerShell host cannot be instantiated...

Post by dave_wills77 »

I unistalled PowerShell, rebooted, downloaded it fresh from Microsoft, installed again, and still get the same error with the right-click "Help". I can always go to other sources for Help, but it would be nice to be able to access it from within PrimalScript.

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

PowerShell host cannot be instantiated...

Post by jhicks »

PowerShell appears to be installed properly, but you already knew that. The issue is Primal Script "finding" PowerShell on your system. I ran into this with earlier release candidate and I'm trying to remember how we fixed it. You didn't do a custom install of PowerShell did you or change the default location? The log entries are pointing to an old location. You should find the .ps1xml files in %systemroot%system32windowspowershellv1.0

User avatar
dave_wills77
Posts: 44
Joined: Wed Nov 15, 2006 10:52 pm

PowerShell host cannot be instantiated...

Post by dave_wills77 »

I didn't do a custom installation, with the release candidate or for the RTM version.I'm not seeing any new log entries related to the old location, and the .ps1xml files are currently located in:"C:WINDOWSSYSTEM32windowspowershellv1.0"My next plan is to uninstall PrimalScript 4.1, then reinstall it to try to refresh PrimalScript's knowledge of the PowerShell installation. I'll let you know what happens next.Thanks again,David

User avatar
dave_wills77
Posts: 44
Joined: Wed Nov 15, 2006 10:52 pm

PowerShell host cannot be instantiated...

Post by dave_wills77 »

Ok, it's now resolved... I reinstalled PrimalScript, and ran two tests:First, I opened the test.ps1 file I created from jhicks suggestion above, which contained two lines:$Var=Get-WmiObject "win32_operatingsystem"$Var.captionI executed the script within PrimalScript, and got:"Microsoft Windows XP ProfessionalPS C:Documents and Settingsms862bMy DocumentsScripts>".While the PowerShell window was still opened, I right-clicked on "Get-WmiObject", and selected "Help". The help results showed correctly within the new "Help" tab at the bottom of the PrimalScript 4.1 Professional screen.I then closed the PowerShell window, closed PrimalScript, reopened PrimalScript, reloaded the test.ps1 file, right-clicked on "Get-WmiObject", and the Help displayed properly again.So, the reinstall of Powershell and reinstall of PrimalScript seems to have resolved the issue. Live and learn. :-) Happy Friday!

User avatar
Alexander Riedel
Posts: 7407
Joined: Tue May 29, 2007 4:43 pm

PowerShell host cannot be instantiated...

Post by Alexander Riedel »

Seems to me PowerShell was initially not installed correctly.
That prevents the assembly we use to communicate with Powershell from being
registered. Uninstallaing and reinstalling should help.

For sanities sake please check that you do have the .NET 2.0 framework installed.

Alex
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
dave_wills77
Posts: 44
Joined: Wed Nov 15, 2006 10:52 pm

PowerShell host cannot be instantiated...

Post by dave_wills77 »

Thank you, too, Alex! PrimalScript and PowerShell seem to be ok now.From Add/Remove Programs:Microsoft .NET Framework 2.0Security Update for Microsoft .NET Framework 2.0 (KB917283)Security Update for Microsoft .NET Framework 2.0 (KB922770)Here's to sanity! David

Locked