VMware Networking Community
mike2493
Contributor
Contributor

NSX Security Tags

This code was posted elsewhere on VMTN, which is exactly what was required.

Get-VM | Get-NsxSecurityTagAssignment | select-object VirtualMachine, (@{Name="SecurityTag"; expression = {$_.securitytag.name}})

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.

Tags (2)
0 Kudos
1 Reply
bayupw
Leadership
Leadership

As an alternative, if you have vRNI you can search all vm: vmware vm then export to CSV

Under the selected properties, add Name, Tag, Security Tags so you will have VM Name, vSphere Tags & Custom Attributes, and Security Tags in one row

pastedImage_4.png

Here's the sample of an exported CSV

pastedImage_3.png

Bayu Wibowo | VCIX6-DCV/NV
Author of VMware NSX Cookbook http://bit.ly/NSXCookbook
https://github.com/bayupw/PowerNSX-Scripts
https://nz.linkedin.com/in/bayupw | twitter @bayupw
0 Kudos