Skip to content

Instantly share code, notes, and snippets.

@Zsoldier
Created July 12, 2021 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zsoldier/9eda954f0c972d17c124040d7759054a to your computer and use it in GitHub Desktop.
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.
$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