VMware

Export and Import VMware customization specs

While looking for ways to migrate to our new VCenter server, I came across http://www.van-lieshout.com/2009/07/export-and-import-customization-profiles-using-powershell/ which describes how to export your customization specs (passwords and all) and then reimport them into the new VC.

Export

$path="d:temp"
#Export Customization Profiles
$view = get-view CustomizationSpecManager
ForEach ($CustomizationProfile in $view.info) {
$xml = $view.CustomizationSpecItemToXml($view.GetCustomizationSpec($CustomizationProfile.name))
$xml | Out-File ($path + "" + ($CustomizationProfile.name) + ".xml")
}

Import

$path="d:temp"
#Import Customization Profiles
$view = Get-View CustomizationSpecManager
ForEach ($xmlfile in (Get-ChildItem -Path $path | where {$_.extension -eq ".xml"})) {
$xml = Get-Content ($xmlfile)
$view.CreateCustomizationSpec($view.XmlToCustomizationSpecItem($xml))
}

One thought on “Export and Import VMware customization specs

  • Export PS fixed:
    if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null )
    {
    Add-PsSnapin VMware.VimAutomation.Core
    }
    $connection = Connect-VIServer wtnintprdsrmvm1.nt.local
    $path="c:userssmagilldesktop"
    #Export Customization Profiles
    $views = get-view CustomizationSpecManager
    foreach ($view in $views) {
    foreach ($CustomizationProfile in $view.info) {
    $xml = $view.CustomizationSpecItemToXml($view.GetCustomizationSpec($CustomizationProfile.name));
    $xml | Out-File ($path + "" + ($CustomizationProfile.name) + ".xml")
    }
    }

Leave a Reply