Powershell ISE crashes on exit while using Microsoft.Web.Management.dll
Published Nov 16 2018 07:00 AM 568 Views
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.

Error details from Event Log:
- <Event xmlns=" http://schemas.microsoft.com/win/2004/08/events/event ">
- <System>
<Provider Name="Windows Error Reporting" />
<EventID Qualifiers="0">1001</EventID>
<TimeCreated SystemTime="2018-08-14T17:21:53.000000000Z" />
<Security />
- <EventData>
<Data>Not available</Data>

Repro steps:
-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


if (-Not ([Microsoft.Web.Management.Server.ManagementAuthorization]::GetAuthorizedUsers("Default Web Site", $true, 0, 10) | ? Name -eq YourDomain\YourUserName)) {
else {

-ISE crashes.
-Error logged in the Eventlog

The solution:
Replace the exit with
Version history
Last update:
‎Nov 16 2018 07:00 AM
Updated by: