PowerCLI script for the deployment of virtual machines via the model using customizations comments

Hello... I hope someone can give me a script that will do the following:

(1) provision VMs in vCenter template (I need 125 + VMs created in the next day or two)

(2) use the existing customizations of comments in vCenter

(3) let me enter data warehouses available to be created on the virtual machines.  Example: I want that VMs on warehouses of specific data as LUN2, LUN5, LUN6, LUN12, LUN1, etc...  However, the script must have the ability to know when a data store is near the threshold of capacity, say 90%, so it can use one of the other warehouses available, identified in the script... similar to storage profiles.  We still have to adopt profiles storage but plan to do so once upgraded us to v5.1 in the next month or two.  We hope that this will help us keep our replicated LUN more organized during the use of SRM and copy to remote groups, our team of storage's configuration on 3PAR.


Additional information: I will use 2 styles... Windows XP and Win7.  Their respective sizes are 40 and 60 GB due to all applications for stable DR.  Data warehouses are ea 500 GB.

Please let me know if additional information is necessary... Thank you!!!

Charles

No, unfortunately you cannot specify a folder like this.

You'll have to do a

$folder = get-file-name WinXP

New-VM-$folder file...

Remove the line of New - VM WhatIf switch if you really want to start creating virtual machines.

Tags: VMware

