VMware Cloud Community
aworkman
Enthusiast
Enthusiast

PowerCLI CustomizeVM_Task?

Is there a way to customize a VM via PowerCLI without cloning?

What I'm doing is following

1) Cloning a NFS datastore and attaching it with several golden image virtual machines(using a separate storage powershell api)

2) Renaming the contents of the virtual machines replacing gold in all of the files with a new string(ie: dev/test/etc.) - Currently i'm doing this with a different script.

3) Register the VM's inside virtual center(doing this with powershell)

4) Customize the new VM as per the specification provided by the user(need to find a way to automate this with powercli)

http://communities.vmware.com/thread/268935

This is link is what I need to do, but hopefully via powercli. It appears the perl api allows you to do this where the powercli is missing this feature. Previously i've been doing this with VMware Orchestrator, but it would be nice to include this in my powercli script instead of having an additional perl script separately.

http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.VirtualMachine.html#cust...

0 Kudos
5 Replies
LucD
Leadership
Leadership

Not 100% sure I understand the question.

Are you in fact asking if you can call the CustomizeVM_Task method from a PowerCLI script ?

If that is indeed the question, then the answer is yes.

Anything specific that is not working ?

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
aworkman
Enthusiast
Enthusiast

I guess I just assumed if there wasn't a cmdlet that it couldn't be done, but I am obviously a PowerShell beginner.

Is there an example of how to invoke an api method to which there is no cmdlet using powershell?

0 Kudos
aworkman
Enthusiast
Enthusiast

http://www.lucd.info/2009/11/19/powercli-and-the-sdk-part-1/

I was able to find this which explains what I need to learn how to do. Thanks for writing your articles Smiley Happy

0 Kudos
aworkman
Enthusiast
Enthusiast

$specname = Get-OSCustomizationSpec -Name Server2008_dc_msdn
$serviceInstance = get-view ServiceInstance
$csMgr = get-view $serviceInstance.Content.CustomizationSpecManager
$spec = $csMgr.GetCustomizationSpec($specname)

$goldens = Get-View -Viewtype VirtualMachine -Searchroot (Get-Folder -Name Golden | Get-View).MoRef
foreach($vm in $goldens){
Write-Output $vm.MoRef
$vm.CustomizeVM_Task($spec.Spec)
}

How does this look?

0 Kudos
LucD
Leadership
Leadership

That should work.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos