Adding a property to a virtual machine

Hello, I would like to add a property to a VM in vCAC with vCO so far, I use the code below with the virtualMachine entries, propertyName, propertyValue

= "ManagementModelEntities.svc"; var model

entitySet var = "VirtualMachineProperties";

var found = false;

Var properties = new Properties ();

Properties.put ("VirtualMachineID", virtualMachine.virtualMachineID);

var virtualMachineEntity = vCACEntityManager.readModelEntity (host.id, model properties, "VirtualMachineProperties", null);

Find the name of the property by property

var virtualMachinePropertiesEntities = virtualMachineEntity.getLink (host, entitySet);

for each {(var virtualMachinePropertiesEntity in virtualMachinePropertiesEntities)

If (virtualMachinePropertiesEntity.getProperty ("PropertyName") == propertyName) {}

found = true;

break;

}

}

Var properties = new Properties ();

Properties.put ("PropertyName", propertyName);

Properties.put ("PropertyValue", propertyValue);

Properties.put ("IsHidden", propertyIsHidden);

Properties.put ("IsRuntime", propertyIsRuntime);

Properties.put ("IsEncrypted", propertyIsEncrypted);

Var links = new Properties ();

Links.put ("VirtualMachine", virtualMachineEntity);

If (found == true) {}

If (doNotUpdate == false & & propertyValue! = "") {}

entityKey var = virtualMachinePropertiesEntity.entityKey;

var entityKeyId = entityKey.get ("Id");

System.log ("Update entity Id" + entityKeyId + "with the property" + propertyName + ":" + propertyValue + "on the virtualMachine entity" + blueprint.displayName);

}

else {}

If (doNotUpdate == true) System.log ("doNotUpdate set to true - update not no property"+ propertyName);

If (propertyValue == ' ') System.log ("no update of the property" + propertyName + "with a value of empty");

}

}

else {}

System.log ("Create property" + propertyName + ":" + propertyValue + "on the virtualMachine entity" + blueprint.displayName);

}

I get away to an exception error any help would be apprciated

You can use a built-in action to deal with what is addUpdatePropertyFromVirtualMachineEntity in com.vmware.library.vcac

Tags: VMware