Similar Questions

  • PowerCLi script to check if 2 virtual machines are on the same host

    Hello

    I'm nubby on PowerCLI and I would like to help in the construction of a script.

    The script should check if two virtual machines (named test1 and test2) are running on the same host in a vCenter and send a notification (email), if they do.

    Something similar with affinity / anti-affinite DRS rules (but not through the DRS enabled on vCenter).  My focus is on the affinity. In case this happens, I need vMotion one of them on an another ESXi host(manually or automated).

    What I have done until now is the following:

    Get - VM | Select Name, @{N = 'Cluster'; {E = {Get-Cluster - VM $_}}, '

    @{N = "ESX host"; {E = {Get-VMHost - VM $_}}, '

    @{N = 'vCenter'; E={$_. "(ExtensionData.CLient.ServiceUrl.Split('/') [2]}}, '"

    @{N = "Datastore"; {E = {Get-Datastore - VM $_}} | `

    Export-Csv - NoTypeInformation C:\Scripts\file.csv

    That becomes all the VMS and export a CSV file information:

    NameClusterESX hostvCenterData store
    test2cluster_testESXi_test1vCenter_test1:443datastore1
    Test1cluster_testESXi_test1vCenter_test1:443datastore1
    For1.localcluster_testESXi_test1vCenter_test1:443datastore1
    VM1.localcluster_test2ESXi_test2vCenter_test1:443datastore1
    VM2.localcluster_test3ESXi_test3vCenter_test1:443datastore1
    VM31.localcluster_test3ESXi_test3vCenter_test1:443datastore1

    Thank you.

    Try like this.

    $tgtVM = "test1", "test2".

    Get-VM-name $tgtVM | Group-object - property VMHost | %{

    if($_.) County - gt 1) {}

    $vm = $_. Group | Get-Random

    $esx = $vm. VMHost

    $tgtEsx = get-Cluster - $vm VM | Get-VMHost | where {$_.} Name - not $esx. Name} | Get-Random

    Move-VM - $vm - Destination $tgtEsx VM - confirm: $false

    }

    }

  • 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,

  • Unable to join the domain using customization comments vCD

    I have vCloud Director installed and running.  I created a vApp and edited the properties to allow customization of comments and more everything works so far but the computer will not join the domain.  I tried to use organization customization, as well as customize the TIME after deployment.  As soon as the server ends with the customization and is powered, I can log in and join the domain manually without any problem, I can't get comments customization to do that for me.   Its a Windows 2008 R2 server.  I found this entry at the end of the journal to customize-comments on the server:

    run the command netsh interface ip set dns 12 xxx.xxx.xxx.xxx static (it has the correct address for my DNS server) =

    The command has been successfully run, the output of the command:

    The configured DNS server is incorrect or does not exist

    Any thoughts?

    It is a farily well known problem.  For a join of field works in vCloud Director, you must have on your DHCP subnet.  Many people make using the vShield edge device that is located on the network of the Org.  The sysprep process runs before tools VMware is running (which applies to the satic IP address to the client).  It's sort of a situation or hen that the guest has ip when in sysprep, so the easy solution to make it work is DHCP.  Conversely, people did it is in port, a lab post script custization in vCD Manager who entered the field after the sysprep is made completely and the guest it's static IP.  Frankly, it's something of the order of operations that is causing the problem.  We are looking at this for other clients, but at the moment, what your options are

    (1) add DHCP to the subnet by using your own server DHCP OR vShield Edge

    (2) add a PostScript of customization to join the domain, it can be inserted into the comments thus customizaion area.

    Hope this helps you stop banging their heads on the wall

  • Scripts for clone/create several virtual machines model.

    Hello

    In the past I used viMa with ghettoClone.sh to create one or more virtual machines based on a model - however are there any similar scripts that run on VMA which can also be used to do the same thing. Because scripts can stand up to ESXi 3.5U2 however used ESXi4

    So, I'm looking to see if there is anything similar, which can be used for ESXi4 with VMA?

    See you soon

    Absolutely must. At this point it is probably not something you want to do or need to do that cannot be done by one of your scripts.

  • Change the display for the class using customization

    Hi all

    In the classes of the OLM of Global catalog are displayed at all, I want to put a restriction on the classes on the basis of the training center. I added the center of training for classes using personalization (aded a point for it). No idea how to restrict the classes further? such as training center that is assigned to the admin can see only its course and not others?

    Hello

    It will be possible by adding dynamic where clauses of views but probably need some trial and error to check the pages where it is needed and the complexity of the requirement (example: 2 admins should see the same course but classes that belong to their centres only)

    In addition, another option could be to use admin groups (R12.1) to manage access even if I think it's only available until the course level and not at the class level.

  • Perl script for deploying a virtual machine template

    Am looking for a perl script for the deployment of the existing models on Vsphere virtual computer. So far, I got access to the virtual machine. I saw that there is a utility called new-vm on the powershell. I'm running a linux machine and therefore seeking an alternative to perl. Kindly give me pointers or help me with some documents.

    Thank you!

    Well, I managed to create a virtual machine from the template using the vmclone.pl script, which is part of the vmware sdk. But post creation that he's not leaving means VM State is off. I'll have to find a way to start the virtual machine as well.

  • I'm looking for a Script that can list all virtual machines with type of NIC E1000 via the output of the CSV file.

    Hi gurrus and LucD

    I'm looking for a Script that can list all virtual machines with type of NIC E1000 via the output of the CSV file.

    The script should search for information in a multiple Vcenter servers and multiple clusters and list all the VMs name, status (two powers on or off) with type card NETWORK Type E1000 only no other.

    Concerning

    Nauman

    Try like this

    $report = @)

    {foreach ($cluster Get-cluster)

    foreach ($rp in Get-ResourcePool-location $cluster) {}

    foreach ($vm in (Get-VM-location the $rp |)) Where {Get-NetworkAdapter - VM $_______ | where {$_.}} Type - eq "e1000"}})) {}

    $report += $vm. Select @{N = "VM"; E={$_. Name}},

    @{N = 'vCenter'; E={$_. Uid.Split('@') [1]. "Split(':') [0]}},"

    @{N = "Cluster"; E = {$cluster. Name}},

    @{N = "ResourcePool"; E = {$rp. Name}}

    }

    }

    }

    $report | Export Csv C:\temp\report.csv - NoTypeInformation - UseCulture

  • deployment of a virtual machine in a paralytic using the api

    Hello

    How to deploy a vm in to an existing paralytic using the vcloud director api? I see this:

    POST /vApp/ {identifier} / action/deployment

    But I how to simply deploy a virtual machine in a public catalog in this paralytic?

    Thanks - Oli

    I found what I was looking for here:

    http://pubs.VMware.com/VCD-51/topic/com.VMware.vCloud.API.doc_51/GUID-667B71BD-6F00-4223-9A12-3CCBE5D215AF.html

  • Unable to choose the host when you deploy a virtual machine template

    Good Morning-

    I feel that the answer to this is with myself; However, I would ask - I try to deploy a virtual machine model for test purposes and I want the virtual machine must be created on a specific host.  When I start the Wizard "deploy the virtual machine of model", I am only able to select the cluster and not a specific host.   Is it possible for me to be able to select the host to which the virtual machine will be deployed without disabling DRS?

    Thank you very much in advance for the help.

    Steve

    What happens if you right click on the host that you want to deploy on the virtual machine to and select deploy from model - but don't forget if you have a DRS activated with anything other that Manuel DRS will select the host on which the virtual machine starts on and it would not be that you deply to--

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

  • 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

  • PowerCLI Script to the report on the failed VM jobs

    I figured out how to report on the events of VM (get-vievent), but no has no stains of VM. If a snapshot of the virtual computer fails, sometimes it never connect the events of the VM, but lists an error on the display of tasks. We are trying to monitor the clichés failed since its part of our backup solution.

    I was looking for a way to report these tasks/failure of events in a daily report, or simply add to the daily report of amazing Alan Renouf that we use.

    does anyone have any suggestions? For an example, see the attached screenshots. See how, in the view tasks, you have mistakes, but in the view of events, there is no errors.

    Any help would be great. Thank you!

    Jeff

    PowerCLI Script to the report on the failed VM jobs

    I figured out how to report on the events of VM (get-vievent), but no has no stains of VM. If a snapshot of the virtual computer fails, sometimes it never connect the events of the VM, but lists an error on the display of tasks. We are trying to monitor the clichés failed since its part of our backup solution.

    I was looking for a way to report these tasks/failure of events in a daily report, or simply add to the daily report of amazing Alan Renouf that we use.

    does anyone have any suggestions? For an example, see the attached screenshots. See how, in the view tasks, you have mistakes, but in the view of events, there is no errors.

    Any help would be great. Thank you!

    Jeff

    Hi Jeff

    I had exactly the same need to identify stereotypes having failed and drilled until SDK and LucD suggestions (thank you) to encode the following lines:

    $vmlist = Get-VM |sort Name
    
    foreach ($guestname in $vmlist)
    {
        $hours = 48 # Number of hours back
          $tasknumber = 999          # Windowsize of the Task collector
    $taskMgr = Get-View TaskManager
    
    # Create hash table. Each entry is a create snapshot task
    $report = @{}
    
    $filter = New-Object VMware.Vim.TaskFilterSpec
    $filter.Time = New-Object VMware.Vim.TaskFilterSpecByTime
    $filter.Time.beginTime = (Get-Date).AddHours(-$hours)
    $filter.Time.timeType = "startedTime"
    
    $collectionImpl = Get-View ($taskMgr.CreateCollectorForTasks($filter))
    
    $dummy = $collectionImpl.RewindCollector
    $collection = $collectionImpl.ReadNextTasks($tasknumber)
    while($collection -ne $null){
    $collection | where {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.EntityName -eq $guestName} | %{
    if ($_.State -eq "Error") {
            write-host $_.EntityName
            write-host $_.StartTime
            write-host $_.State
            }
        else {
        }
    }
    $collection = $collectionImpl.ReadNextTasks($tasknumber)
    }
    $collectionImpl.DestroyCollector()
    
     }  
    

    This script displays the name of the virtual machines which met with an instant failure in the last 48 hours (a variable, you can change)

    This is just the beginning, because I want to count the shots failed and identify virtual computers that have more than 2 in 2 days

    Feel free to alter it at will.

    Enjoy

    Eric

  • 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.

  • customization error "Sysprep is not installed on the server of virtual center for the model you have selected.

    Hi all

    Need your help with customization of the script here is the steps I've done so far

    1.I have created a virtual machine with Windows XP Professional as the operating system installed VMware Tools / VMware view agent then I added the virtual machine to the domain and created a template called (winXPtemp)

    2. According to article http://www.VMware.com/support/VC/doc/c12prepcustomize.html#1030366 I downloaded the Q257813_w2k_spl_x86_en.exe and the same extract. I force my VC server find the path as mentioned in article

    C:\ [VirtualCenter_installation_directory]\resources\windows\sysprep\1.1 so copied the files extracted to the location C:\Program Files\VMware\Infrastructure\VirtualCenter Server\resources\windows

    3 then I copied and extracted the file \support\tools\deploy.cab on the windows 2003 CD and copied the sysprep files extracted to the following location on the VC Server

    C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep\xp

    4. After you have done that, I've created a script under customization script called "testsript".

    5 Note until now I have not created a pool of resources as requires it the deployment of only 4 VM on an ESX Server with script customization. The data store for the virtual machine is a 100 GB LUN from a 2050 of FAS of NetApp iSCSI

    6. now when I create an automatic pool when I select the script that I created in step 4, and then click then it gives me an error "Sysprep is not installed on the server of virtual center for the model you have selected. Sysprep on the server installation.

    Troubleshooting done by me:

    I have readded the VC Server Manager to view but it force worked

    Thanks in advance for your help

    Kind regards

    v

    If I remember correctly the location for XP should go to: C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep\xp

    For XP SP2 Sysprep files can be downloaded from the Microsoft site and are called

    Windows XP SP2 deployment tools

    The article you linked was VirtualCenter 1.x. Since you have given a version number of VirtualCenter I assumed it was 2.x or later.

    ----

  • 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]

    }

Maybe you are looking for

  • Changing Media Touch Inductive Panel settings? for U330

    Hello So yay I finally got my computer! Thanks Lenovo forums... I have an ideapad u330 and everytime I use the inductive sensitive touchscreen that controls my Media Player, it opens Windows Media Player. I want to use iTunes and tried to tinker with

  • HP mini 110 problem

    Can someone help me too? HP 110 Faulty password checking.Fatal Erroe... System stopped.CNU94567DQ

  • cant get anti virus program to turn it on in the windows Security Center

    I have windows vista and an alert pops up, saying: my antivirus program is disabled. I opened Security Center says AVG anti virus reports that it is turned off. I clicked on the button, and it didn't turn it on. another box pops up asking if I trust

  • Remote VPN

    We have several clients to manage thiere IT infrasturcutre, so far, we have access to the content of their infrastructure through RDP and then we access theire resources. Now, we decided to go to remote VPN, according to my knowledge, in the case of

  • Accidentally moved my file music Xbox; ramena; still does not see my music

    I accidentally moved my folder music Xbox on my Surface of the disk to my SD card.  Even if I moved the hierarchy of directories back to the right place, music Xbox sees more music that I had previously bought.  On ANY of my devices.  :( How can I fo