Deploy multiple virtual machines simultaneously

Hello

I'm trying to deploy multiple virtual machines at the same time using powercli.  I think I have has the switch - RunAsynch, howerver, this doesn't seem to work, instead of that virtual machines are deployed one at a time.  Here is my code:

SE connect-VIServer-Server vc1. MYDOMAIN.local - user MYDOMAIN\MYACCOUNT-password MYPASSWORD

New-vm - vmhost prodh1. MYDOMAIN.local - name of TEST - SVR01 - model W2K8R2SP1 - IOMEGA data store - OSCustomizationspec-W2K8R2SP1-_Tobedeleted location | Start-VM - RunAsync

New-vm - vmhost prodh1. MYDOMAIN.local - name of TEST - SVR02 - W2K8R2SP1 - IOMEGA data store model - OSCustomizationspec-W2K8R2SP1-_Tobedeleted location | Start-VM - RunAsync

New-vm - vmhost prodh1. MYDOMAIN.local - name of TEST - SVR03 - W2K8R2SP1 - IOMEGA data store model - OSCustomizationspec-W2K8R2SP1-_Tobedeleted location | Start-VM - RunAsync

New-vm - vmhost prodh1. MYDOMAIN.local - name of TEST - SVR04 - W2K8R2SP1 - IOMEGA data store model - OSCustomizationspec-W2K8R2SP1-_Tobedeleted location | Start-VM - RunAsync

Start-Sleep - seconds 300

Get - vm "TEST-SVR01 | Get-VMGuestNetworkInterface Guestuser - administrator - GuestPassword "MYPASSWORD" |? {$_.name - eq "Connect to network Local 3"} | Game-vmguestnetworkinterface administrator - Guestuser - GuestPassword "MYPASSWORD" - IPPolicy - 192.168.1.25 static IP - Netmask 255.255.255.0 - Gateway 192.168.1.1 DNS - 192.168.1.2,192.168.1.3 - RunAsync

Get - vm "TEST-SVR02 | Get-VMGuestNetworkInterface Guestuser - administrator - GuestPassword "MYPASSWORD" |? {$_.name - eq "Connect to network Local 3"} | Game-vmguestnetworkinterface administrator - Guestuser - GuestPassword "MYPASSWORD" - IPPolicy - 192.168.1.25 static IP - Netmask 255.255.255.0 - Gateway 192.168.1.1 DNS - 192.168.1.2,192.168.1.3 - RunAsync

Get - vm "TEST-SVR03 | Get-VMGuestNetworkInterface Guestuser - administrator - GuestPassword "MYPASSWORD" |? {$_.name - eq "Connect to network Local 3"} | Game-vmguestnetworkinterface administrator - Guestuser - GuestPassword "MYPASSWORD" - IPPolicy - 192.168.1.25 static IP - Netmask 255.255.255.0 - Gateway 192.168.1.1 DNS - 192.168.1.2,192.168.1.3 - RunAsync

Get - vm "TEST-SVR04 | Get-VMGuestNetworkInterface Guestuser - administrator - GuestPassword "MYPASSWORD" |? {$_.name - eq "Connect to network Local 3"} | Game-vmguestnetworkinterface administrator - Guestuser - GuestPassword "MYPASSWORD" - IPPolicy - 192.168.1.25 static IP - Netmask 255.255.255.0 - Gateway 192.168.1.1 DNS - 192.168.1.2,192.168.1.3 - RunAsync

Get-NetworkAdapter "TEST-SVR01 | Together-NetworkAdapter - NetworkName VM1-confirm: $false

Get-NetworkAdapter "TEST-SVR02 | Together-NetworkAdapter - NetworkName VM1-confirm: $false

Get-NetworkAdapter "TEST-SVR03 | Together-NetworkAdapter - NetworkName VM1-confirm: $false

Get-NetworkAdapter "TEST-SVR04 | Together-NetworkAdapter - NetworkName VM1-confirm: $false

If anyone can help?

Thank you

Duncan.

Yes, you are right.

