Highlighted
Enthusiast
Enthusiast

Get-VM -Tag not working in VMware vSphere 6.7

Hello all

In VMware vSphere 6.0 with PowerCLI version 11.2.0 we used Get-VM -Tag 'Test' to list

VM with tag with value Test. After upgrade to VMware vSphere 6.7 this stopped working.

Is there a solution for that?

Regards

Hideyori

Tags (2)
0 Kudos
33 Replies
Highlighted
Hot Shot
Hot Shot

I've found that on vmware sites:

The following example returns all tags named “MyTag”.

Get-Tag -Name MyTag

The following example returns all tags from the “MyCategory1” and “MyCategory2” categories, named “MyTag”.

Get-Tag -Category MyCategory1, MyCategory2 -Name MyTag

Did you try your Get-VM -Tag 'Test' like: Get-VM -Tag Test

?

0 Kudos
Highlighted
Enthusiast
Enthusiast

Hello

Yes, I tried "Get-VM -Tag Test" but I get error:

Value cannot be null

Regards

Hideyori

0 Kudos
Highlighted
Hot Shot
Hot Shot

I tested it on my LAB but with newer PowerCLI version and it works.

PS C:\Users\****\Documents\WindowsPowerShell> Get-PowerCLIVersion

WARNING: The cmdlet "Get-PowerCLIVersion" is deprecated. Please use the 'Get-Module' cmdlet instead.

PowerCLI Version

----------------

   VMware PowerCLI 11.3.0 build 13990089

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component PowerCLI Component 11.3 build 13964830

   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.3 build 13964826

Next:

Connect-VIServer <vCenter server name>

Get-VM -Tag Test

Could You check your CLI version and update to newest?

0 Kudos
Highlighted
Enthusiast
Enthusiast

Thanks, I had 11.2.0. Have now updated to version 11.5.0 but still same result when execute:

Get-VM -Tag Test

> Value cannot be null

Regards

Hideyori

0 Kudos
Highlighted
Hot Shot
Hot Shot

Hmmm,

What about other options?

What happens if you try do only Get-VM or Get-VM -Name <vm name> ?

0 Kudos
Highlighted
Enthusiast
Enthusiast

This works without an issue.

0 Kudos
Highlighted
VMware Employee
VMware Employee

Moderator note: Moved to PowerCLI


Forum Usage Guidelines: https://communities.vmware.com/docs/DOC-12286
VMware Training & Certification blog: http://vmwaretraining.blogspot.com
0 Kudos
Highlighted
User Moderator
User Moderator

That was a known error in older PowerCLI versions.

But shouldn't be there anymore.

Just tested , for me it works as expected

vmtag.png

Which PowerCLI modules do you have installed?
Can you show what the following returns?

Get-Module -Name VMware* -ListAvailable


Since this issue was also seen occasionally with some corrupt PowerCLI installations, you could try to uninstall PowerCLI (just remove the folders) and after a restart, install PowerCLI again.


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

0 Kudos
Highlighted
Enthusiast
Enthusiast

Hi Luc

I have tried with version 11.2.0 and then updated to 11.5.0 > same result. I have now uninstalled and

installed PowerCLI as you told > same problem (we are using newest version of vCenter Appliance 6.7.

build 41000 from 24october2019 ... maybe there is an issue again?):

-------------------------------------------------------------------

Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands

---------- -------    ----                                ----------------

Script     6.7.0.1... VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-D...

Script     6.7.0.1... VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-Esx...

Manifest   11.5.0.... VMware.PowerCLI

Script     6.7.0.1... VMware.Vim

Script     11.5.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}

Script     11.0.0.... VMware.VimAutomation.Cloud          {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, G...

Script     11.5.0.... VMware.VimAutomation.Common         {Get-Task, Stop-Task, Wait-Task}

Script     11.5.0.... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAd...

Script     11.5.0.... VMware.VimAutomation.Hcx            {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance...

Script     7.10.0.... VMware.VimAutomation.HorizonView    {Connect-HVServer, Disconnect-HVServer}

Script     11.3.0.... VMware.VimAutomation.License        Get-LicenseDataManager

Script     11.5.0.... VMware.VimAutomation.Nsxt           {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtPolicy...

Script     11.5.0.... VMware.VimAutomation.Sdk            Get-ErrorReport

Script     11.0.0.... VMware.VimAutomation.Security       {Get-SecurityInfo, Get-VTpm, Get-VTpmCertificate, Get-VTpm...

Script     11.5.0.... VMware.VimAutomation.Srm            {Connect-SrmServer, Disconnect-SrmServer}

Script     11.5.0.... VMware.VimAutomation.Storage        {Add-KeyManagementServer, Add-VsanObjectToRepairQueue, Cop...

Script     1.3.0.0    VMware.VimAutomation.StorageUtility Update-VmfsDatastore

Script     11.2.0.... VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, E...

Script     11.5.0.... VMware.VimAutomation.Vmc            {Add-VmcSddcHost, Connect-Vmc, Disconnect-Vmc, Get-AwsAcco...

Script     10.0.0.... VMware.VimAutomation.vROps          {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-O...

Script     6.5.1.7... VMware.VumAutomation                {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Complia...

-------------------------------------------------------------------

Regards

Hideyori

0 Kudos
Highlighted
Hot Shot
Hot Shot

Hi,

I've upgraded vCenter to version as you have and command works, so it is not a problem with vCenter version.

0 Kudos
Highlighted
User Moderator
User Moderator

No, the vCenter version should not make a difference.


Are you using an embedded or external PSC?
The known issue seems to have occurred more frequently with installations with an external PSC.

I would also suggest opening an SR for this.

If GSS tells you PowerCLI is not supported, point them to PowerCLI Support Breakdown


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

0 Kudos
Highlighted
Enthusiast
Enthusiast

We are using the embedded PSC. I have opened a SR yesterday evening with VMware about this.

Thanks for all the help in the meantime.

0 Kudos
Highlighted
User Moderator
User Moderator

No problem.
Can you check if the following work in your environment?

Get-TagAssignment

Get-TagAssignment -Entity <name-of-a-vm-with-a-tag>


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

0 Kudos
Highlighted
Enthusiast
Enthusiast

This also fails with: "vSphere single sign-on failed for connection during a previous operation"

0 Kudos
Highlighted
User Moderator
User Moderator

Can you try running the following before doing the Tag cmdlet?

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'


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

0 Kudos
Highlighted
Enthusiast
Enthusiast

When I do this, result is:

PS C:\Users\hideyori> [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'

PS C:\Users\hideyori> get-vm -tag Test

get-vm : 11.11.2019 11:08:14    Get-VM          Value cannot be null.

Parameter name: collection

At line:1 char:1

+ get-vm -tag Test

+ ~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

PS C:\Users\hideyori>

0 Kudos
Highlighted
User Moderator
User Moderator

Are you on the latest PowerCLI version 11.5.0?

There were a number of Tag related cmdlet improvements made in that version.


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

0 Kudos
Highlighted
Contributor
Contributor

We just upgraded to 6.7, I am using PowerCLI 11.5, and I am receiving the same error:

Get-Tag : 12/10/2019 2:05:10 PM    Get-Tag        Value cannot be null.

Parameter name: collection   

At line:1 char:1

+ Get-Tag -Category $CATEGORY

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-Tag], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.GetTag

0 Kudos
Highlighted
User Moderator
User Moderator

What are you getting on the Get-TagAssignment lines I mentioned earlier?


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

0 Kudos