First published on MSDN on Sep 05, 2018
I was helping a customer other day on a stubborn crash whenever Powershell-ISE and Microsoft.Web.Management.dll are put together. While calling Microsoft.Web.Management.dll from Powershell-ISE or WMIprvse.exe, upon exit, it was throwing Runtime.InteropServices.InvalidComObject error while crashing the Powershell-ISE or WMIprvse.exe. Loading/calling the same DLL on the same machine from a C# console application did NOT exhibit this behavior.
-First verify that IIS Default Web Site is up and running without any issues (we will be referencing this site in the powershell script)
-Launch Powershell ISE in admin mode
-Run following commands one after another