Last active
October 1, 2026 06:53
-
-
Save thost96/b39fddefe4054fbb1df18d7ab3e2adb9 to your computer and use it in GitHub Desktop.
export-vm-custom-attributes.ps1
This file contains hidden or 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
| Connect-VIServer -Server vc-source.example.com | |
| $attList = Get-CustomAttribute -TargetType VirtualMachine | |
| $attList | Export-Csv ".\exported-attributes.csv" -NoTypeInformation -Encoding UTF8 -Delimiter ";" | |
| $valueList = foreach ($vm in (Get-Cluster "CL01" | Get-VM)) { | |
| foreach ($cf in $vm.CustomFields.GetEnumerator()) { | |
| [PSCustomObject]@{ | |
| VMname = $vm.Name | |
| FieldKey = $cf.Key | |
| FieldValue = $cf.Value | |
| } | |
| } | |
| } | |
| $valueList | Export-Csv ".\exported-attributes-value.csv" -NoTypeInformation -Encoding UTF8 -Delimiter ";" | |
| Disconnect-VIServer -Server * -Confirm:$false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment