VMware Cloud Community
golddiggie
Champion
Champion

set drives to independent/persistent via CLI script??

We're looking for a script/command set to set specific drives to independent/persistent in our environment (~1000 hosts and 10,000+ VMs). We would prefer to have a feeder file with a list of targets that it will use to make this change. It would also need to not shut down the VM as part of this but let it wait (flags set) until the VM is powered off as part of a set schedule.

Hoping someone knows a good way to do this, IF it can be done.

Thanks.

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

Something like this?
Note that the VM needs to be powered off for this to work.

$vmName = 'MyVM'

$hdName = 'Hard disk 2'


$vm = Get-VM -Name $vmName

$hd = Get-HardDisk -VM $vm -Name $hdName

Set-HardDisk -HardDisk $hd -Persistence IndependentNonPersistent -Confirm:$false


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

kronosvmw
Contributor
Contributor

LucD,

Confirmed that the machines need to be powered off for the change:

pastedImage_0.png

However I see posts back from 2011 that seem to indicate this used to work against live workloads?  Was this changed?

Changing persistent <-> non-persistent disks

https://ict-freak.nl/2009/12/01/powercli-change-persistence-mode-on-the-fly/

Reply
0 Kudos
LucD
Leadership
Leadership

Afaik this always required the VM to be powered off.
Neither of those 2 posts seems to say that the VM can be powered on.


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

Reply
0 Kudos