VMware Cloud Community
sakvel
Contributor
Contributor

Script for add vmdk disk via command line in esxi 5.1

Script for add vmdk disk via command line in esxi 5.1

Reply
0 Kudos
2 Replies
cjscol
Expert
Expert

What exactly do you want to do?

Does this help (see link below)?  I used this to add a vmdk to 50 VMs via PowerCLI

I Love PowerCLI! | Pelicano Computer Services

If you just want to add a new vmdk to an existing VM you can use the PowerCLI command

New-HardDisk -VM <VMName> -CapacityGB <Size-of-VMDK> -Datastore <DatastoreName>

Where <VMName> is the name of the VM you want to add the vmdk to

<Size-of-VMDK> is the size of the VMDK in GB

<DatastoreName> is the name of the datastore you want the VMDK to be stored on, off the top of my head if you omit the -Datastore option then it will store the vmdk on the same datastore as the .vmx file is stored.

e.g.

New-HardDisk -VM Server01 -CapacityGB 20 -Datastore Datastore01

Calvin Scoltock VCP 2.5, 3.5, 4, 5 & 6 VCAP5-DCD VCAP5-DCA http://pelicanohintsandtips.wordpress.com/blog LinkedIn: https://www.linkedin.com/in/cscoltock
Reply
0 Kudos
sakvel
Contributor
Contributor

Hi Cjscol...

Thanks a lot for your quick responce...my requirement is i am working on DR test.. we need to attach number  already exsisting disk to vms..in GUI it will take time.. so if we are doing in command line it will

elimate the time window...

i plan to use this command "vim-cmd vmsvc/device.diskaddexisting 441 /vmfs/volumes/WhatEverDatastore/vDisk.vmdk 0 3"

if we create a script with this command . it will save more time.

Reply
0 Kudos