On a Windows Server 2012 box, I'm using PS to create a new IIS User (for automated deployments using MSDeploy). The command itself appears to work fine -- the user is created -- but as soon as I exit my PowerShell session (typing exit or just closing the command window), a dialog is displayed stating "powershell has stopped working", with the following details:

Problem signature:
  Problem Event Name:   PowerShell
  NameOfExe:    powershell.exe
  FileVersionOfSystemManagementAutomation:  6.2.9200.16628
  InnermostExceptionType:   Runtime.InteropServices.InvalidComObject
  OutermostExceptionType:   Runtime.InteropServices.InvalidComObject
  DeepestPowerShellFrame:   unknown
  DeepestFrame: System.StubHelpers.StubHelpers.GetCOMIPFromRCW
  ThreadName:   unknown
  OS Version:   6.2.9200.
  Locale ID:    1033

The PS commands in question are:

[Microsoft.Web.Management.Server.ManagementAuthentication]::CreateUser("Foo", "Bar")

Why is this happening and how can I avoid it?

EDIT: I've also confirmed this be a problem with PowerShell 4.0, so I've added that tag. I've also submitted it on Connect.

UPDATE: It appears that Windows Server 2012 R2 does not have this same bug.

  • Try creating the COM object with the $Obj = New-Object -ComObject cmdlet, then try to dispose of it when you're done with it with $Obj.Dispose() (if it implements IDisposable) or $Obj.Close() or something. Use Get-Member to see what method the object actually has. My guess is Powershell and/or the .NET framework is trying to dispose of the object twice when you exit Powershell. – Ryan Ries Apr 7 '14 at 22:40
  • Thanks @RyanRies, but which COM object in this case are you thinking I should create/dispose this way? Literally the only code I'm running are the two lines above. – Nick Jones Apr 7 '14 at 23:15
  • FWIW, I've verified that neither the Microsoft.Web.Management nor the IIS User are considered COM objects by PowerShell -- attempting [System.Runtime.Interopservices.Marshal]::ReleaseComObject([variable]) (having assigned the return of the two lines above to variables) throws "The object's type must be __ComObject or derived from __ComObject." So I'm still mystified as to what the original COM object is. – Nick Jones Apr 9 '14 at 13:35
  • I found that even the standard script SetupSiteForPublish.ps1 from WebDeploy crashes for me on Windows Server 2012 R2. – Der_Meister Aug 22 '18 at 3:34

Old post, but I ran into this exact issue and needed help with it. Hopefully this answer helps someone else.

It was happening to me on Windows Server 2012 R2 running PowerShell 4. My solution isn't exactly a true fix, but it gets me what I needed. What I did was put this operation on a background "thread" so the main process wasn't blocked by the pop-up window indicating that PowerShell crashed. Note PowerShell was only crashing for me when I ran a script that did this through cmd or Microsoft Release Management. When calling the script directly in a PowerShell window it didn't crash. Even when it was crashing everything I wanted the script to do was being performed. It only crashed after the script finished.

Here is a bit of my code


$jobScript = {
    <# Clear the $Error variable so errors do not build up when debugging this script #>

    $userName = "SomeUser"

        Add-Type -Path "C:\windows\system32\inetsrv\Microsoft.Web.Management.dll"
        Add-Type -Path "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll"

        <# Set IIS Permissions on Default Web Site #>
            $errorMessage = "Error setting IIS Permissions on Default Web Site for $userName"
            [Microsoft.Web.Management.Server.ManagementAuthorization]::Grant("$userName", "Default Web Site", $false)
            Write-Output "IIS Permissions set on Default Web Site for $userName"
        Catch <# Tried catching the specific exception thrown, but was not working #>
            Write-Output "IIS Permissions already set on Default Web Site for $userName"
        $errorMessage = "The SomeUser user must be created prior to running this script"
        Write-Output $errorMessage
        Throw $errorMessage
    # Signal failure to Microsoft Release Management
    Write-Error "$errorMessage - $Error"

$job = Start-Job $jobScript
Wait-Job $job
Receive-Job $job

Solved - "Powershell has stopped working" error upon starting either powershell or powershell_ise. This error did not happen when starting these programs “Run As Administrator”. All 20 physical and virtual servers in this network experience this issue. It seems to be related to Windows Management Framework. All servers have Windows Management Framework V5.1 installed.

This resolved the error in all tested servers:

Install the Windows Management Framework if it is not already installed.


If your computer already has Windows Management Framework installed, install this update:


Once installed, restart the server.

Please vote if you find this helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.