PowerShell Script SCVMM to controller of VM virtual machine cloning

Dear experts,

I'm looking to automate creating a VM (VM cloning), but also looking to explicitly select the VLAN ID and push specific IP,.

Thanks in advance for your help/input

Thnaks

Mohammad Al-Masri

This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
*

Tags: Windows

Similar Questions

  • Windows 2 k 3 lack of SCSI controller after running virtual machine converter

    Hello

    After you convert a Windows 2 k 3 server making the VM P2V is now lack a SCSI controller for the virtual machine cannot start.

    What is the best way to solve this problem? I need to copy the drivers from the physical server?

    Thanks in advance,

    PM

    If the disk controller type see you in the settings of the virtual machine is IDE, check out http://kb.vmware.com/kb/1016192.

    Another option is to choose the type of controller in the converter, when it comes to hardware.

    André

  • What is the difference between a virtual machine cloning and v2v conversion to a virtual machine

    What is the difference between a virtual machine cloning and v2v conversion to a virtual machine

    Cloning process is to duplicate a VM. V2V is deploy vm on vsphere environment to another virtual machine format (example: the workstation, hyper-v).

  • Script to stop a list of virtual machines

    Hello world

    I'm working on an ESXi4 and I want to stop that all my virtual machines except one. So I try to write a script by changing a single witch stop all VMs.

    But it is difficult to do what I want and I'm not really good at the script .

    Please, someone has an idea, that write in this script?

    Kind regards

    Damien

    I think that an important question to ask since I think that many answers's on the "assumption" that you are using a licensed version (non-free) of ESXi, you're asking... sounds like you use a free version of ESXi, so not the API 'methods work like the use of vSphere SDK for Perl or PowerCLI.

    Please clarify this, if this is the case.

    I'll tell you it looks like you are using the free version, here's a script very simple which makes what you like, as if you need to extend the scope, you will need to modify it according to your needs and even once, you can use vimsh as a means of y to achieve.

    This script takes a list of exclusion (I hope that your VMS don't have spaces in their names, very bad practice) separated by a line break:

    for example

    ~ # cat exclude_list
    vm-1
    vm-4
    

    Let's say that there are 4 virtual machines running on an ESXi host: 1 vm, vm-2, 4 - vm and vm - 5 and you want to / stop all the virtual machines with the exception of those listed in the exclusion list.

    ~ # ./powerDownVM.sh exclude_list
    Issuing shutdown command to vm-2
            Unable to issue shutdown command, VM either does not have VMware Tools installed or someting else went wrong!
            Issuing hard power off to VM!
            Taking a nap for 10seconds
    
    vm-1 is excluded from power down!
    
    vm-4 is excluded from power down!
    
    Issuing shutdown command to vm-5
            Unable to issue shutdown command, VM either does not have VMware Tools installed or someting else went wrong!
            Issuing hard power off to VM!
            Taking a nap for 10seconds
    

    Attached is the script, make sure you set the correct permission on the script to run.

    For more information about vimsh and how it works, please take a look at these resources:

    http://engineering.UCSB.edu/~duonglt/VMware/#vmware_vimsh

    http://www.VI-Toolkit.com/wiki/index.php/Main_Page

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

    William Lam

    VMware vExpert 2009

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

    Twitter: @lamw

    repository scripts vGhetto

    Introduction to the vMA (tips/tricks)

    Getting started with vSphere SDK for Perl

    VMware Code Central - Scripts/code samples for developers and administrators

    150 VMware developer

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

  • PowerCLI svMotion VM script based on a list of virtual machines

    I seeks to svMotion the VM based on a spreadsheet file or txt (either will work for me) of a data to another store. I found simpler than do, but nothing that will import a csv or txt file and svmotion these virtual machines.

    Try changing the line 37 (in the original function) in this

    $NumvMotionTasks = (get-task |?) { ($_. PercentComplete - do 100)- and ($_.) Description-match 'Move')} | Measure - Object). County

  • excluding the hard drives in a virtual machine cloning

    Hello

    I want to clone a virtual machine that has multiple drives. The c: drive has OS (W2008R2) and is small enough, D:, E:, and F: are large (terabytes), and contain data. I need only the C: drive in the clone. Is it possible to exclude other readers during the cloning process? I clicked through the wizard, but it does not give me an option.

    Thank you

    Matthias

    I would use the VMware Converter Standalone where you have a choice of which drives to clone.  http://VMware.com/go/converter

  • Script of cli power consolidation for virtual machines

    We get a number of necessary groups every morning when entered in our test environments, someone knows the best way to configure a script to run in order to consolidate the vms who needed?

    I tried using the command below:

    to connect-viserver VCENTERSERVER

    Get - VM |

    Where-Object {$_.} Extensiondata.Runtime.ConsolidationNeeded} |

    {ForEach-Object

    $_. ExtensionData.ConsolidateVMDisks)

    }

    disconnect viserver VCENTERSERVER-confirm: $FALSE

    with a pointing to it--batch file

    C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe - PSConsoleFile "C:\Program Files (x 86) \VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "&"C:\Consolidation_Script\Consolidation_Script.ps1 ".

    I expected this, but still see consolidation: Burkina Faso / vms, can someone help to?

    May be that the script fails because of plug-in software component PowerCLI has not loaded. Try to add the line to your script (add it as the first line) and check if it works.

    Add-PSsnapin VMware.VimAutomation.Core

  • Looking for a Script to extract information for a virtual machine

    HiEvryone

    Looking for a Script pull information for a virtual of VC machine what operating system installed (2003, 32-bit or 64-bit, 2008 etc), vCPU and memory allocated and State. Output in CSV format.

    Thank you

    vmguy

    You mean something like this

    Get-VM |
    Select Name,NumCpu,MemoryMB,PowerState,@{N="OS";E={$_.Guest.OSFullName}} |
    Export-Csv "C:\report.csv" -NoTypeInformation -UseCulture
    
  • PortGroup change after a virtual machine cloning

    Hello there,

    hope someone can help me, find a solution to my problem: I want to change the PortGroup to a virtual computer after cloning a model.

    Thanks http://mighty-virtualization.blogspot.com I am able to get all the information I need. But I have no solution to try to change the PortGroup.

    My actions for the information:

    getPortGroupByNetworkName

    var dvGroups = VcPlugin.getAllDistributedVirtualPortgroups ();

    i in dvGroups
    {
    If (dvGroups [i] .name is NetworkName)
    {
    return dvGroups [i];
    }
    }

    getDistributedVirtualSwitchByPortGroup

    VGA var = VcPlugin.getAllDistributedVirtualPortgroups ();
    var DVS = new Array();

    i in VGA
    {
    DVS.push (dvPG [i].config.distributedVirtualSwitch);
    DVS.sort ();

    for (i = 0; i < DVS.length; i ++)
    {
    If (I! = 0)
    {
    While (DVS [i] is DVS [i-1])
    DVS.splice (i, 1);
    }
    }
    }

    (j in DVS)
    {
    (h in DVS [j] .portgroup)
    {
    If (.portgroup [j] [h] DVS is PortGroup)
    {
    return DVS [j];
    }
    }
    }

    My task scriptable workflow after completing the dvSwitch and the portGroup by networkname:

    var MinLastStatusChange = 2;
    var DateNow = new Date();
    var TempYear = DateNow.getFullYear ();
    var TempMonth = DateNow.getMonth ();
    var TempDay is DateNow.getDate () - MinLastStatusChange.;

    If (TempDay < = 0)
    {
    TempDay = TempDay + MinLastStatusChange;
    TempMonth = TempMonth - 1;
    }
    If (TempMonth < = 0)
    {
    TempMonth = TempMonth + 12;
    TempYear = TempYear - 1;
    }

    var DateTwoDaysAgo = new Date (DateNow.getFullYear (), TempMonth, TempDay, DateNow.getHours (), DateNow.getMinutes (), DateNow.getSeconds ());
    var PortSpecs = new VcDistributedVirtualSwitchPortCriteria();
    PortSpecs.connected = false;
    PortSpecs.portgroupKey = new Array (detectedPortGroup.key);

    System.log("------------------------------------------------------------------------------------------------");
    System.log ("-today:" + DateNow);
    System.log ("-two days ago:" + DateTwoDaysAgo);
    System.log("------------------------------------------------------------------------------------------------");
    System.log ("detected PortGroup Key:" + detectedPortGroup.key);
    System.log ("detected PortGroup Name:" + detectedPortGroup.name);

    System.log ("detected dvSwitch Name:" + detectedDvSwitch.name);
    System.log ("detected dvSwitch ID:" + detectedDvSwitch.id);
    System.log ("detected dvSwitch UUID:" + detectedDvSwitch.uuid);
    System.log("------------------------------------------------------------------------------------------------");

    Ports of the var = detectedDvSwitch.fetchDVPorts (PortSpecs);
    i in Ports
    {
    If (.lastStatusChange [i] Ports < = DateTwoDaysAgo)
    {
    var detectedPort = [i] Ports;
    break;
    }
    }
    System.log (' key Port detected: "+ detectedPort.key +" IS FREE"');
    System.log ("the State of the Port detected:" + detectedPort.state);
    System.log ("last Port State change detected:" + detectedPort.lastStatusChange);
    System.log("------------------------------------------------------------------------------------------------");

    var myVirtualDeviceConfigSpec = new VcVirtualDeviceConfigSpec();
    var myVirtualMachineConfigSpec = new VcVirtualMachineConfigSpec();
    var myVirtualDeviceArray = new Array();

    for (i = 0; i < vm.config.hardware.device.length; i ++)
    {
    If (System.GetModule("de.) (("WW - Informatik.Functions") .wwiIsNetworkCard (VM.config.hardware.Device [i]) == true)
    {
    Map var = vm.config.hardware.device [i];

    System.log ("NIC(Device"+ i +") found:"+ card ");

    System.log ("PRE port:" + networkCard.backing.port);
    System.log ("PRE portgroupKey:" + networkCard.backing.port.portgroupKey);
    System.log ("PRE Key:"+ networkCard.backing.port.portKey ");
    System.log ("PRE dvSwitch UUID:"+ networkCard.backing.port.switchUuid ");
    System.log("------------------------------------------------------------------------------------------------");

    TempBacking = System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualEthernetCardDvNetworkConfigSpec (detectedPortGroup);

    myVirtualDeviceConfigSpec = TempBacking;
    myVirtualDeviceConfigSpec.device = map;
    myVirtualDeviceConfigSpec.device.connectable.connected = true;
    myVirtualDeviceConfigSpec.device.connectable.startConnected = true;
    myVirtualDeviceConfigSpec.device.backing.port.portKey = detectedPort.key;
    myVirtualDeviceConfigSpec.device.backing.port.portgroupKey = detectedPortGroup.key;
    myVirtualDeviceConfigSpec.device.backing.port.switchUuid = detectedDvSwitch.uuid;
    myVirtualDeviceConfigSpec.operation = VcVirtualDeviceConfigSpecOperation.edit;
    myVirtualDeviceArray [0] = myVirtualDeviceConfigSpec;

    myVirtualMachineConfigSpec.deviceChange = myVirtualDeviceArray;

    task = vm.reconfigVM_Task (myVirtualMachineConfigSpec);

    System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd (task, false, 0);
    }
    }

    Maybe I did the steps wrong to change the portgroup but I tried a few things and this is my best solution, but it does not work.

    Hope you can help me.

    Best regards

    Chris

    Please try my package here http://communities.vmware.com/message/1731492#1731492 since you are targeting a GROUP of virtual ports distributed

  • Duplicate name after a virtual machine cloning

    We run ESX 3.5. After I cloned a cup of virtual XP Machines, all have the same host name and I get duplicate name message. How to avoid that?

    Bob Lee, MS - MVP, MCSE & CNE

    Networking, Internet, routing, VPN Troubleshooting

    http://www.ChicagoTech.NET

    Sysprep and models should take care of this.

    http://www.VMware.com/PDF/vc_2_templates_usage_best_practices_wp.PDF

  • Impossible to get 'notes' of the virtual machine

    I tried to use a powershell script to get information from the virtual machine. I can get VMHost, VMname and GuestVersion using the script in the following, but failed to get the notes of the virtual machine. Anyone know why I can't get notes, please help me with that. Thank you in advance.

    report = @)
    foreach ($vmView in (Get-View - ViewType VirtualMachine))
    {
    $report += $vmView. Select-Object @{Name = "$vmhost"; Expression = {($vmView.Runtime.Host Get-View).} Name}},
    @{Name = "VMName"; Expression = {$_.} Name}},
    @{Name = 'Notes'; Expression = {$_.} Description}},

    @{Name = "GuestVersion"; {Expression = {$vmView.Guest.GuestFullName}}
    }
    $report | Sort-Object VMName-descending | Export-Csv "d:\vm_GuestVersion.csv" - NoTypeInformation

    There is no need to do it with the cmdlet Get-View.

    You can do

    $report = @()foreach ($vm in Get-VM){    $report += $vm | `        Select-Object @{Name="VMHost"; Expression={($_.Host).Name}},            @{Name="VMName"; Expression={$_.Name}},            @{Name="Notes"; Expression={$_.Description}},            @{Name="GuestVersion"; Expression={$_.Guest.OSFullName}}}$report | Sort-Object VMName -Descending | Export-Csv "d:\vm_GuestVersion.csv" -NoTypeInformation
    

    If you want to do with the cmdlet Get-View for any reason, you can do

    $report = @()
    foreach ($vmView in (Get-View -ViewType VirtualMachine))
    {
        $report += $vmView | `        Select-Object @{Name="VMHost"; Expression={(Get-View $vmView.Runtime.Host).Name}},
                @{Name="VMName"; Expression={$_.Name}},
                @{Name="Notes"; Expression={$_.Config.Annotation}},
                @{Name="GuestVersion"; Expression={$vmView.Guest.GuestFullName}}
    }
    $report | Sort-Object VMName -Descending | Export-Csv "d:\vm_GuestVersion.csv" -NoTypeInformation
    

    But note that as you need a view of the GET each time for the host name, performance will suffer.

  • How to change network name for all virtual machines within the same cluster

    We have recently changed name vswitch to take into account that something significant, in the past vCenter could change the labels of networh for all virtual machines... seems this time help labels are not changed (maybe its got something to do with the update vcenter for 2.5.U3)...

    in any case, someone at - it a powershell script that could find all the virtual machines that are referring to the old label network and then changing again the name... ?

    Enjoy the respponses...

    Thanks in advance

    A few things on this blog could help.

    If you know the names you want to use, you could also just use something like:

    Get-Cluster X | Get-VM | Get-NetworkAdapter | Where { $_.NetworkName -eq "OldNetwork" } | Set-NetworkAdapter -NetworkName "NewNetwork" -confirm:$false
    Get-Cluster X | Get-VM | Get-NetworkAdapter | Where { $_.NetworkName -eq "NewNetwork" } | Set-NetworkAdapter -Connected:$true -confirm:$false
    
  • Script for a specific virtual machine vmotion

    I play a few trials of benchmarking on VMS 2. part of the test is to migrate a virtual computer when certain I/O points are reached. I wrote a simple script for vmotion one of these virtual machines:

    $vm = get-VM-name Bench_VM | Get-View

    $chost = $vm. $host.name

    If ($chost = ESX01.company.com)

    {

    Move-VM VM - Bench_VM - Destination ESX02.company.com

    }

    on the other

    {

    Move-VM VM - Bench_VM - Destination ESX01.company.com

    }

    I get an error:

    The term 'ESX01.company.com' is not recognized as the name of a cmdlet, function, script file, or an executable program. Check the spelling of the name, or if a path has been included, make sure the path is correct, and then try again.

    What I am doing wrong?

    Thank you

    There are 2 problems with your script.

    (1) you can't get hostname like this

    (2) comparison of PowerShell uses the operator - eq.

    This should work better

    $vm = Get-VM -Name Bench_VM
    $chost = ($vm | Get-VMHost).Name
    if ($chost -eq "ESX01.company.com")
    {
         Move-VM -VM Bench_VM -Destination ESX02.company.com
    }
    else
    {
         Move-VM -VM Bench_VM -Destination ESX01.company.com
    }
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • The list of all names of virtual machines that are attached to the computer with script group

    I need a script that would list all the virtual machines names that are attached to the Machine group as the bellows screenshot:

    vcm.jpg


    Ce can be in any language I just need to get this information.

    I tried to Watch in database and found vm names of in table [ecm_dat_machines] and Group of/ids in names of table [ecm_sysdat_machine_groups] but I don't find table that would be assign vm to the Group.

    I serait appreciate any help or clue as I already spent a lot of time on this task.

    Attached file of import/export includes a view created for the SQL below, as well as a SQL report that uses this perspective to the computers by group in the VCM UI.

    Note that the functions used in the join of the query criteria are there to ensure that only valid/active/license machines are displayed, these date data and time are adjusted to the time zone of the user, and that the users do not see that their role does not have access to groups of computers.

    SELECT

    m.machine_name,

    mg.machine_group_name,

    mg.machine_group_desc,

    DATEADD (mi, utc.utc_offset, m.date_last_contact) as date_last_contact

    OF dbo.ecm_dat_machine_group_machines_xref mgx

    JOIN dbo.ecm_dat_machines m

    ON mgx.machine_id = m.machine_id

    Join dbo.ecm_dat_machine_groups mg

    ON mgx.machine_group_id = mg.machine_group_id

    JOIN dbo.ecm_dat_roles_machine_group_xref rmx

    ON mgx.machine_group_id = rmx.machine_group_id

    AND rmx.role_id = dbo.role_current)

    JOIN dbo.ecm_fn_machines_valid_t (vm)

    ON mgx.machine_id = vm.machine_id

    JOIN dbo.ecm_user_utc_offset (utc)

    1 = 1

  • Script to create virtual machines fails when you try to add the disk to the cluster data store

    Hello

    Attached is the script that I used to create virtual machines and it works very well when virtual machines are created to warehouses of unique data, but do not have clustered data warehouses. I think that the reason is that it creates the virtual machine through the esx host (who does not know the cluter) and not via vCenter (who knows about it). Unfortunately I do not know how to fix.

    Thank you

    Astra

    Looks like he needs a store of data for this parameter object. So we need to do a get Datastore cluster I can try to test tomorrow, but try this:

    If ($datastore1 - only 'none') {}

    $drscluster = get-DatastoreCluster $datastore1

    $vmadddsk = new-disk-hard - VM $gstname CapacityKB - $datastore1size - data $drscluster store

    }

