Trying to use powershell to remove a 2nd hard disk and seem to be having trouble
Param($VMname)
Get-HardDisk -VM $VMname | Remove-HardDisk -HardDisk "Hard Disk 2" -DeletePermanently
If i run without the "-HardDisk "Hard Disk 2" -DeletePermanently" it interactivley allows me iterate and remove I would however like to specify the correct disk.
Anyone know where I'm going wrong with the syntax?
Thanks in advance
Try it like this
Get-HardDisk -VM $VMname | where {$_.Name -eq "Hard Disk 2"} | Remove-HardDisk -DeletePermanently
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks worked a treat