vCAC: Export all PropertyDefinitions automatically with PowerShell

Imagine you feel like reinstalling your vCAC system as the DB got somehow corrupted and VMware support is not able to fix it. Although you really like the fancy GUI of the vCAC administration interface you somehow get bored to enter all your configuration options again and again … As usual, there is help:

PS > $File = 'C:\data\Export-PropertyDefinitions.xml';
PS > $m.GetType().FullName;
DynamicOps.ManagementModel.ManagementModelEntities
PS > foreach($pd in $m.PropertyDefinitions) {
  ($pd|gm -Type Property).Name |% { $null = $m.LoadProperty($pd, $_); }
} # foreach
PS > $apd = $m.PropertyDefinitions;
PS > $apd | Export-Clixml $File;

You can later import them via API again (or just use one of the handy wrappers in our ‘biz.dfch.PS.vCAC.Utilities’ module):

PS > $apd = Import-Clixml $File;
PS > foreach($pd in $apd) {
  New-VcacPropertyDefinition 
    -Name $pd.PropertyName 
    -Value $pd.PropertyValue 
    -DisplayName $pd.DisplayName 
    -Description $pd.FullDescription 
    -Type $pd.ControlTypeName 
    -IsHidden:$pd.IsHidden 
    -IsRuntime:$pd.IsRuntime 
    -IsEncrypted:$pd.IsEncrypted 
    -IsRequired:$pd.IsRequired
    ;
} # foreach

Needless to mention that you can do this with nearly any entity in vCAC you like…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: