"powershell has stopped working" on PS exit after creating IIS User

Posted by Nick Jones on Server Fault See other posts from Server Fault or by Nick Jones
Published on 2014-04-07T21:08:16Z Indexed on 2014/05/30 15:33 UTC
Read the original article Hit count: 667

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.2.0.0.400.8
  Locale ID:    1033

The PS commands in question are:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Management")
[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.

© Server Fault or respective owner

Related posts about powershell

Related posts about windows-server-2012