Last active
January 26, 2017 15:53
-
-
Save brianbunke/4606d212420c3980042c7aeb8ee3a7ac to your computer and use it in GitHub Desktop.
Suggestions for https://www.reddit.com/r/vmware/comments/5q99je/why_is_my_script_so_slow_gettagassignment/
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
#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