NM, I figured it out.
Since I had riun the first script in this thread, the $hdnames variable was there.
when I after a restart of the PS editor it is no longer there,
It worked when I ran:
$vmName = 'node02'
$vm = Get-VM -Name $vmName
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
Get-HardDisk -VM $vm -DiskType RawVirtual,RawPhysical -PipelineVariable hd |
ForEach-Object -Process {
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.Device = $hd.ExtensionData
$dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::remove
$spec.DeviceChange += $dev
}
$vm.ExtensionData.ReconfigVM($spec)
So, just delete all RDM disks, removing the -Name $hdnames