Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 225804

Re: Script to Remove HDDs other than HDD1 from VM and re-add it back.

$
0
0

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

 

}


Viewing all articles
Browse latest Browse all 225804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>