By specifying the param -VM (Get - VM $modelVM) , you create the new virtual machine from an existing one.

Just change the cmdlet New - VM settings according to your needs and let the VM - far.

It creates your virtual machines based on a template and specification of customization.

$esxName = "prodh1.MYDOMAIN.local"
$template = "W2K8R2SP1"
$datastore = "IOMEGA"
$newVmList = "TEST-SRV01", "TEST-SRV02", "TEST-SRV03", "TEST-SRV04"
$custSpec = "W2K8R2SP1"
$location = "_Tobedeleted"
$taskTab = @{}

# Create all the VMs specified in $newVmList
foreach($Name in $newVmList) {
     $taskTab[(New-VM -Name $Name -VMHost (Get-VMHost -Name $esxName) -Template $template -Datastore $datastore -OSCustomizationSpec $custSpec -Location $location -RunAsync).Id] = $Name
}

Of course, you can write it as before. You will need to only change the $newVmList variable in the original script.

foreach($Name in $newVmList) {
     $taskTab[(New-VM -Name $Name -VMHost "prodh1.MYDOMAIN.local" -Template" W2K8R2SP1" -Datastore" IOMEGA" -OSCustomizationSpec "W2K8R2SP1" -Location "_Tobedeleted" -RunAsync).Id] = $Name
}

You will also need to insert the remaining part with the while loop and the customizations in your network!

http://www.lucd.info/2010/02/21/about-async-tasks-the-get-task-cmdlet-and-a-hash-table/

Concerning

Emanuel

Tags: VMware

Similar Questions

  • Deploy multiple virtual machines on several hosts evenly?

    Hello people!

    I wrote a small script to deploy many virtual machines on several hosts at random.

    But I would rather deploy a virtual machine to each host in a table and then start over again until the number of virtual machines to deploy exhausted.  Distribution of the burden of deployment as evenly as possible.

    Anyone have a suggestion?  Example of nested loops?

    PowerShell beginner, here.

    Thank you

    romatlo

    One way to do this is with the modulo operator (%), something like this

    $numVMs = 11

    $tgtEsx = get-Cluster "Westcreek | Get-VMHost-name z420 *.

    1.. $numVMs | %{

    [New-VM-name 'Test $($_)' $tgtEsx[$_%$tgtEsx.Count - VMHost]

    }

  • deploy multiple virtual machines using vmdk and SID file

    Hello

    Need to know if I am correct or miss me something... I deploy many virtual machines using method.

    1. remove the vmdk files a XP.

    2. create new folders and copy the vmdk into this folder.

    3. create virtual machines using existing vmdk files.

    4 rename the computer and join it to the domain.

    My question is, my VMDK files are an existing xp VM (no longer exist), what is the status of the deployed virtual machines? they still have the same SID or it is changed? I managed to join to the domain, but do not want surprises in the future.

    Note:

    I had another option, could have all these automated with new SID using PowerCLi, unfortunately, osCustomization has default, I can't event run the get-OsCustomization command, it keeps failing.

    Thank you.

    Yes, Windows writes the SID on disk (virtual disk for virtual machines) or physical disk for physical machines.  The guest operating system has no idea on the vmx file.

    Dave

    VMware communities user moderator

    Now available - vSphere Quick Start Guide

    You have a system or a PCI with VMDirectPath?  Submit your specifications to Officieux VMDirectPath HCL.

  • Deploy multiple virtual machines from one model to the help of customization of the OS and a text file for hostname and IP

    Hi all

    Not sure if this has already been answered, I did a search on the forums, but couldn't find an answer to what I'm looking for.

    I want to fully automate the deployment of multiple VMs of a model using a customization file, but also to retrieve the host names and IP addresses from a text file / spreadsheet.

    for example:

    I need to deploy a test environment of 30 virtual machines using the template file and customizing TestVM. I have a spreadsheet with the VM host names and IP addresses. The process now is to manually enter the host name and IP when the customization file invites to do while deploying them in each virtual machine. The customization file takes care of the rest (license key, admin password, add to the domain etc.) can I automate entry of the name of host and IP addresses in reading from a text file?

    Thanks in advance!

    Take a look on the deployment, customization and modification of virtual machines to a csv file

    There are many more examples of this community on the same subject,

  • Mount a file ISO in multiple virtual machines simultaneously.

    Hello

    I found I can mount the same ISO file to virtual CD 8 VM simultaneously, but failed with the ninth VM. Is there a limitation on this subject?

    Thank you.

    The ISO is mounted in a virtual machine running on an ESX ESXi host, a file lock is held on the ISO file. Each host for the file connection consumes a lock. There is a maximum of eight locks possible for a file residing on a VMFS 3 datastore. This limits the amount of hosts of virtual computers that can access a disk for a cluster of eight ESX/ESXi hosts. This restriction applies to the files of virtual disk (VMDK), ISO CD/DVD images, floppy disks or any other file.

  • Starting from multiple virtual machines simultaneously

    I've slowly been deployment of thin clients in my desktop using PCOIP and view 4.5.  Lately, I've noticed that when enough people begin their computer at the same time the connection to the server view will not respond until the first on that some computers are up and running.  Is there a setting somewhere, using the VSphere, which dictates the number of virtual machines or may start at the same time?

    Welcome to the forums.  There should be a maximum power of competitor on effective information under vCenter servers specification and the Advanced tab.   The default value is 5 if I'm not mistaken.

  • from multiple virtual machines simultaneously

    How can I put the start-vm cmdlet to enable me to launch 40 VMS with different names at the same time.

    I tried to do it this way

    I connect on the vcenter server and these VMs are spreadout between 6 different hosts in a cluster

    Start-VM - vm (vm-get-name sales *, salesams *, salessvr *, devsvrs *)

    What would be the best way to approach this task? any help is appreciated!

    Hello, Sith-

    Yes, it works like:

    Start-VM -VM (Get-VM -Name sales*, salesams*, salessvr*, devsvrs*) -RunAsync
    

    Otherwise, you could get the VMs and then redirect it to Start-VM with the same net result:

    Get-VM -Name sales*, salesams*, salessvr*, devsvrs* | Start-VM -RunAsync
    

    How to make them for you?

  • Controlling multiple virtual machines on multiple hosts?

    Hello

    My apologies for what will clearly be a newbish question because I just started using PowerCLI yesterday. I have 6 servers hosts with 10 virtual machines on each and every VM with a snapshot.

    I created a script for

    (1) connect to Host #1

    (2) to reset all 10 VMS to the snapshot (a)

    (3) power on all virtual machines (simultaneously)

    (4) connect to the host #2... Rinse and repeat at host #6.

    It takes a little more than 5 minutes. I'm sure that this process will speed up if I find the answers below:

    Two questions:

    There's a way to connect to all servers at the same time, so can I have step #3 works on all servers host 6.

    -Is it possible to have the step #2 run simultaneously on each host to save on time?

    Thank you very much!

    With the Connect-VIServer cmdlet, you can connect to several servers in vSphere.

    Only condition is that you can use the same credentials, or this UNIQUE authentication is implemented.

    When you switch to view "multiple" with the Set-PowerCLIConfiguration cmdlet, you can run cmdlets against all those servers at the same time.

    You can now do a 'Get - VM"which will return all the virtual machines on all connected servers vSphere.

  • Is it Possible to access only bypassed FC HBA to multiple virtual machines

    Hello

    I have a FC HBA on my 5.5 ESX. Server. It does not support the function of SR - IOV. Is it possible to access this FC HBA across multiple virtual machines?

    If possible, please provide as follows to go further.

    Kind regards

    Aashish

    It is not possible. The basic material underlying PCI specification does not have a single shared between several independent operating systems PCI device.

    SR - IOV solves by creating the virtual function peripheral PCI, but as you mentioned, that he can't stand not and first of all, ESXi supports that SR - IOV for Ethernet network devices and not for native FC HBA (excluded FCoE) functions.

  • GUI: how to run the same command on multiple virtual machines at the same time?

    Hello

    Suppose we have several operations on multiple virtual machines (for example as updated virtual hardware, install vmtools - but it could be something else of course...).

    I would avoid clicking on each virtual machine (especially when we have hundreds of different groups).  It is possible to select sort

    (they are not side by side) and perform on a particular operation on all selected both?

    Hello

    If you use vCenter 5.1 + you can also try to use marking and assign tags on the items in the inventory.

    VSphere 5.5 Documentation Center - apply a label to an object

    Search for items by this tag.

    If you want to use PowerCLI 5.5, you can also search the inventory by this tag.

    Get-VM-Tag which lists all the virtual machines with which

    Here are some links for getting started with vSphere PowerCLI

    Back to Basics: part 1 - installation PowerCLI | VMware PowerCLI Blog - Articles from VMware

    vSphere PowerCLI Documentation

  • Help for a demo: create multiple virtual machines

    Hello

    I am a beginner in vCO, I completed the installation and configuration with success and I started to create workflows, but I guess that I need help with an example that I started yesterday:

    I am creating several virtual machines at the same time, I mean all the user have to do is say how VMs, he wants to be created and the workflow must do the rest, but I don't know what is the best way to do so, in the present workflow in the library , find us only 'create simple VM' so I added a few scriptable tasks to this workflow, but still can't do what I want.

    Any solution plese? or a few best practices to perform this type of workflow? Maybe I missed a workflow can create multiple virtual machines with different names but the same configuration.

    Thanks in advance,

    This can help out you.

  • Deployment of virtual machine using VMware Orchestrator

    Hello

    Can you help me pls with deployment of virtual machine using VMware Orchestration?

    Thank you

    Rekha

    Hello, Rekha, welcome to vCO take a look at my blog to get an idea of how use vCO. Christophe & I (and a few guests) have posted some tutorials around doing things with Orchestrator. Particular interest to the subject of this thread would probably be this series into three parts:

    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

  • Stop/start multiple virtual machines with names created automatically

    Hi all

    in my test environment, I want to stop or start multiple virtual machines via the script.

    Their name is always like this:

    'vm-100-qa', 'vm-101-qa","vm-100-qa","vm-102-qa '...

    Now I would like to just stop every VM 'vm-140-QA' to 'vm-160-qa.

    I created a table "$a = 140.160", but I don't know how to implement this in a script 'Shutdown-VMGuest-comments '.... »

    Sorry for this stupid question. I am a beginner absolute powershell.

    Thank you very much in advance,

    Petrie

    You can do something like this

    140..160 | %{   Shutdown-VMGuest -VM "vm-$_-qa"}
    
  • 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.

  • What is the advantage to affect multiple virtual machines in a data store?

    Hello

    Quite a question stupid and basic, but I can't answer . What is the advantage of having multiple virtual machines in a store of VMFS data instead of having each VM in another VMFS data store? (eg. 3 VMs in 1 data store or 3 data warehouses and each virtual machine in one of them). I can only think about the ease of management for storage administrator because it creates only a single large LUN.

    Thank you

    By allowing multiple virtual machines in a data store, you can run more than 256 virtual machines in a DRS cluster.

    As a host has a limit of 256 scsi identification numbers, which means that it accesses no more than 255 LUNS shared. 1 scsi ID is used for local storage.

    In a DRS cluster as each host must be mapped to the same data warehouses to ensure that virtual machines can be moved on the cluster and run on any of the hosts.

    Now in my life as an architect VMware PSO I saw that a lot of virtual machines that require a single data store. The main reason to isolate a virtual machine on a data store must provide sufficient i/o performance. This can be achieved with other solutions than to isolate a virtual machine on a data store. Having a properly architected storage subsystem is crucial, vSphere can get out of a very large number of the IOPS / s. With technologies such as SIOC and DRS for storage, you can check that the virtual machines receive IO performance according to the needs.

Maybe you are looking for