Hi Robert,
Thanks for the reply,
Here i have completed the script can u please suggest if it is right
$vmname = testvm02
Get-VM -Name $vmname| %{
Write-Host "Stoping VM" $vmname
$vmname | Get-VMGuest | where {$_.State -eq "Running"} | Shutdwon-VMGuest -Confirm:$false
$HDDfile = Get-HardDisk -VM $vmname | Where-Object {$_.Name -e 'Hard Disk 1'} | select Filename
Get-HardDisk -VM $vmname | Where-Object {$_.Name -e 'Hard Disk 1'} Remove_Harddisk
New-HardDisk -VM $vmname -DiskPath $HDDfile
Write-Host "Starting VM" $vmname
$vmname | Start-Vm -Confirm:$false
}