Hi I was trying to write the script to shutdown the VM and then remove the HDDs other than HDD1 and then re-add it back, here is my script ( not completed yet)
$vmname = testvm02
Get-VM -Name $vmname | %{
Write-Host "Stopping VM" $vmname
$vmname | Get-VMGuest | where {$_.State -eq "Running"} | Shutdown-VMGuest -Confirm:$false
$HDD = Get-HardDisk -VM $vmname | Remove-Harddisk
above script remove all the disks which are attached to VM which i don't want, I want only to remove HDDs other than Hard Disk1 .
Can anyone please help me to write this script