Skip to content

Instantly share code, notes, and snippets.

@thost96
Last active October 1, 2026 06:53
Show Gist options
  • Select an option

  • Save thost96/b39fddefe4054fbb1df18d7ab3e2adb9 to your computer and use it in GitHub Desktop.

Select an option

Save thost96/b39fddefe4054fbb1df18d7ab3e2adb9 to your computer and use it in GitHub Desktop.
export-vm-custom-attributes.ps1
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