Removing with DeletePermanently switch means it will also remove the incorrect VMX file from the DS?
$ResourcePool = "hostname"
Get-VMHost -Name $ResourcePool | Get-VM |
Where-Object{$_.PowerState -eq 'PoweredOff'} |
ForEach-Object -Process {
Remove-VM -VM $_.Name -Confirm:$false
New-VM -Name $_.Name -VMHost $_.VMHost -VMFilePath $_.ExtensionData.Summary.Config.VmPathName -Confirm:$false
}
This is the script I'm trying to use to fix the new created VMs instead of Registered...
for example:
on host 1, there was vm1(orphaned), vm2(orphaned), vm3(orphaned)
I accidentally used the wrong script, which removed the VMs, but instead of re-registering, I've created new VMs now I have on host 1 VMs - vm1, vm2 vm3, not orphaned.
I tried to remove them (without DeletePermanently ) and re-register with the script above.
it did removed them, but did not re-registered them back from the location of the VMX.
Is removing them permanently with DeletePermanently will do the trick, and re-register them from the correct path of VMX?