Skip to content

Instantly share code, notes, and snippets.

@brianbunke
Last active January 26, 2017 15:53
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 brianbunke/4606d212420c3980042c7aeb8ee3a7ac to your computer and use it in GitHub Desktop.
Save brianbunke/4606d212420c3980042c7aeb8ee3a7ac to your computer and use it in GitHub Desktop.
#Requires -Version 3
Import-Module VMware.VimAutomation.Core
Connect-VIServer XXXXX
$Report = New-Object 'System.Collections.Generic.List[PSCustomObject]'
$VM = Get-VM
$VM | ForEach-Object {
$Obj = [PSCustomObject][ordered]@{
VMName = $_.Name
VMPowerstate = $_.Powerstate
VMTagDRSPrio = (Get-TagAssignment -Category DRSPrio $vmname).tag.name
VMTagBootPrio = (Get-TagAssignment -Category BootPrio $vmname).tag.name
VMFolder = $_.Folder
VMMemoryGB = $_.MemoryGB
VMNumCpu = $_.NumCpu
VMProvisionedSpaceGB = $_.ProvisionedSpaceGB
VMUsedSpaceGB = $_.UsedSpaceGB
VMNotes = ($_.Notes -replace "`n"," ")
}
$Report.Add($Obj)
}
$Report | Export-Csv -Path "C:\Temp\VMTagList_$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss')).csv" -Delimiter ";" -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment