VMware Cloud Community
JBartholomew
Enthusiast
Enthusiast

PowerCLI hangs on New-Tagcategory & New-Tag in vSphere 6.5

We have recently begun to migrate our vSphere installation from 5.5 to 6.5. During this migration I noticed that the VM Tag assignments were not carried over to the new vCenter when the VMs got reattached to the new vCenter. This in of itself is not an issue as I have a script to take our VM Inventory CSV and import it back into vSphere as well as export the current VM inventory with tags to a CSV. The script checks the existing tag categories against the categories in the CSV and adds any new categories that are not in vCenter. It does the same with the tags under each Category and then will go through each VM and ensure that the VM has the correct tags assigned in each category.

This script works perfectly in vSphere 5.5, but when I attempt to run the script against the 6.5 vCenter PowerCLI hangs when it gets to New-TagCategory. The really strange thing is if I kill the script and close PowerCLI and go back in and run it again the script now tells me that the category that it hung up on exists, and then hangs up trying to create the next category.

I have confirmed within vCenter that after closing PowerCLI (and only after closing PowerCLI) the new tag category does show up in the GUI.

I have tried manually running New-tagcategory and New-tag in the 6.5 environment and get the same result, so I dont think its any thing in particular to the script itself. I have tried searching the forums and the web, and all of the results have been meaningless in my situation.

any assistance in trying to determine why it might be hanging in 6.5 would be appreciated.

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership

There are some known issues with Tags in 6.5 nd PowerCLI.

One thing to check, did you connect to the vCenter with the FDQN?

An alternative could be to use my rCisTag module which is based on the REST API calls.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JBartholomew
Enthusiast
Enthusiast

yes I have tried FQDN with the same result. The 6.5 vCenters are in a different domain than the system I am running the PowerCLI from so I thought that FQDN might be part of the issue, so I tried with and without domain and got the same results.

I will take a look at your rCisTag module to see if that can help.

Thanks

Reply
0 Kudos
JBartholomew
Enthusiast
Enthusiast

Well I have discovered that my reason behind this issue is an issue with using PowerGUI against the vSphere 6.5 Environment. I attempted to run the script in PowerShellPlus and it adds the categories and tags without issues, so it looks like I will be moving away from PowerGUI for scripting.

Reply
0 Kudos
LucD
Leadership
Leadership

Small tip, have a look at Visual Studio Code as well.
Open sourced, multi-platform and a great PowerShell extension.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JBartholomew
Enthusiast
Enthusiast

I have looked at Visual Studio Code in the past as well, and I could not easily locate a variable explorer which I use quite heavily when trying to write/debug my scripts.

Reply
0 Kudos
LucD
Leadership
Leadership

All there in the Debugger

debug-code.png


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JBartholomew
Enthusiast
Enthusiast

hmmm weird. I just tried it again, and I found the Variable section within the Debugger, but after running through the script the section still shows as blank.

Reply
0 Kudos
LucD
Leadership
Leadership

You have to select the debugger, place some breakpoints and then run from there (Start Debugging).
The Variables will be empty again, once the script completes

Have a look at

Debugging PowerShell script in Visual Studio Code – Part 1 – Hey, Scripting Guy! Blog

Debugging PowerShell script in Visual Studio Code – Part 2 – Hey, Scripting Guy! Blog


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos