VMware

This Question is Not Answered

1 "correct" answer available (10 pts) 1 "helpful" answer available (6 pts)
7 Replies Last post: May 19, 2008 12:41 PM by gpeck29  

Changing Disk Persistence posted: Apr 30, 2008 7:17 PM

Click to view gpeck29's profile Enthusiast 29 posts since
Sep 12, 2006

I need to change the disk persistence of some VMs for patching and software updates. Any ideas how to go about this? I haven't found a straightfoward way to do this.


Re: Changing Disk Persistence

2. Apr 30, 2008 8:18 PM in response to: gpeck29
Click to view kjb007's profile Guru 5,476 posts since
Sep 18, 2006
You should be able to use wait-task, to wait until the vm is down, or just loop until the state returns poweredOff, and then continue on with your other code.

-KjB

Re: Changing Disk Persistence

3. May 1, 2008 5:32 AM in response to: gpeck29
Click to view halr9000's profile Master 808 posts since
Jun 7, 2007
gpeck29 wrote:
Now if I can figure out how to use a CSV file of VM's or even a list of VMs in an Active Directory OU to perform this operations for, I'll be set.

$process = import-csv need_maint.csv
$process | foreach-object {
    $vm = $_.name | get-vm # assumes there is a Name column in the CSV
   # the rest of your steps
}


For AD, check out Quest's AD cmdlets. There is one called Get-QADComputer that will do the trick very nicely. You can specify an OU or LDAP query to it and then for example assign those results to the $process variable above.


Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)

Re: Changing Disk Persistence

4. May 8, 2008 8:32 PM in response to: gpeck29
Click to view stephen.ng's profile Novice 12 posts since
Apr 4, 2008

Hmm, this doesn't work for me. I'm using ESX 3.

(Get-HardDisk -VM (Get-VM -Name MyVm)) | Set-HardDisk -Persistence persistent

No matter whether I set it to "persistent" or "nonpersistent", the disk is not independent. How can I configure the disk to be independent using the API?

Thanks,

Steve


Re: Changing Disk Persistence

5. May 9, 2008 12:37 AM in response to: stephen.ng
Click to view LucD's profile Champion 2,384 posts since
Oct 31, 2005
As far as I know there is no cmdlet that allows you to change the mode of a hard disk to independent.

You can use the SDK API to configure this.
See here for the different options you have.

An example of this is the add-HD function in Adding an existing hard disk.

Re: Changing Disk Persistence

6. May 9, 2008 9:46 AM in response to: LucD
Click to view stephen.ng's profile Novice 12 posts since
Apr 4, 2008
Yeah, I wound up going to the underlying API. Kind of a pain but it works.

Steve

$vm = Get-View(Get-VM $NewVmName).ID

$vdcs = New-Object VMware.Vim.VirtualDeviceConfigSpec
$vdcs.Device = $vm.Config.Hardware.Device10
$vdcs.Operation = 'edit'
$vdcs.Device.Backing.diskMode = "independent_nonpersistent"
$vmcs = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmcs.DeviceChange = $vdcs
$vm.ReconfigVM($vmcs)

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities