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.
This works until vSphere 5.1Update 2, either if the VM is running or powered-off. In vSphere 5.5 it works ONLY if the VM is powered-off
can you tell how to do it for a single VM. when i run the first command i am getting many VM Disks ,of that i need to change the setting for one particular VM .
i have just ran for the Vsphere 4.1 host and the VM is in Running state and upon execution it throws an error that the Vm should be in the powered off state.
Im currently using VMWare 5.1 and trying to write a script with PowerGUI using CLI commandlets.
I have found a bug with command “Set-HardDisk” – it appears deprecated from a storage vMotion perspective, but when setting it to persistent from IndependentPersistent, my script only works if the -confirm switch isnt set.
If I remove the switch, by default my script prompts me, when I say yes… it works (the VM is off by the way). I’ve run it via PowerCLI and via PowerGUI – neither work and both errors say the same thing… “Invalid value passed for the SizeKB parameter.” even when I havent used this switch.
Any thoughts would be much appreciated 🙂
Hats off to you partner! I performed this in production with 10 hosts and 170 VM’s. Worked like a charm – no complaints!