PowerCLI - New-TAG hangs in a script

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
gertvangorp
Posts: 1
Last visit: Thu Dec 22, 2022 6:54 am

PowerCLI - New-TAG hangs in a script

Post by gertvangorp »

Hi,



I a creating a script that needs to do the following thing.

I us Sapien Powershell 2017 Editor for this because it has a form with info on it

check if a TAG exists (GET-TAG)

$TagInfo = Get-Tag -Name $paramClassName .

This works perfect. I get the info of the TAG if it exists and a $null if the TAG does not exist.

if the TAG does not exist, creat it.

$MyClassTAG = Get-TagCategory -name "Class" | New-Tag -name $paramClassName -Verbose -Debug -Confirm:$false

The TAG is created but the script does not continue, it stays in the NEW-TAG cmdlet...

with the VERBOSE option I get following output

VERBOSE: 07/01/2018 22:43:01 New-Tag Started executionVERBOSE: Create tag 'ECCS-Classroom-GERTGERT-1' in category 'Class'
VERBOSE: 07/01/2018 22:43:01 New-Tag Started execution
VERBOSE: Create tag 'MyTAG' in category 'Class'


The next command, writing a status update in a text filed is never executed. if I comment out the NEW-TAG command line, the status is written correctly

Working with lates vCenter 6.5 and ESXi, on a windows 10 machine with latest PowerCLI modules installed.

Sapien Powershell Studio 2017 latest version 64 bit
Windows Enterprise 10 6bit, updated on januari 2017

PowerCLI Version
----------------
VMware PowerCLI 6.5.1 build 5377412
---------------
Component Versions
---------------
VMware Cis Core PowerCLI Component 6.5 build 6983166
VMware VimAutomation Core PowerCLI Component 6.5 build 6234650



Can someone tell me what I am doing wrong?



Thanks



Gert
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: PowerCLI - New-TAG hangs in a script

Post by davidc »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]

Some cmdlets that depend on events internally may get hang up on a GUI because the pipeline / messaging held up by the form. You can try creating the tag using a Job instead and see if that works (Look at the Job Tracker control sets, such as Button - Start Job).

https://info.sapien.com/index.php/guis/ ... sive-forms
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerCLI - New-TAG hangs in a script

Post by jvierra »

If you use "Debug" the command can stop in the debugger. You should not use "Debug" in PSS or in a form for this issue.

Also be sure you are using STA model.

David's suggestion will help to decouple from PSS settings but be sure code works at a CLI prompt.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked