its done .. Thanks everyone for the inputs
here is the script ...
$vmname = Get-Content -Path "VM.txt"
foreach ($VM in $Vmname){
$getVM = Get-VM -Name $VM
Write-Host "Stopping VM" $VM
$getVM | Get-VMGuest | where{$_.State -eq "Running"} | Shutdown-VMGuest -Confirm:$false
do{
#Wait for the VM to poweroff
$Shutdownvm = Get-VM -Name $VM
$powerstaus = $Shutdownvm.PowerState
Write-host "Waiting for shutdown of $VM"
sleep 5
} until($powerstaus -eq "PoweredOff")
$HDDfile = Get-HardDisk -VM $VM | Where-Object {$_.Name -ne 'Hard Disk 1'} | select Filename
#$HDDpath = $HDDFile.FileName
Write-Host "Removing The HDDs of VM" $VM
Get-HardDisk -VM $VM | Where-Object {$_.Name -ne 'Hard Disk 1'} | Remove-Harddisk -Confirm:$false
foreach ($HDD in $HDDfile){
$HDDpath = $HDD.Filename
Write-Host "Re-adding The HDD to VM" $VM
New-HardDisk -VM $VM -DiskPath "$HDDpath"
}
Write-Host "Starting VM" $VM
Start-VM $getvm
}