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
Try like this
Get-VM | where {-not (Get-NsxSecurityTagAssignment -VirtualMachine $_)}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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.
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
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:\>
Try like this
Get-VM | where {-not (Get-NsxSecurityTagAssignment -VirtualMachine $_)}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked like a charm. thank you so much LucD