1

I have powercli module installed and cannot get powernsx to work no matter what I try, so I'm limited to direct API calls to NSX.

The goal is to report on all VMs that do not have a security tag applied.

I know i can see all VMs with Get-VM, and I can get all security tags calling https://10.x.x.x/api/2.0/services/securitytags/tag

That security tag call will only return the number of VMs it's applied to, and not the names. I need the names so I can compare to the output from Get-VM.

Does anyone know how to see the names of all the VMs that have security tags from NSX? The issue is sys admins spin up new servers and do not tag them. Need to see which ones are untagged.

1 Answer 1

1

See if this command helps you find what you are looking for, (reference)

Get-VM | Get-NsxSecuritytagassignment | select-object @{Name="SecurityTag"; expression = {$_.securitytag.name}}, VirtualMachine
Sign up to request clarification or add additional context in comments.

6 Comments

Isn't Get-NsxSecurityTagassignment from the powernsx module?
It is from powernsx module
I cannot get the basic connection to work with the powernsx module. I have a whole other post on that one requesting help. I can access via native API calls though.
well.. thats going to get tricky for you real fast if you cant use the modules that gives you flexibility and performance. If you dont have access to nsx module, I dont know how you expect to get the name of the VMs. Security Tag Assignment is specific to NSX Managers and doesnt exist outside of that. vCenter itself doesnt know anything about it and unless you have a list of VM Names (somehow) that are part of that tag, there isnt any way to determine it.
I can hit NSX with API calls. I can also hit Vcenter with the powercli module. I can easily get all the VMs in Vcenter...but getting VMs without tags is my biggest problem. My thoughts are, run 2 commands (get-VM and whatever the NSX one that shows VMs without tags). Compare outputs, and show only the VM names that are different.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.