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.
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
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.
https://docs.microsoft.com/en-us/powershell/scripting/wmf/overview?view=powershell-6
If your computer already has Windows Management Framework installed, install this update:
http://www.catalog.update.microsoft.com/Search.aspx?q=3191564
Once installed, restart the server.
Please vote if you find this helpful.