Maybe you are looking for

  • Question Airport Express.

    I'm so confused. I'll try to keep a long story short. I lost my internet connection a few weeks ago, and instead blame Mediacom, I blamed my old airport of 12 years and I bought a new Airport Express Terminal (with a new ethernet cable to replace a a

  • Hello! Where can I quote a small (11 FF on mac OS 10.6) bug + fix?

    Hello!First of all, thank you all very much for... Firefox And now, the point... On 11 FF (International), if you, like I did, on drupal 6 "subtopic", a CSS integrate property 'border-radius', it's not... only with mac 10.6, 11 FF.Linux and W7 seemed

  • Get the hDC for a Canvas control

    Hello I have a DLL that takes a hDC parameter, which is then 'draw' something using Windows API. An example of this can be the function WinSDK TextOut (HDC hdc int nXStart int nYStart LPCTSTR lpString int cbString). How could I get the hDC to a Canva

  • Can not turn Security Center on, error 0 x 80070424

    I can not turn on Security Center; I get the Ox80070424 error message.  How can I solve this problem?

  • How can I move a compressed file (zipped) on my memory stick?

    I can download a "e-book" from loc.gov.  It is sent compressed (zipped). How "decompress this file? How can I move the "file unzipped on my memory stick? Any help will be greatly appreciated!