Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 176483

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

$
0
0

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


Viewing all articles
Browse latest Browse all 176483

Trending Articles



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