Similar Questions

  • Adding multiple RDMs to a virtual machine

    Hello community... we do a lot of fun virtual project of the SQL cluster, running on ESXi 5.0. Without going too much into the details of design, I'm looking to try to generate scripts, adding a bunch of RDM (45ish) for a virtual machine. The RDM were presented to the guests, so the next step is to add the ROW appropriate to the virtual machine in the right order.  Here is a partial list of the available RDM:

    lunlist.png

    Based on our design, I know that 46 LUN must go in SCSI 1:1, 47 LUN must go to SCSI 2:1, 48 LUN must go to SCSI 3:1, and so on. I have a worksheet that has a correlation between LUN ID and SCSI ID required.  I can also manually add 1:0, 2:0, 3:0 for created controllers. What I would do is script the rest.

    I saw a number of scripts, and I don't quite see what I need.  To begin with, how can I specify LUN ID?  From there the questions keep coming. Any ideas/suggestions?  Thank you!

    The error is because there are 2 controllers returned (the same one twice).

    If you have 2 connections open vSphere? Make one

    Global $: defaultviservers

    If there is more than 1 entry displayed, you should check if you are in multi mode. Make one

    Get-PowerCLIConfiguration

    scopes 1 says "multiple"?

    If so, cut 1 vSphere connections. For example, by

    Disconnect-ViServer-Server $global: defaultviservers [0] - confirm: $false

    Then check if the SCSI controller Get returns only 1 object.

  • Cannot start a virtual machine with more than 1 CPU socket added

    I've set up a few boxes of ESXi 5.5 with the free license in recent weeks, they have all been without problems so far. All 4 servers have the same exact hardware

    Environment:

    Dell Poweredge T620

    E5-2630 2 Intel CPU

    40 GB OF DDR3 ECC RAM

    ESXi is installed on 2 x 146 GB 15 K SAS drives RAID-1

    Data for virtual machines store are 8 x 600 GB 10 K SAS RAID-10 disc

    Guest operating system is Server2012r2 on all virtual machines

    Installed it on ESXi 3 previous were conducted with custom ESXi 5.5 Dell without problem.

    The 4th is where I will have questions. I used the following ESXi installed just in case there is a bug somewhere

    5.5 of VMware ESXi

    ESXi 5.5 customized by Dell

    5.5 U1 of VMware ESXi

    Any version of the ESXi I use I can't have a virtual machine to begin with more than 1 CPU socket added to it. The virtual machine does not start even the VMWare BIOS. I tried the Bios EFI as well with no luck. The error message I get in the events is ' fatal error VMware ESX: vcpu (vcpu-X)-X:VM - entry failed; Valid VMCS (error code 8). The vcpu-X is always another. I have attached the log file is created. If I give the VM 1 single processor TI starts very well. I'm at a loss as to what could be the issue.

    Problem is solved. I caught another server with identical hardware, verified it worked properly, then started to swap parts between them. Turned out to be CPU1. Once this has been replaced from a working server I have not had any problems. Warranty has been appealed.

    Thanks for all the help!

  • How to list virtual machines with associated vmdk files

    Hello.

    I have a folder vmfs and file vmdk with names that aren't like any virtual machine name (probably because that rename the virtual computer name).

    How can I find what VM is?

    Thank you

    Hello, biokovo-

    You can use the standard Get - VM and hard to find names of VMDK VMs-associated cmdlets Get-disc.  Or another, much more quickly elsewhere, would be to use everyone's favorite: Get-View.

    Since you know the path of the data store for the VMDK, you can check the property LayoutEx of virtual machines to find the virtual machine that said the file property with the name of the value as the games way to store data, as:

    $strVmdkDatastorePath = "[mydatastore] somefolder/somefile.vmdk"Get-View -ViewType VirtualMachine -Property Name,LayoutEx.File | ?{$_.LayoutEx.File | ?{$_.Name -eq $strVmdkDatastorePath}} | select name
    

    Where the path of the data store's format, "[datastoreName] folder/somefile.vmdk.  Yes, including the square brackets around the name of the data store and a space after the "]" (before the first character of the name of the folder).

    How does do for you?  (must be straight fast)

  • New virtual machine for the model with the specific name

    Hello

    I'm trying to add some model VM to VAPP using recomposeVApp (...). And it works well except that I can not change the name of the virtual machine while recomposing. It takes the name of the model. But how to add VMS to model with the specific name? I use the v1.0 API.

    This is my code:

    ReferenceType vmTemplateRef = new ReferenceType();
    vmTemplateRef.setName ("MyNewVM"); This name is ignored. The name of the model is taken!
    vmTemplateRef.setHref (vmRef.getHref ()); reference to the model

    CompositionItemParamType vmItem = new CompositionItemParamType();
    vmItem.setSource (vmTemplateRef);

    create the type params VAPP recompose.
    RecomposeVAppParamsType recomposeVAppParamsType = new RecomposeVAppParamsType();
    recomposeVAppParamsType.setName (vAppRef.getName ()); The name of vApp. It is ok.

    added the element of the virtual machine.
    The newItems < CompositionItemParamType > recomposeVAppParamsType = list
    . getItem().
    newItems.add (vmItem);

    Task task = vapp.recomposeVapp (recomposeVAppParamsType);

    Thank you

    Hello

    For after this code fragment:

    vmTemplateRef.setName ("MyNewVM"); This name is ignored. The name of the model is taken!

    The model name is ignored because vmTemplateRef is the only reference to the object that will be used for the operation of recomposition. If changing the name it will be always ignored.

    I think that changing the name of the virtual machine template for recompose cannot be done as follows:

    (1) operation recomposeVApp().

    (2) get the recomposed VAPP

    (3) download the children-> VM you want to change.

    (4) change the name of the virtual computer.

    I hope this helps!

  • Folder path as a VM property - for virtual machines in a paralytic

    Hello

    I used the new-viproperty of LucD script to create a folder for each virtual computer property in my inventory. It works perfectly well for virtual machines, but not for virtual machines in a paralytic as these do not have a 'record' in powercli property. they report a $null value.

    Would be much appreciated if someone can help me to modify this script so it creates a VM property for the VMS and VMs in a paralytic?

    http://www.lucd.info/2012/05/18/folder-by-path/

    01

    02

    03

    04

    05

    06

    07

    08

    09

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    New-VIProperty-Name'BlueFolderPath' -ObjectType 'VirtualMachine'-Value{

        param($vm)

        functionGet-ParentName{

            param($object)

            if($object.Folder){

                $blue= Get-ParentName$object.Folder

                $name= $object.Folder.Name

            }

            elseif($object.Parent -and$object.Parent.GetType().Name -like"Folder*"){

                $blue= Get-ParentName$object.Parent

                $name= $object.Parent.Name

            }

            elseif($object.ParentFolder){

                $blue= Get-ParentName$object.ParentFolder

                $name= $object.ParentFolder.Name

            }

            if("vm","Datacenters"-notcontains$name){

                $blue+ "/"+ $name

            }

            else{

                $blue

            }

        }

        (Get-ParentName$vm).Remove(0,1)

    }-Force| Out-Null

    Check if the new version works for you.

    New-VIProperty-name 'BlueFolderPath' - 'VirtualMachine' - value {ObjectType

    Param ($VM)

    Function Get-ParentName}

    Param ($Object)

    if($Object.) {Folder)

    $blue = get-ParentName $object. Folder

    $name = $object. Folder.Name

    }

    ElseIf($Object.) VApp) {}

    $blue = get-ParentName $object. VApp.ExtensionData.ParentFolder

    $name = $object. VApp.Name

    }

    ElseIf ($object - is [VMware.Vim.ManagedObjectReference]) {}

    $folder = get-VIObjectByVIView - MORef $object

    $blue = get-ParentName $folder. Parent

    $name = $folder. Name

    }

    ElseIf($Object.) Parent - and $object. Parent.GetType (). Name - as a ' file * ') {}

    $blue = get-ParentName $object. Parent

    $name = $object. Parent.Name

    }

    ElseIf($Object.) ParentFolder) {}

    $blue = get-ParentName $object. ParentFolder

    $name = $object. ParentFolder.Name

    }

    If ("vm", "Data centers" - notcontains $name) {}

    $blue + "/" + $name

    }

    else {}

    $blue

    }

    }

    (Get-ParentName $vm). Remove (0.1)

    } - Force | Out-Null

  • Find a property-based Virtual Machines

    Hello

    What I want to do is to find a set of system VMs in vCAC and based on the value of the property I want to perform an action on them so far that's what I have, but keep o get an error.  Any help would be great!

    If (host == null) {}
    System.log ("no host has been defined");
    }
    get host Virtual Machines
    var virtualMachines = Server.findAllForType ("vCAC:VirtualMachine");

    for each {(virtualMachine var in virtualMachines)
    If (virtualMachine.isManaged == true) System.log ("found Virtual Machine" + "" + virtualMachine);
    Var properties = new Properties ();
    Properties.put ("VirtualMachineID", virtualMachine.virtualMachineID);
    var virtualMachineEntity = vCACEntityManager.readModelEntity (host.id, "ManagementModelEntities.svc", "VirtualMachines", properties, null);

    var virtualMachinePropertiesEntities = virtualMachineEntity.getLink (host, "VirtualMachineProperties");
    for each {(var virtualMachinePropertiesEntity in virtualMachinePropertiesEntities)
    If (virtualMachinePropertiesEntity.getProperty ("PropertyName") == propertyName) {}
    }
    }

    }

    Instead of trying to find machines find properties, you can find the properties to find the machine.  VCAC custom properties are themselves entities like Virtual Machines:

    vmPropsProperties = new Properties ();

    vmPropsProperties.put ("PropertyName", property_name);

    modelName = "ManagementModelEntities.svc"; var

    entitySetName var = "VirtualMachineProperties";

    var propertyEntities = vCACEntityManager.readModelEntitiesByCustomFilter (vcacHost.id, modelName, entitySetName, vmPropsProperties, null);

    var virtualMachineEntities = new Array();

    for each {(var propertyEntity in propertyEntities)

    var propertyEntity.getProperty ("PropertyValue") = propertyValue;

    If (propertyValue == desiredValue) {}

    virtualMachineEntities.push (propertyEntity.getLink (vcacHost, "VirtualMachine") [0]);

    }

    }

  • Creating a property for a Total of your virtual machines

    How can I create a custom property to the total number of virtual machines in my report, such as:

    Get - vm | Select the name,

    @{N = "TotalVMs"; E = {TotalTheNumberOfVMs}}

    Thank you!

    Something like that

    $vms = Get-VM$vms | select name,  @{N="TotalVMs";E={$vms.Count}} 
    

    Note that this simplistics rather than he doesn't face not VMs returned.

  • define an id scsi for a disc newly added for virtual machines via script

    Hi Experts,

    I used the script below to add disks to several virtual machines
    http://blog.mattvogt.NET/2013/03/14/PowerCLI-mass-add-hard-disks/

    But currently our requirement for change as if we must add 3 2 GB drives, the disks must the controller use SCSI (1:0) - (1:2)

    And next bunch of disks, for example, should use use SCSI (2:0) - (2:2).

    Y at - it an option to set the SCSI ID when adding new disks.
    Please let me know if there is nothing we can achieve through scripts.

    Thanks in advance.

    Kind regards
    Sourav

    Try this new version, it works for me in my test environment

    ### Get VM/Disk Count/Datastore information ### $vmname = Read-Host "VM Name to add disks to"$num_disks = Read-Host "number of disks to add"$ds = "Oracle DB Farm Datastore Group"$format = Read-Host "Disk Format (thin, thick, EagerZeroedThick)"$size = Read-Host "Disk Size (GB)"
    
    $vm = Get-VM $vmname$datastore = Get-DatastoreCluster -Name $ds
    
    ### Add $num_disks to VM1..$num_disks | %{  Write-Host "Adding disk $_ size $size GB and format $format to $($vm.Name) on datastore $datastore"
    
      if($_ -eq 1){      $hd = New-HardDisk -vm $vm -CapacityGB $size -Datastore $datastore -StorageFormat $format      $hd = Get-HardDisk -VM $vm | Where {$_.ExtensionData.Backing.UUid -eq $hd.ExtensionData.Backing.Uuid}      $ctrl = New-ScsiController -Type Paravirtual -HardDisk $hd  }  else{      $hd = New-HardDisk -vm $vm -CapacityGB $size -Datastore $datastore -StorageFormat $format -Controller $ctrl    $hd = Get-HardDisk -VM $vm | Where {$_.ExtensionData.Backing.UUid -eq $hd.ExtensionData.Backing.Uuid}  }}
    
  • Unable to connect to the virtual machine after adding new eSATA drive

    Hello.

    I'm trying to connect my new 2 TB drive in VMWare Workstation. It is connected via eSATA to the host computer, and it works. I added the drive to the desktop as a new "physical disk." But now I can not power the workstation the most.

    (1) when I start the VMWare Workstation it right ask admin (it didn't need before).

    (2) when I turn on the prompt does not charge even the bios. It shows a rear screen with the logo of VMWare for a while and then stop saying: "VMware Workstation cannot connect to the virtual machine. Make sure that you have the rights to run the program and access all directories that it uses and access rights to all directories for temporary files. »

    The host is running Windows 7 x 64. The workstation runs under the standard user account.

    Thank you.

    Hmmm - it's unexpected - works for me here - only difference: I tried with only 1 TB disks.

    You start Workstatiion as an administrator?

    _________________________

    VMX-settings- WS FAQ -[MOAcd | http://sanbarrow.com/moa241.html]- VMDK-manual

  • New virtual machine not added the domain

    Hello

    I use workflow 'Request new VM' by default provided by prchestrator platform, but newly developed VM thr' this workflow is not added on the field that I select during placement workflow execution. However, once the virtual machine is created I can manually connect to it and add it to the field. Any reason, why it does not work when the virtual machine is configured? Apart from the configuration of the settings field and network with the infrastructure, is there anything else I need to do? Once this virtual machine as added on a network, I also want to add some users as local administrators on this virtual machine, I couldn't find any way to do thr' orchestrator, can be done thr' orchestrator?

    What happens if you deploy a model via VCenter virtual computer

    All I can think is:

    Check your model costumiztion of misspellings

    The format of username and password specified is also:

    Domainname\username

    password

    Concerning

    If you find this or any other answer useful please consider giving points by checking the answer useful or appropriate. Thank you.

  • Adding the OS to a new Virtual Machine

    Hello

    I am trying to add another data store that would simply be a mapped, drive so I chose "Network File System"... I specify the server by its ip address, the shared folder is a windows mapped drive... example is/flights/vol0/datastore-001... .this who do I enter to simply add the windows share drive because it is where is my iso and where I put the cd to boot from to start the generation of the image...

    The method that you use is for adding a NFS data store - you cannot use a standard Windows sharing as a data store.

    On the contrary - power on the VM - then select the option to connect CD/DVD (it's a menu option) - select ISO on Windows sharing and virtual computer must be able to access - obviously you will need to be sure to only select the CD drive to boot from the boot order.

    If you want the iso on the data store - you can download the ISO using the datastore browser - but to use a separate data for housing iso media store, models etc. If you choose to do, then you can plug the iso in the virtual machine settings.

    Post edited by: java_cat33 - line added referring to download the iso file on datastore etc.

  • Adding a virtual machine that has been previously saved

    Hello. I backed up a virtual machine that was running in an ESX (ESX n ° 1) and transfer all of its files in an a different ESX (ESX No. 2) data store. How should I add this VM in the new ESX (ESX No. 2)? I'm not using vCenter, I connect directly to the ESX Server via vSphere Client.

    The only way I found to do this is to create a new virtual machine in ESX No. 2, and when I add the new hard drive, I select the old VM hard. But this process is not so clean. For example, I read that if I used vCenter I'd be able to disconnect the server ESX n ° 2 of my datacenter and plug it back again, and when I do he added all the virtual machines that are within its data store automatically. The problem, as I said, is that I'm not using vCenter.

    Thanks in advance.

    Warlock.

    Once you access the data store and find the files, you can simply right click on the VMX file and select "Add to inventory."  This will allow you to add the virtual machine to your host without manually creating a new virtual machine and pointing to the existing VMDK file.

  • Library of Virtual Machine in fusion 2.0.5 is adding false entries

    Hello:

    I'm under Fusion 2.0.5 on a Mac Pro using another (dedicated) disc for my partition Bootcamp taking into my Windows 7 disc.  A few times when I start VMware Fusion library Virtual Machine adds a second 'fake' entry labeled as Partition Boot Camp for a XP Pro.  I didn't create it and all the right click menu choices are available except "Delete" when I tried to start it (false entry) to see what will happen, it is clear that it is not fully implemented yet because the VMware Mac OS ask me my password perform additional processing to implement the system VM on my Boot Camp Partition.  I do not give my password software and the implementation of treatment plants.

    In addition to my first entry (unique, original, real) in the library Virtual Machine is a Vista x 64 edition that points to my Boot Camp (on a dedicated disk) partition with my Windows 7 system. When I right click on my (the) real library Virtual Machine 'Start up invited' and 'Settings' are grayed out.  Now, I have to go to the Bar Menu of Mac OS to boot my VMware system on the window-"& gt; The Boot Camp partition option".

    Any thoughts why:

    (1) VMware Fusion 2.0.5 is adding unwanted entries / fake Virtual Machine library?

    (2) how to remove false entries (delete is gray)?

    (3) how to retrieve entries from the right click menu 'greyed - out' on my real library of Virtual Machine entry for my Bootcamp Partition based Windows 7 system?

    Take a look on: Re: New Boot Camp entry Every Reboot?

  • Maximum amount of disks that can be added to a virtual machine?

    Hello

    We are DPM configuration and we need a huge pool of disks and our EVA system allows us only to created a maximum of 2 TB LUN.

    Now, we are at the point were we only had SCSI ID 0:15 left to add a disk.

    What is the limitation of adding disks of virtual machines?

    Thank you

    Erik

    60 is the maximum: 4 * 15 devices SCSI

    SCSI controllers per virtual machine 4

    Devices per SCSI 15 controller

    Devices per virtual machine (Windows) 60

    Devices per virtual machine (Linux) 60

    http://www.VMware.com/PDF/vi3_35/esx_3/r35u2/vi3_35_25_u2_config_max.PDF

    If you found this information useful, please consider awarding points to 'Correct' or 'useful '. Thank you!

Maybe you are looking for