Unhandled Powershell error on launch

0

I randomly started getting an unhandled exception when trying to launch powershell x64 this evening. It was working just fine before I put my computer to sleep a few hours ago.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.SEHException: External component has thrown an exception.
  at System.Runtime.CompilerServices.RuntimeHelpers.PrepareContractedDelegate(Delegate d)
  at System.AppDomain.add_UnhandledException(UnhandledExceptionEventHandler value)
  at System.Management.Automation.WindowsErrorReporting.RegisterWindowsErrorReporting(Boolean unattendedServer)
  at Microsoft.PowerShell.UnmanagedPSEntry.Start(String consoleFilePath, String[] args)
  --- End of inner exception stack trace ---
  at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
  at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Management.Automation.Utils' threw an exception. ---> System.Runtime.InteropServices.SEHException: External component has thrown an exception.
  at System.Management.Automation.Utils..cctor()
  --- End of inner exception stack trace ---
  at System.Management.Automation.Runspaces.EarlyStartup.<>c.<Init>b__0_0()
  at System.Threading.Tasks.Task.Execute()
  at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
  at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
  at System.Threading.ThreadPoolWorkQueue.Dispatch()

I performed an sfc /scannow which did not find any issues. The problems persists after multiple restarts. I tried creating a new windows user however the problems persists on the new user too.

Any idea what may be causing this or how I could go about running a repair?

Ross Jones

Posted 2017-05-22T21:13:22.130

Reputation: 101

Try installing the newest Windows Management Framework (5.1), or reinstalling just Powershell from the GitHub releases page.

– CConard96 – 2017-05-23T01:31:01.853

Thanks, there doesnt seem to be an installer for Windows Management Framework (5.1) for windows 10. I see the github version is open powershell. It installs and works however it doesn't fix the native powershell. I am thinking about uninstalling creators edition and reinstalling. – Ross Jones – 2017-05-23T05:26:31.513

Interestingly my Docker installation is also broken, however that could be because it relies on powershell in some way? – Ross Jones – 2017-05-23T05:28:15.170

Answers

0

I uninstalled windows update KB4016871 and everything started working again.

Ross Jones

Posted 2017-05-22T21:13:22.130

Reputation: 101