Created
July 12, 2021 15:44
-
-
Save Zsoldier/9eda954f0c972d17c124040d7759054a to your computer and use it in GitHub Desktop.
Someone was looking for a way to find 'Tagless' NSX-T VMs. Seems like the NSX-T realized state endpoint was the way to go.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Credential = Get-Credential | |
$skipcertcheck = $true | |
$AuthMethod = “Basic” | |
$NSXMgr=”NSXTManagerIPorDNSName” | |
$policyapi = "/policy/api/v1" | |
$base_url = ("https://" + $NSXMgr + $policyapi) | |
$endpoint = "/infra/realized-state/virtual-machines" | |
$Data = Invoke-restmethod -Uri ($base_url + $EndPoint) -Method GET -Credential $Credential -SkipCertificateCheck:$skipcertcheck -Authentication:$AuthMethod | |
#VMs without tags | |
$data.results | where {$_.tags -eq $null} | |
#VMs with tags | |
$data.results | where {$_.tags -ne $null} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment