Create the virtual machine by using the file PowerCLI and csv

I know there is a lot of info out there on this and I think I have a working script prety good.  Much was borrowed from this thread, http://communities.vmware.com/thread/315193 many thanks to LucD.

My code is as follows:

# Deploy virtual machines from CSV file
# Much borrowed from http://communities.VMware.com/thread/315193?start=15 & tstart = 0


# CSV import file
Import-Csv "C:\guests.csv" - UseCulture | %{
# Gets the customization information to configure the static NETWORK card and assign the static IP address
Get-OSCustomizationSpec $_. Customization | Get-OSCustomizationNicMapping | `
Game-OSCustomizationNicMapping - UseStaticIP - IpAddress IpMode $_. ""IP address""
-Subnet mask $_. Subnet - DefaultGateway $_. Gateway - Dns $_. DNS
$vm = New-VM-Name $_. "" Server name "-model $_. Model-host $_. ' "The ESX host" '
-Datastore $_. Data store - OSCustomizationSpec $_. Customization"
-Confirm: $false - RunAsync
## .......
}

He's going to cross and clone the virtual machine, and looks like he's running of the OSCustomizaitonSpec then it bombards.  It cleans bad VM.  Recent tasks shows "failed virtual machine clone that a specified parapeter was not correct." hostname ".

The problem is that I don't mean to set a hostname with the OSCustomixationSpec, I try only to IP address info.

I'm runningn PowerCLI 5.0.1 build 581491

My ESXi host is 5.0.0 build 914586

My vCenter Server is Ver 5.0.0 build 623373

I opened a new thread, because the age of the old thread.  Not sure if this is the best way to do things.

A very simple and intuitive brake system :-)

## Deploy VMs from CSV File
## Much borrowed from http://communities.vmware.com/thread/315193?start=15&tstart=0  

$maxJobs = 3 $currentJobs = 0
## Imports CSV file
Import-Csv "C:\temp\TestDeploy1" -UseCulture | %{
## Gets Customization info to set NIC to Static and assign static IP address
    Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | ` ## Sets the Static IP info
    Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."IP Address" `        -SubnetMask $_.Subnet -DefaultGateway $_.Gateway -Dns $_.DNS## Sets the name of the VMs OS
    $cust = Get-OSCustomizationSpec -Name Test    Set-OSCustomizationSpec -OSCustomizationSpec $cust -NamingScheme Fixed -NamingPrefix $_.VMName## Creates the New VM from the template
    $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" `        -Datastore $_.Datastore -OSCustomizationSpec $_.Customization `        -Confirm:$false -RunAsync

    $currentJobs = Get-Job -State Running | Measure-Object | Select -ExpandProperty Count    while($currentJobs -ge $maxJobs){
      sleep 30      $currentJobs = Get-Job -State Running | Measure-Object | Select -ExpandProperty Count    }
## .......
}

You can be more selective about the current jobs. For example, you can check if the name of the job shows that they are actually cloning jobs.

Tags: VMware

Similar Questions

  • Cannot create a virtual machine with a vmdk file copied from another location, please find the attached error

    Hi all

    I copied a file from one place vmdk and try to make a new virtual machine with this vmdk file. But when I turn on after the creation of vm error is coming. Error in the text and the image below

    Power on the virtual machine: cannot open scsi0:0 disc: disc not supported or not valid type 7. Ensure that the disk has been imported.

    See the error of the stack for more details on the cause of this problem.

    Time: 31/03/2015-14:40:05

    Target: DBServer

    vCenter Server: vcsa

    Error stack

    An error was received from the ESX host turning on DBServer VM.

    Unable to start the virtual machine.

    Power DevicePowerOn module has failed.

    Unable to create the virtual SCSI device for scsi0:0, ' / vmfs/volumes/543d140b-feb33d52-7640-90b11c9796c3/vmdk/kapuatdb.vmdk'

    Could not open scsi0:0 disc: disc not supported or not valid type 7. Ensure that the disk has been imported.

    This error message generally if the hard files have been copied hosted as VMware Workstation product, which uses a format of sparse file that is not supported on an ESXi host. Instead of the hard copy, you can use VMware Converter, or - if you prefer - you can convert the hard using vmware-vdiskmanager (before transfer) or vmkfstools (after downloading). I deal to use vmkfstools you will need to load the mutliextent module (see for example "Clone or migration operations involving virtual discs non-VMFS on ESXi fail with an error" vSphere 5.1 Release Notes)

    André

  • API to create a Virtual Machine without using a model

    I see the GUI documentation how to create a virtual machine without a model, but I can't find the actions of the API how to build the virtual machine based on custom settings (CPU, memory, OS, etc.), there are a only of the shares how instantiate OVF or vAppTemplate. Could you please tell is possible to generate/create the VM without model or OVF by API?

    I see. Thanks for the background.

    Based on my notes there is no such API. Other applications were similar to this one and the solution suggested in this case is to programmatically create an OVF (describing the configuration of the VM to instantiate) and import it into the vDC. The end result is the same (i.e. an empty VM configured by entries) the difference is how it gets instantiate (created from zero Vs described in the OVF and imported).

  • How to create a virtual machine from an ISO file?

    Hello

    I was exposed to ESXi for a few days and who need your help.

    I installed ESXi on a server and you want to create VMS of ISO files. (Ubuntu, Win7, ESXi)

    I beent told I can create virtual machines using Vcenter Converter from a client computer, but I can't figure out how.

    I have the Client installed vSphere and vCenter Converter Sandalone.

    Thank you for your help,

    Park

    The virtual machine must be fed first

  • Loading file to the Virtual Machine by using an external USB drive... Please help

    We have an environment that we would like to import and create a virtual machine. The files are on the external 1 TB external hard drive USB puppy with NTFS. The files are approximately 430 GB. I tried almost all the options to get the files to the HOST that is running the server ESXI 4.0.

    Whenever we tried to get the files using the USB drive and Vsphere client connected to a local computer running windows on the ESXI 4.0 Server somehow transfer stops after a while. Some time around after ro possibly around 250 GB 200 GB. So far, we are not able to get the hard master file that occupies about 430 GB in the ESXI data store.  We also tried the third "Fastscp" software to transfer files to the ESXI host, but we had the same problem that the transfer stops at some point.

    Another option that we tired was to start a machine with Linux live CD and USB directly attached to this machine. As the Linux version was newer USB NTFS partition hard drive has been detected without installing any NTFS disks. We have mounted the drive USB on this machine and exported the mount point. In the ESXI server using CLI not supported (Alt - F1) we were able to ride the point of editing exported and tried to copy the files to the folder main datastore but same problem the transfer stops after a few hours sometimes even near 300 GB.

    Y at - it somehow I can bypass the file transfer by using not not the network, which means that if we reach directly the USB key to the ESXI server machine does not recognize it (using Alt - F1 not CLI) because it is partitioned into NTFS. I read that ESXI only supports FAT partition.

    We also tried to start the machine running ESXI server with the latest versions of Linux, in this case, we were able to mount the USB drive directly, but because ESXI stores files with VMFS partition we couldn't mount this partition in linux.

    Could you please recommend any solution to get the files the server ESXI 4.0?  Is there a way to allow us to start the EXSI with Linux server and can mount the partition VMFS use third-party drivers? OR what you would do. Advice would be nice.

    Welcome to the forums - using the vSphere client should work - block of what size did you use to create your VMFS data store? If you left it at the default of 1 MB, then the bigger file, you can copy that VMFS datastore is 256 GB - you'll need to create the data store with a block size of 2 MB which will allow you to create a file upto 4 MB or 512 GB keast and a size of 1024 GB.

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

  • Create a virtual machine using the ubuntu (host of W7) partition

    I am running Windows 7 and 8 of VMware Workstation.

    The disc is actually a raid-0. There are 3 partitions: (Dual-boot)

    -Ubuntu (64-bit)

    -System reserved Windows

    -Windows (64-bit)

    I am trying to create a virtual machine under W7 using the Ubuntu partition.

    I tried 2 things for step 'select a physical drive:

    -Use individual partitions. The problem is at the end, when you click Finish. I get the error: "one of the provided parameters is not valid."

    -Disc use whole. The virtual machine is created, but when I turned on, I get the error:

    "Could not open the disk ' C:\. [..] \Ubuntu 64 - bit.vmdk' or one of the snapshot disks it depends on.

    Reason: the physical disk is already in use. »

    Thank you in advance for answering,

    Kind regards.

    In my tests I couldn't use a host physical diskwith a Windows 7 without setting the disc 'offline '.
    But then you can set the diskette from Windows Startup 'offline '.

    Using Linux or 2003, you don't have this problem.

  • VMware 6.5.5 cannot import the virtual machine that uses 2GB "disks of split.

    Hello

    I'm using VMware Workstation 6.5.5 under Win XP. I tried to import a virtual machine that was created by using the option 'Split' virtual disks into files of 2 GB. The import fails and presents a pop-up: ' Conversion Assistant/cannot determine the guest operating system. The log file includes the line "could not find the disk cofortcol3v01 - cl1.vmdk. This file does not exist of course, there are more files cofortcol3v01-cl1 - s001.vmdk, cofortcol3v01-cl1 - s002.vmdk and so on. The machine virtual original (cofortcol3v01) has been created under VMware Workstation 5.1, and it does not under Workstation 6.5.5.

    Is this a known problem in the conversion utility? Is there a work around for this problem?

    Thank you.

    -Phil Anzel

    FYI... VMware Workstation peut import a Virtual Machine that uses twoGbMaxExtentSparse discs.

    The log file includes the line "could not find the disk cofortcol3v01 - cl1.vmdk. This file does not exist of course, rather there are files cofortcol3v01-cl1 - s001.vmdk, cofortcol3v01-cl1 - s002.vmdk and so on. The machine virtual original (cofortcol3v01) has been created under VMware Workstation 5.1, and it does not under Workstation 6.5.5.

    Is this a known problem in the conversion utility? Is there a work around for this problem?

    The problem is that you're missing the "disk DescriptorFile", "cofortcol3v01 - cl1.vmdk" and which is why it's a failure and not a limitation of the Conversion utility.

    Also if you actually had a Virtual Machine created in VMware Workstation 5.1 you can simply run directly under VMware Workstation 6.5.5 without having to run the import command.

    Anyway, if you have a backup that you can recover the file "cofortcol3v01 - cl1.vmdk" then you should be fine and if you have not then a new can be created.  If you can archive (compress) files vmware*.log (usually 4 of them) in a single zip file archive and tied him to a post in response, then one of us will create a new file "cofortcol3v01 - cl1.vmdk", based on the information contained in files vmware.log for you, if you don't know how to do it yourself.

  • Create a virtual machine with the physical RAM total?

    I want to virtualize ESXi 4 on my MacBook Pro. However, I have 2 GB of RAM and ESXi 4 requires a minimum of 2 GB.

    I posted in the community of ESXi (is it possible to virtualize ESXi 4 with less than 2 GB of RAM?) and there is a solution for using ESXi with less RAM, but the problem is that I first need to run the installation with 2 GB.

    Basically, I tried to create a virtual machine with 2 GB, but the maximum I can use is 1840MB. Is it something that I do with Fusion to increase this limit? I understand that I am under a host operating system and requiring too little RAM, but just to get through the ESXi installation isn't it possible to push the VM of RAM to 2 GB and the host what OS increase the pagefile to deal with the lack of RAM?

    Any help would be appreciated!

    Thank you

    You may be able to edit the .vmx file and change the memsize option either 2048 or more. The merger is able to start a virtual machine with more memory that the host, just UI prevents common users to exceed the limits of security in general.

    I'm not quite sure what would happen if the VM actually tries to use all of the memory. If all goes well, it will be just talk and run slowly. Of course, the worst case are that it crashes.

  • How can I know what the user creates a virtual machine?

    vCenter 2.5 update 4.

    All users of this connection are users active directory.

    How can I find who created a virtual machine from scratch / deployed a VM from a template.

    I.E. I'm visualize something like a right click on the virtual computer, then select properties and it shows you the creator / owner. A bit like the advanced windows file security tab, you can watch the owner.

    It is not a good like that.

    But the newspaper of VC, you can trace who create/deploy a virtual computer.

    André

    * If you found this device or any other answer useful please consider awarding points for correct or helpful answers

  • Create several virtual machines from the same base image

    Hi all

    Is there any vi api sdk by which I can create several virtual machines form same base vmdk file?

    All create the VM from the base VMDK file will have their own delta vmdk file that will refer to the same base VMDK file. Only changes that are performed on each virtual machine are saved on their respective delta vmdk files.

    Thanks in advance...

    Hello

    What you are referring is called Clones related, in the current VI API, there is no method that supports this feature. You can take a look at CloneVM_Task() http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.VirtualMachine.html#clone if you want to implement a full clone and this will require you to have access to vCenter.

    In the next version of vSphere, vSphere SDK THAT will provide a way to implement the related Clones and it will be a parameter you can specify CloneVM_Task() , more precisely in the VirtualMachineRelocateSpec where you will specify diskMoveType to createNewChildDiskBacking

    You can find more information once vSphere of GA and the new QAnywhere VI documents are released, but if you are looking to implement related Clones today, you can take a look at the product of VMware View 3, which provides support for linked Clones or you can take a look at two scripts that I wrote which creates linked Clones similar to that of the view :

    Clones related to ESX

    CLones related to ESXi

    =========================================================================

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    repository scripts vGhetto

    http://Twitter.com/lamw

    If you find this information useful, please give points to "correct" or "useful".

  • Create a virtual computer model using the Windows Client (c#) function?


    The windows-based client can create VM templates?  I created a VM Windows Server 2012 R2 Standard and I would use it as a model for all the virtual machines that follow.  However, I have not yet created the vCenter Server VM but want to use the W2012R2 virtual machine as its base.  I don't see how with the customer I have.  Can if not a model, I simply duplicate the VM?  I don't want to use this machine virtual first for vCenter Server and then create a new one from scratch for use as a model.

    To create templates and clone virtual machines, you will need vcenter server in place, but you can use alternative means to clone this virtual machine to use as a basis for vCenter, take a look at this blog post: cloning a virtual machine without vCenter in ESXi free edition 5.1 | Curiosity killed the cat

  • vCO workflow: create a virtual machine from a model and then ask the user about the CPU, memory size...

    Hi guys,.

    I am trying to create a workflow with vCO that can do the job for me:

    -Create a virtual machine (or maybe a several virtual machines) from a model (the model is in vCenter, of course)

    -L' user who is running the workflow has the thr right to say what he wants for the CPU, the memorysize, the disksize

    Any help?

    I found some workflows in the library can seem to do something similar to what I want, but since I'm a beginner I'd rather have your advice

    Hello there and welcome to vCenter Orchestrator

    Take a look at this series of tutorials to get an idea of how start:

    Create a vCO simple self-service VM Provisioning Portal - part 1

    Create a vCO simple self-service VM Provisioning Portal - part 2

    Create a Simple Self Service VM Provisioning Portal vCO - part 3

    The general approach to take would be to determine which of the clone (or clone and customize) workflows adapts to your nearest need (see your customer vCO: workflows\Library\vCenter\Virtual Machine management\Clone\)

    Then, create a NEW WORKFLOW that calls this one... after that your clone operation is complete, keep the computer turned off virtual and add feeds of extra work from the library to your new workflow that do things like change the amount of Ram, adds disks, change CPU, etc...

    Be sure to watch the videos on http://www.vmwarelearning.com/orchestrator to get a basic understanding of the use of vCO.

  • Script to create multiple virtual machines model works is not for the network adapter variable

    We are working on a script to create multiple virtual machines from a template. The script works fine, but when we try to include commands to set the NIC to a group of specific ports on a dvswitch script errors on. Here's what we have so far. This script (less network variables) works, but we would like to include the network configs in the script as well.

    -------------------

    This is the part of the script that configures the network/dvswitch adapter... but does not work properly.

    $myResourcePool = get-ResourcePool-name DQOL

    $dsName = get-Datastore-name "DQOL-DS01.

    $myTemplate = get-Template-name "DQVTemplate".

    $distributedSwitchPortGroup = get-VirtualSwitch-distributed - name "CVE-dvS04-Nexus - k 5 | Get-VirtualPortGroup-name '979-DQ-SHARED '.

    New-VM-name MyVM1-model $myTemplate - Networkname ResourcePool - $myResourcePool - OSCustomizationSpec $mySpecification $distributedSwitchPortGroup - Datastore

    (Get-$dsName data store)

    New-VM-name MyVM2-model $myTemplate - ResourcePool $myResourcePool - OSCustomizationSpec $mySpecification - Datastore (Get-$dsName data store)

    _____________________

    !!!!!!!  This part works, but without specifying a network/dvswitch... card!

    $myResourcePool = get-ResourcePool-name DQOL

    $dsName = get-Datastore-name "CVE-SAN-ISG-DS02-02ef.

    $myTemplate = get-Template-name "DQVTemplate".

    New-VM-name MyVM3-model $myTemplate - ResourcePool $myResourcePool - OSCustomizationSpec $mySpecification - Datastore (Get-$dsName data store)

    New-VM-name MyVM4-model $myTemplate - ResourcePool $myResourcePool - OSCustomizationSpec $mySpecification - Datastore (Get-$dsName data store)

    Here is the error we get:

    New-VM: all parameters can be resolved by using the specified named parameters.

    C:\Users\capuanoj\Desktop\Create-multiplevms-fromtemplate.ps1:6 char: 7

    + New-VM < < < <-name MyVM1-model $myTemplate - Networkname $distributedSwitchPortGroup - ResourcePool

    ePool - OSCustomizationSpec $mySpecification - Datastore (Get-$dsName data store)

    + CategoryInfo: InvalidArgument: (:)) [new-VM], ParameterBindingException)

    + FullyQualifiedErrorId: AmbiguousParameterSet, VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

    You cannot use the - model and Networkname - parameters of the cmdlet New - VM in a single order, because both are in different parameter sets. You must first create the virtual machine and then use the cmdlet Set-NetworkAdapter to change the portgroup of the virtual machine. As in example 4, assistance from cmdlet Set-NIC:

    --------------  Example 4 --------------

    C:\PS>$myNetworkAdapters = Get - VM | Get-NetworkAdapter-name "NIC 1.
    $myVDPortGroup = get-VDPortgroup-name MyVDPortGroup
    Together-NetworkAdapter NetworkAdapter - $myNetworkAdapters - $myVDPortGroup Portgroup

    Retrieves all network named "NIC 1" cards of all virtual machines and connects to the specified distributed port group.

  • Can I just create a virtual machine with the installation of operating system and Application in an external drive?

    People,

    Hello. I use VMPlayer to install virtual machines a few OS in my laptop.

    Because my laptop's hard drive space is not enough to create a VM more to install Oracle Linux and its Application, can I just create a virtual machine in my laptop and then install Oracle Linux and its Application in an external USB disk?

    You can create and save the Virtual Machine in any place that you have read & write access to and enough space to support what is being installed.

  • do I have to buy the new key to run the operating system on a virtual machine personal use? SOS. SOS...

    Hello

    I wanted to run vista on the same computer; but on a virtual machine. I wanted to know if I should buy a seprate key. I was perplexed because it is on the same computer at home. I wanted to use it for personal use as run the operating system on the virtual machine for programs to avoid viruses and use it kind of like a backup. I asked around only to meddle with the answers. Many people need to know the right answer to this question. Oh guys please keep this thread alive for others!

    Thank you

    Jamie

    Hello

    the rules of licensing are:

    One license = Installation and which includes computer

    the vista virtual machine installation will be a second installation requiring a second license of Vista

Maybe you are looking for

  • CANNOT REMOVE SWEET/IM TOOLBAR, ETC.

    Unfortunately, the emoticons software has been installed on my computer.Some time ago I removed the installation and thought I had deleted, but there must be some leftovers. I can't get rid of it, in the Firefox toolbar. It substitutes for all attemp

  • Update 05/21/2012 continues to repeat after succesful installed

    Update returns constantly after successful installation. What is the problem with the update today. I go to successfully and updating Microsoft install, restart the computer. It is said correctly updates installed. After restarting, the taskbar icon

  • Cannot find the driver Hitachi HDT721010SLA360

    I have a Hitachi HDT721010SLA360 disk drive and can not find a driver 64 bits for her, I found 32 but I don't know if that's going to help since my system is 64-bit. Thanks for any help, the last suggestion, I had was to buy a new one and I would lik

  • Microsoft VM is installed on my computer?

    I have a program that requires Java installed to run.  My computer shows that I have Java installed.  Help box says that I must have msjavx86.exe contained in jvmlnstall.zip.fil.  I'm stuck.  I'm not savvy computer then!

  • Whatsapp blackBerry Smartphones

    I just upgraded my whatsapp and when I try to open it it says error starting whatsapp. display the event log? tried to copy the newspaper... given below... #BlackBerry Event Log (cpt)#HwID: 0x7001204#DPIN: 0x28c6ddc5#PVer: 5.1.0.692#AVer: 7.1.0.1033E