VMware Cloud Community
icnivad
Contributor
Contributor

New-VM without harddisk?

Hi,

is it possible to create a new VM without any disk?

Additional:

How would i remove a disk from a VM? And delete the Disk from Datastore? through PowerCLI

Thanks!

0 Kudos
4 Replies
weinstein5
Immortal
Immortal

Yes it is possible to create a VM without a hard disk - it will then be able to boot form cd, floppy or PXE -

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
LucD
Leadership
Leadership

I assume your question was how to do this with PowerCLI.

On the New-VM you can't specify afaik that there should be no hard disk.

You can do the following in your script

$vmImpl = New-VM -Name MVV30111 -VMHost (Get-VMHost mmmstv004.muac.corp.eurocontrol.int) `
 	-Datastore (Get-Datastore -Name devvmfs1)
$vmImpl | Get-HardDisk | Remove-HardDisk -Confirm:$false

Unfortunately this will not remove the .VMDK file, just the definition of the virtual disk from the .VMX.

Have a look at PowerShell Remove Harddisk Function, which is a similar question.

As I said there you could use the remove-HD function in Adding an existing hard disk


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

jeveenj
Enthusiast
Enthusiast

Hi,

As per my understanding, there is no way to create VM without hard disk with New-VM cmdlet directly. As LucD has suggested first create new VM and then remove hard disk or otherwise you can create VM in different way. This is code snippet which might be helpful

$vmCreateSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmCreateSpec.Name = |Get-View

$fld.CreateVM_Task($vmCreateSpec,$poolmor,$vmhmor)

Hope this helps.

-If you found this information useful, please consider awarding points for Correct or Helpful.
icnivad
Contributor
Contributor

Thanks, i will have a look on the two suggested solutions. Might be a feature request for the new-vm commandlet to have a -disk:$false switch. As there is a checkbox in the gui i think thats not much effort Smiley Wink

0 Kudos