adr1an5
Contributor
Contributor

Get NSX security tags assigned to a VM using powershell?

Jump to solution

Is it possible to get a list of NSX security tags assigned to a VM using powershell?

I already tried the following but it only returns a value "securityTag" and not the actual name of the security tag(s).

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

SecurityTag VirtualMachine                        

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

securityTag dhcp01

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
amolnjadhav
Enthusiast
Enthusiast

Hi,

i guess following command can solve your issue,

Get-VM *dhcp* | Get-NsxSecuritytagassignment | select-object @{Name="SecurityTag"; expression = {$_.securitytag.name}}, VirtualMachine

Please consider marking this answer "correct" or "helpful" if you think your query have been answered correctly. Regards Amol Jadhav VCP NSXT | VCP NSXV | VCIX6-NV | VCAP-DCA | CCNA | CCNP - BSCI

View solution in original post

0 Kudos
4 Replies
amolnjadhav
Enthusiast
Enthusiast

Hi,

i guess following command can solve your issue,

Get-VM *dhcp* | Get-NsxSecuritytagassignment | select-object @{Name="SecurityTag"; expression = {$_.securitytag.name}}, VirtualMachine

Please consider marking this answer "correct" or "helpful" if you think your query have been answered correctly. Regards Amol Jadhav VCP NSXT | VCP NSXV | VCIX6-NV | VCAP-DCA | CCNA | CCNP - BSCI

View solution in original post

0 Kudos
adr1an5
Contributor
Contributor

This is exactly what I was looking for, thanks!

0 Kudos
amolnjadhav
Enthusiast
Enthusiast

I am glad !! It is useful for you.

Please consider marking this answer "correct" or "helpful" if you think your query have been answered correctly. Regards Amol Jadhav VCP NSXT | VCP NSXV | VCIX6-NV | VCAP-DCA | CCNA | CCNP - BSCI
0 Kudos
mike2493
Contributor
Contributor

Just what I needed, many thanks.

Is there anyway of formatting the output, as the output of this command lists the VM multiple times.

If possible I'd like the VM name and then one column per security tag.

VM1, Tag1, Tag2, Tag3

rather than

VM1,Tag1

VM1,Tag2

VM1,Tag3

If possible I'd also like vcenter and NSX Security tags in the same report.

0 Kudos