Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 178776

New-TagAssignment works in .ps1, but not in .psf...

$
0
0

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). 

  1. 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.
  2. 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

 

ModuleTypeVersionName
Binary6.5.4.6983166VMware.VimAutomation.Cis.Core
Manifest6.5.4.6979861VMware.VimAutomation.Common
Binary6.5.2.6234650VMware.VimAutomation.Core
Manifest1.0.0.5334677VMware.VimAutomation.Sdk

 

vCenter ServerVersionBuild
**********.prime.cisco.com6.5.05973321

Viewing all articles
Browse latest Browse all 178776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>