I have a very simple function I've created that creates Tags (if they don't exist), then assigns them to a VM. I created and tested this code in a normal .ps1 file first before porting it over to the Form Project. As stated in the subject, this code works perfectly fine in a .ps1, but if I try to add the exact same code to my Form Project, or even a bare-minimum .psf (with a single button to 'GO'), the script execution hangs/freezes forever when trying to execute the New-TagAssignment statement.
PLEASE NOTE: to test the code, change the Connect-VIServer and $VMname lines to be applicable to your environment.
I'm attaching 2 files to demonstrate what I'm talking about. The code to do the Tag query and assignment are the same between the two files. The only difference is one file is a regular .ps1 whereas the other file contains a GUI (.psf).
- Doesn't_Work.psf - This is a very stripped down version of the GUI from my actual project. This file only contains the form and a single "GO" button to execute the code. Even in this very basic version, the script hangs/freezes forever when trying to execute the New-TagAssignment cmdlet.
- Working.ps1 - This is strictly the code without a GUI. This works perfectly...
After doing a tremendous amount of troubleshooting on my own, contacting Sapien support (the IDE I use for GUI powershell projects - Powershell Studio 2017 5.4.145.0), and massive Googling, I've come to the conclusion that there must be a bug in the cmdlet that is causing the hang/freeze. There aren't any messages (error or otherwise) displayed; just straight up hangs/freezes forever.
I've seen many people with similar issues like I have (all concerning the "Tag" cmdlets), but I haven't seen any real/working resolution.
Here is the requested version info:
Name | Value |
PSVersion | 5.1.16299.98 |
PSEdition | Desktop |
PSCompatibleVersions | {1.0, 2.0, 3.0, 4.0...} |
BuildVersion | 10.0.16299.98 |
CLRVersion | 4.0.30319.42000 |
WSManStackVersion | 3.0 |
PSRemotingProtocolVersion | 2.3 |
SerializationVersion | 1.1.0.1 |
ModuleType | Version | Name |
---|---|---|
Binary | 6.5.4.6983166 | VMware.VimAutomation.Cis.Core |
Manifest | 6.5.4.6979861 | VMware.VimAutomation.Common |
Binary | 6.5.2.6234650 | VMware.VimAutomation.Core |
Manifest | 1.0.0.5334677 | VMware.VimAutomation.Sdk |
vCenter Server | Version | Build |
---|---|---|
**********.prime.cisco.com | 6.5.0 | 5973321 |