0
我已經開始使用VMWare的標籤來幫助我使用powerCLI
作爲我的腳本工具進行報告和過濾。我有tags
與VMs
和Hosts
相關聯。使用PowerCLI獲取與ESXI主機相關的標籤
我可以檢索與VMs
用這樣的腳本相關的標籤:
Get-VM | Select Name,Guest,PowerState,VMHost,Tag,ResourcePool
因爲tag
包括作爲返回的屬性。
我無法弄清楚如何從主機或數據存儲中返回tab
值。有任何想法嗎?我想將其添加到以下腳本中:
Get-VMHost | Get-View | Select Name,
@{N="Cluster";E={Get-Cluster -VMHost (Get-VMHost $_.Name)}},
@{N="DataCenter";E={Get-Datacenter -VMHost (Get-VMHost $_.Name)}},
@{N="Vendor";E={$_.Hardware.SystemInfo.Vendor}},
@{N="Model";E={$_.Hardware.SystemInfo.Model}},
@{N="CPU";E={$_.Hardware.CpuInfo.NumCpuPackages}},
@{N="CORES";E={$_.Hardware.CpuInfo.NumCpuCores}},
@{N="TotalMHZ";E={[math]::round($_.Hardware.CpuInfo.Hz/1000000, 0)}},
@{N="UsedMem (GB)";E={[math]::round($_.Summary.QuickStats.overallMemoryUsage/1000, 2)}},
@{N="TotalMem (GB)";E={[math]::round($_.Hardware.MemorySize/1000000000, 2)}} |
Export-Csv MyOutputFile.csv
一如既往的感謝。
有趣的是,你可以從'Get-VM'獲得'tag',但不能'Get-VMHost',因爲'Get-VM'返回'VirtualManchine'對象,並且不包含'tag'屬性,所以它必須包含在'InventoryItem'基礎對象包含的'ExtensionData'或'CustomFields'屬性中。 'Get-VMHost' cmdlet也包含這些,所以我認爲你可以在那裏做同樣的事情。 – TheMadTechnician