Using Windows Forms code in PowerISE causes the ISE to crash

Copper Contributor

I was testing a colleague's small script which lists VM snapshots from our vCenters, and it uses a Windows Form to get the vCenter name, username & password. It then logs into the vCenter and extracts the required info.

In a PowerShell command line, it works perfectly. In the ISE, the code runs fine until it completes then after about 10 seconds, the ISE freezes. I tried the same code on other Windows servers in our environment and the same happened.


To test if it was code related or not, I have a script which Get-Credential to ask the user for logon details so I modified the code to create a form with the username & password details using labels & textboxes with an OK button. As soon as I ran the code, it froze the ISE. Again if run from the PowerShell command line, works fine.


I tried adding the following to the scripts which did not help:


Add-Type -AssemblyName  Microsoft.VisualBasic,




I'm using $Form.Dispose()



Linked references:


Does anyone know of any fixes for this situation?

2 Replies
When using VSCode, do you still have the problem or not? (Stopped using ISE years ago)

Any update ?