Update the ISO Path on multiple VMs using PowerCLI

I have several special use case VMs that boot from an ISO file stored on a datastore. During a recent storage refresh, I found that we had the need to update the ISO path on all of these VMs from the old datastore to the new. PowerCLI came to the rescue once again and tackled it with just a few lines of code:

$vms = get-vm -location "cluster name"
$oldPath = "[Old_ISO_Datastore] boot.iso"
$newPath = "[New_ISO_Datastore] boot.iso"

foreach($vm in $vms){
	$cd = get-cddrive -VM $vm
	if($cd.IsoPath -eq $oldPath){
		set-cddrive -CD $cd -IsoPath $newPath -Confirm:$false
This entry was posted in PowerShell, VMware and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *