This issue has been documented at:
https://stackoverflow.com/questions/48837473/visual-studio-2017-unable-to-initialize-powershell-host
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Powershell host should be initialized so that NuGet Package Manager can be used -- without it -- Visual Studio is useless and we cannot continue our work (because we need the NuGet Package Manager) to function so we can update our projects) !!!
As shown above -- powershell host fails -- which in turn causes NuGet Package Manager to fail.
Have tried a complete uninstall and re-install of Visual Studio Community 2017 - NO EFFECT.
POWERSHELL ($PSVersionTable)
Name Value
---- -----
PSVersion 5.1.16299.248
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.248
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
GET-EXECUTIONPOLICY -LIST
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
VISUAL STUDIO INFO:
Microsoft Visual Studio Community 2017
Version 15.5.6
VisualStudio.15.Release/15.5.6+27130.2027
Microsoft .NET Framework
Version 4.7.02556
Installed Version: Community
Visual Basic 2017 00369-60000-00001-AA629
Microsoft Visual Basic 2017
Visual C# 2017 00369-60000-00001-AA629
Microsoft Visual C# 2017
Visual F# 4.1 00369-60000-00001-AA629
Microsoft Visual F# 4.1
Application Insights Tools for Visual Studio Package 8.10.01106.1
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2017 15.0.31127.0
ASP.NET and Web Tools 2017
ASP.NET Core Razor Language Services 1.0
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2017 5.2.51007.0
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 15.0.31106.0
Azure App Service Tools v3.0.0
Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.
Azure Data Lake Tools for Visual Studio 2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio
Azure Data Lake Tools for Visual Studio 2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events
JavaScript Language Service 2.0
JavaScript Language Service
Microsoft Azure HDInsight Azure Node 2.2.9000.1
HDInsight Node under Azure Node
Microsoft Azure Hive Query Language Service 2.2.9000.1
Language service for Hive query
Microsoft Azure Service Fabric Tools for Visual Studio 2.0
Microsoft Azure Service Fabric Tools for Visual Studio
Microsoft Azure Stream Analytics Language Service 2.2.9000.1
Language service for Azure Stream Analytics
Microsoft Azure Stream Analytics Node 1.0
Azure Stream Analytics Node under Azure Node
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.51120.3
Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
NuGet Package Manager 4.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
SQL Server Data Tools 15.1.61710.120
Microsoft SQL Server Data Tools
ToolWindowHostedEditor 1.0
Hosting json editor into a tool window
TypeScript Tools 15.5.11025.1
TypeScript Tools for Microsoft Visual Studio
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
WebJobs Tools v1.0.0 15.0.31106.0
WebJobs Tools v1.0.0
SYSTEM SUMMARY INFO:
OS Name Microsoft Windows 10 Pro
Version 10.0.16299 Build 16299
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name WKSTN2
System Manufacturer Gigabyte Technology Co., Ltd.
System Model To be filled by O.E.M.
System Type x64-based PC
System SKU To be filled by O.E.M.
Processor Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz, 3901 Mhz, 4 Core(s), 8 Logical Processor(s)
BIOS Version/Date American Megatrends Inc. F8, 21-Feb-12
SMBIOS Version 2.7
Embedded Controller Version 255.255
BIOS Mode Legacy
BaseBoard Manufacturer Gigabyte Technology Co., Ltd.
BaseBoard Model Not Available
BaseBoard Name Base Board
Platform Role Desktop
Secure Boot State Unsupported
PCR7 Configuration Binding Not Possible
Windows Directory C:\WINDOWS
System Directory C:\WINDOWS\system32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "10.0.16299.248"
User Name WKSTN2\Administrator
Time Zone Mountain Standard Time
Installed Physical Memory (RAM) 16.0 GB
Total Physical Memory 16.0 GB
Available Physical Memory 12.0 GB
Total Virtual Memory 32.0 GB
Available Virtual Memory 27.8 GB
Page File Space 16.0 GB
Page File C:\pagefile.sys
Virtualization-based security Not enabled
Device Encryption Support Reasons for failed automatic device encryption: TPM is not usable, PCR7 binding is not supported, Hardware Security Test Interface failed and device is not InstantGo, Un-allowed DMA capable bus/device(s) detected, Disabled by policy, WinRE is not configured, TPM is not usable
Hyper-V - VM Monitor Mode Extensions Yes
Hyper-V - Second Level Address Translation Extensions Yes
Hyper-V - Virtualization Enabled in Firmware Yes
Hyper-V - Data Execution Protection Yes
Based on the error message, it seems like VS is trying to load PowerShell V2 because V5.1 does not read the ps1xml files in $PSHOME.
I don't know why that would happen, the package manager console does load V5.1 on my machine, both with and without V2 enabled.
I suppose you could try disabling V2 and see if it helps.
Thanks for the reply -- 4 days now ... no solution ...
I have two identical (hardware) systems. On the first system (S1) Visual Studio 15.5.6 / NuGet Package Manager Console works; On the second system (S2) Visual Studio 15.5.6 Powershell host fails to initialize -- which renders NuGet Package Manager in Visual Studio useless. I copied all files from S1 in C:\Windows\System32\WindowsPowerShell\v1.0 and C:\Windows\SysWOW64\WindowsPowerShell\v1.0 to S2 -- to see if perhaps there was some difference - NO EFFECT. Some setting, somewhere is causing this problem! As I posted on StackOverflow -- even a clean install of Visual Studio is not helping.
Used the following commands to disable V2:
> Get-WindowsOptionalFeature -Online | Where {$_.FeatureName -like '*PowerShellv2*' }
FeatureName : MicrosoftWindowsPowerShellV2Root
State : Enabled
FeatureName : MicrosoftWindowsPowerShellV2
State : Enabled
> Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root
Path :
Online : True
RestartNeeded : False
> Get-WindowsOptionalFeature -Online | Where {$_.FeatureName -like '*PowerShellv2*' }
FeatureName : MicrosoftWindowsPowerShellV2Root
State : Disabled
FeatureName : MicrosoftWindowsPowerShellV2
State : Disabled
Rebooted - started Visual Studio - Try to start NuGet Package Manager Console -- system displays "Initializing Powershell host..." -- and just seems to hang at that point. If I re-enable powershell v2 -- the error messages as per my original post return -- the STRANGE thing is -- on the system that does work (S1) -- powershell v2 is ENABLED.
Any other ideas would be appreciated.
I can only suggest a couple other things, I have little experience in this area.
You might get a hint from fuslogvw - try it on both the good and bad machines, see what's different.
You might also look in the GAC for Policy.1.0.System.Management.Automation - this assembly is supposed to forward bindings from 1.0 to 3.0, if that was missing, then that might explain why V2 is used.
So I'm confuse! Is this a PSCore6 issue or a Windows PowerShell 5 issue.
In one of the error is showing Get-ExecutionPolicy as "AllSigned" which I think it most be brought to "RemoteSigned". But, nevertheless, this is not the correct place to handle this particular issue, so maybe try to go to a Nuget forum site to be properly handled.
:)
The root cause is unknown at this point -- hence I have posted on Powershell, Nuget, and Visual Studio/StackOverflow for all RFCs (Request For Comments). Tons of posts can be found about NuGet / Powershell failing in Visual Studio -- although no specific root cause has been identified.
lzybkr - I checked the GAC for the assembly: Policy.1.0.System.Management.Automation, the assembly was found on both machines.
I then listed all the assemblies in in the GAC with Powershell in the name, on the system that is NOT working, the following assemblies exist:
Microsoft.PowerShell.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Activities.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Cmdletization.OData, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Cmdletization.OData.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Diagnostics.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Core.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Diagnostics.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Editor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Editor.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GPowerShell, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GPowerShell.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GraphicalHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GraphicalHost.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ISECommon, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ISECommon.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Management.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ScheduledJob, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ScheduledJob.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Utility.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Utility.Activities.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Workflow.ServiceCore.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.Commands.Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
I then listed the assemblies on the system that DOES work, the following were found:
Microsoft.PowerShell.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Activities.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Cmdletization.OData, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Cmdletization.OData.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Diagnostics.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Diagnostics.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Core.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Diagnostics.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Editor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Editor.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GPowerShell, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GPowerShell.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GraphicalHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.GraphicalHost.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ISECommon, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ISECommon.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Management.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ScheduledJob, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ScheduledJob.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Utility.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Utility.Activities.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Workflow.ServiceCore.Resources, Version=3.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.Commands.Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Policy.1.0.Microsoft.PowerShell.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
The assemblies that are MISSING from the system that does not work are:
Microsoft.PowerShell.Commands.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Diagnostics.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Management.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Commands.Utility.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.ConsoleHost.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Microsoft.PowerShell.Security.Resources, Version=1.0.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Are any of the above critical to get the powershell host initialized in Visual Studio -- I do not know!?
The missing assemblies are all for V2. In V3 and later, the version is 3.0.0.0.
I think most or all of the missing assemblies would be loaded during initialization of V2.
I still believe the problem is the attempt to load V2, but based on your list of assemblies not including Policy.1.0.System.Management.Automation, I'm not sure how to explain the difference between the good and bad systems.
I suggest comparing the fuslogvw logs to see if you find anything interesting.
And to address the question from @MaximoTrinidad - this is definitely not a PSCore issue. This repo is for tracking PSCore issues, so I'll close this as Resolution External, but we can still continue the conversation here.
Thanks Jason,
I seem to remember in my hunt for a solution a thread that indicated that Visual Studio only tries to use V2 – could this be why it is working on the second system (where v2 is still present) and does not on the other system that is missing the V2 assemblies?
Ps – tried to run fuslogvw – but there is little instruction / direction for doing so – and I was unable to get any type of log file produced – If you have any step-by-step instructions for running fuslogvw that would be most helpful.
Log from fuslogvw –
* Assembly Binder Log Entry (19-Feb-18 @ 8:11:01 PM) *
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319clr.dll
Running under executable D:apps\VStudioNet2017\Common7\IDEdevenv.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: Where-ref bind. Location = D:/apps/VStudioNet2017/Common7/IDE/en-US/Microsoft.VisualStudio.Shell.UI.Internal.resources.EXE
LOG: Appbase = file:///D:/apps/VStudioNet2017/Common7/IDE/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio15.0_e42d1106devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319config\machine.config.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/en-US/Microsoft.VisualStudio.Shell.UI.Internal.resources.EXE.
LOG: All probing URLs attempted and failed.
* Assembly Binder Log Entry (19-Feb-18 @ 8:11:01 PM) *
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319clr.dll
Running under executable D:apps\VStudioNet2017\Common7\IDEdevenv.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: Where-ref bind. Location = D:/apps/VStudioNet2017/Common7/IDE/en-US/Microsoft.VisualStudio.Shell.UI.Internal.resources.EXE
LOG: Appbase = file:///D:/apps/VStudioNet2017/Common7/IDE/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio15.0_e42d1106devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319config\machine.config.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/en-US/Microsoft.VisualStudio.Shell.UI.Internal.resources.EXE.
LOG: All probing URLs attempted and failed.
That log doesn't seem useful. It's been years since I've used fuslogvw, I know it wasn't always easy or friendly, but sometimes it would give a clue to the problem.
When I opened package manager, $PSVersionTable reported 5.1 - so I would be surprised if V2 the normal and expected version.
Agreed -- the log did have the line:
Bind result: hr = 0x80070002. The system cannot find the file specified.
But (of course) does not report the file path that could not be found; making the error message completely useless !
I get the same result on the system that IS working, that is: $PSVersionTable reported 5.1
The system that is (still) NOT working -- simply seems to hang with the message "Initializing Powershell host..."
The system cannot find the file specified
Try procmon utility.
Ran procmon utility.
Started Visual Studio
TOOLS -> NuGet Package Manager -> Package Manager Console.
770 "NOT FOUND" events found for process "devenv.exe"; process monitor log attached.
Logfile.zip
770 guesses as to which event is causing the Package Manager Console to hang!
Just tried to install a NuGet Package in a new project...
OUTPUT WINDOW:
Severity Code Description Project File Line Suppression State
Error Could not load file or assembly 'System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
ERROR LIST WINDOW:
=== Pre-bind state information ===
LOG: DisplayName = System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/apps/VStudioNet2017/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : NuGet.Console, Version=4.5.0.4685, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\15.0_e42d1106\devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PublicAssemblies/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PublicAssemblies/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/Debugger/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/Debugger/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PublicAssemblies/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PublicAssemblies/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/Debugger/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/Debugger/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/apps/VStudioNet2017/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Management.Automation/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/APPS/VSTUDIONET2017/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/NUGET/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/APPS/VSTUDIONET2017/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/NUGET/System.Management.Automation/System.Management.Automation.DLL.
LOG: Attempting download of new URL file:///D:/APPS/VSTUDIONET2017/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/NUGET/System.Management.Automation.EXE.
LOG: Attempting download of new URL file:///D:/APPS/VSTUDIONET2017/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/NUGET/System.Management.Automation/System.Management.Automation.EXE.
Time Elapsed: 00:00:05.3641938
========== Finished ==========
The following finally solved the problem:
Most helpful comment
The following finally solved the problem:
https://developercommunity.visualstudio.com/content/problem/199976/visual-studio-failed-to-initialize-the-powershell.html