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

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

$
0
0

On new-harddisk why are you specifying the actual disk path? Why not specify just the datastore?

 

Try this to get the datastore name and put it on the same datastore:

 

$HDDfile = Get-HardDisk -VM $vmname | Where-Object {$_.Name -ne 'Hard Disk 1'} | select Filename

$datastorename =$HDDfile.split("[]")[1]

Get-HardDisk -VM $vmname | Where-Object {$_.Name -ne 'Hard Disk 1'} | Remove-Harddisk -Confirm:$false

   New-HardDisk -VM $vmname -Datastore $datastorename

 

 

You also have to specify the size of hte disk.  so -capacityGB.  Don't know if they will all be same size or not but you can get that info as well and pass it or hardcode it.


Viewing all articles
Browse latest Browse all 214415

Trending Articles



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