VMware Networking Community
Vijay2027
Expert
Expert
Jump to solution

Security Tags in NSX

I was able to retrieve the VM's with security tags assigned.

PS C:\> Get-VM | Get-NsxSecurityTagAssignment | select-object @{Name="SecurityTag"; expression = {$_.securitytag.name}}, VirtualMachine

SecurityTag                                         VirtualMachine

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

VULNERABILITY_MGMT.VulnerabilityFound.threat=medium AD01

VULNERABILITY_MGMT.VulnerabilityFound.threat=medium AD-01

However I am looking for a way to retrieve VM's without any Security tags assigned through PowerCLI.

Any help is greatly appreciated. Thank you in advance. LucD

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | where {-not (Get-NsxSecurityTagAssignment -VirtualMachine $_)}


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

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

I don't have a NSX environment to test.
To allow me to determine what to filter on, can you check what this returns?

Get-VM | Get-TagAssignment


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

0 Kudos
Vijay2027
Expert
Expert
Jump to solution

Thank you for your quick response.

I am trying to security tags from powercli like:

PS C:\> Get-VM |  Get-NsxSecurityTagAssignment

SecurityTag VirtualMachine

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

securityTag AD01

securityTag AD-01

So I am trying to figure out if there is a way to get VM's without any "Security Tags" assigned.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I understand that, but I would like to know which TagCategory these NSX SecurityTags belong to.

Hence my previous request to run that line in your environment, and show me the result.


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

0 Kudos
Vijay2027
Expert
Expert
Jump to solution

Here is the output:

PS C:\> Get-VM | Get-TagAssignment

PS C:\>

PS C:\> Get-VM | Get-NsxSecurityTagAssignment

SecurityTag VirtualMachine

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

securityTag AD01

securityTag AD-01

PS C:\>

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | where {-not (Get-NsxSecurityTagAssignment -VirtualMachine $_)}


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

0 Kudos
Vijay2027
Expert
Expert
Jump to solution

Worked like a charm. thank you so much LucD

0 Kudos