VMware Cloud Community
DSeaman
Enthusiast
Enthusiast

Import/export customization specs with vsphere 5.0

I am unable to find a script that works with vSphere 5.0 which can export the XML customization specifications.  GetCustomizationSpec seems to be an unsupported method with PowerCLI 5.0.

Export:

------

# Variables
$VCServer = "vcserver.yourdomain.local"
$path = "."

#Connect to vCenter Server
$VC = Connect-VIServer $VCServer

#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:

-----

# Variables
$VCServer = "vcserver.yourdomain.local"
$path = "."

#Connect to vCenter Server
$VC = Connect-VIServer $VCServer

#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))
}

Derek Seaman
0 Kudos
3 Replies
LucD
Leadership
Leadership

Works for me.

The GetCustomizationSpec method is present.

custspec.png

Which PowerCLI build are you using ?

Get-PowerCLIVersion

And did you both export/import the customization spec in vSphere 5 ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DSeaman
Enthusiast
Enthusiast

Hmm this is weird...I closed the PowerCLI window, reconnected, and it works now. Ugh!

Derek Seaman
0 Kudos
LucD
Leadership
Leadership

Very strange, that shouldn't normally happen.

If you see the same occurring, I would suggest to open a ticket with VMware.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos