PowerCLI: Change Persistence mode (on the fly)
December 1, 2009 5 Comments
When you have some vmdk’s with the Independent Persistent mode enabled. You might get problems with Storage vMotion (some DMotion errors). I was able to fix this with disabling the Independent mode and create and remove a snapshot of the VM. But within the vSphere client you’re not able to change the Independent setting of a running VM. With PowerCLI you can!
The first one-liner will return all the vmdk’s with the Independet Persistent mode enabled:
Get-VM | % { Get-HardDisk -VM $_ | Where {$_.Persistence -eq "IndependentPersistent"} }
This is what you see in the console.
Within the vSphere client, you can’t change this setting while the VM is powered on.
But why use the vSphere client when we have PowerCLI
. If you run the following one-liner, it will return all the vmdk’s with Independent Persistent mode enabled. The next step is to disable this setting.
Get-VM | % { Get-HardDisk -VM $_ | Where {$_.Persistence -eq "IndependentPersistent"} | ` % {Set-HardDisk -HardDisk $_ -Persistence "Persistent" -Confirm:$false} }
This is the output you’ll see:
When you check the settings within the vSphere client, you’ll notice that the Independent mode is disabled.





Very usefull !!
Excelent,
PowerCLI is very …. powerfull… -:)
Great tip Arne..
I can’t do this without first powering off the VM. Have I missed something here?
I had the same issue. “The VM must be in the following state: PoweredOff.
Pingback: Liens du jour #5 - Hypervisor.fr