How to add a script to a virtual machine using vmwrae api?

Hello

I am trying to add a new disk to an existing VM (Linux).

To do this.


Now to use the new drive on a run a series of commands, like:

-format the drive

-mount the drive

-put this information to disk in the file/etc/fstab


My question is how we can automate this task without actually going inside the virtual machine?

This is precisely what my advice is intended to accomplish. There are many examples available online to use Invoke-VMScript to automate actions in a Linux VM.

http://www.Google.com/search?q=invoke-vmscript+examples

This was done from my Windows using PowerCLI workstation to a virtual machine running SLES:

PowerCLI C:\> Invoke-VMScript -vm $vm -HostCredential $hc -GuestCredential $gc -ScriptText "uptime"

ScriptOutput
---------------------------------------------------------------------------------------------------
 08:32:52 up 88 days,  7:27,  0 users,  load average: 0.00, 0.00, 0.00
|
---------------------------------------------------------------------------------------------------

Tags: VMware

Similar Questions

  • How to add several records of existing virtual machines

    Is it possible to add several drives in one shot to a virtual machine?

    I know it's possible with the new - vm cmdlet, and if I manually modify the virtual machine, I can add as much as I want.

    The cmdlet New-hard drive allows only 1 at a time, I can say.

    Any suggestions?

    You are right, that the cmdlet New - hard drive allows the addition of 1 HDD at the time.

    If you want to add several hard disks, you will need to use the ReconfigVM_Task method.

  • Create the new virtual machine using Java API vCloud

    Hi guys,.

    I am trying to create the new virtual machine in TIME, but I've stuck here. The API I'm using is vcloud-java-sdk - 1.0.jar.

    Could you please show me a code snippet how to do this?

    For now I do it like this:

    RecomposeVAppParamsType recomposeVAppParamsType = new RecomposeVAppParamsType();

    List the items < CompositionItemParamType > = recomposeVAppParamsType.getItem ();
    ReferenceType vappTemplateVMRef = new ReferenceType();

    // ??? seems that new reference to the new virtual machine should be here. But how to create this VM
    CompositionItemParamType compositionItemParamType = new CompositionItemParamType();
    compositionItemParamType.setSource (vappTemplateVMRef);

    Items.Add (compositionItemParamType);
    ReferenceType vAppRef is Vdc.getVdcByReference (vcloudClient, vdcRef) .getVappRefByName ("vApp_Websrv");.

    Vapp.getVappByReference (vcloudClient, vAppRef) .recomposeVapp (recomposeVAppParamsType);

    One day before I played with Web Services SDK, which is much easier to understand. I was able to create the vApp and VMs in vSphere. Is it possible to import machines virtual vSphere to vCloud? Should what API I use for this?

    Thank you

    Hello

    You cannot add a new empty virtual machine in a paralytic.

    Instead, you can add a virtual machine from an existing vapp, vapptemplate.

    To import a vsphere vm to vcloud.

    Import vsphere vm as VAPP in vcloud. VMWVimserver-> importVmAsVApp()

    The importation of vsphere vm, as vAppTemplate, in vcloud. VMWVimserver-> importVmAsVAppTemplate()

    See also the example of ImportVmAsvAppTemplate.java, which is part of the vcloudjavasdk group.

    Kind regards

    Rajesh Kamal.

  • How can I add a tag to a virtual machine?

    What is the best way to be part of an workflow add a label to a virtual machine? The closest I found is System.getModule("com.vmware.library.vc.customattribute").setOrCreateCustomField (), but given that the custom fields do not appear in the web client, I need a way to do the same with the tags in place.

    Unfortunately the vSphere API does not yet provide a way to create (vCenter) tags. The only way is to use the provided of the vCO powershell cmdlets.

  • How to get the configuration of the virtual machine, please give me some ideas

    How to get the configuration of the virtual machine, please give me some ideas

    Hello

    Take a look at

    For the General operations of VM

    https://docs.google.com/viewer?a=v&q=cache:F3tEld7LNv0J:communities.vmware.com/servlet/JiveServlet/downloadBody/11301-102-1-10681/GettingStartedGuide.pdf+accessing+virtual+machine+configuration+settings+,+vsphere+sdk&hl=en&gl=uk&pid=bl&srcid=ADGEESgXQlnYzxO10t-E1uHDiz3o1zBBt4ojDZDbzAmHPO3Odcl2HhLlbrSODQjtDPccHMBK7NZ3F_N6xEJqEl29ZD_l-ZUxgSzSirW6qO47dH-bR9E4mfivkf3Ip30jTbBMKQm-7rwR&sig=AHIEtbQaMKQ21DFCex0Wi6NQtHQmEvQvng

    For the settings advanced VM:

    http://blogs.VMware.com/vSphere/2012/03/Acessing-virtual-machine-advanced-settings.html

    Other general settings of the SDK:

    http://vSphere-land.com/vSphere-links/scripting-links-2.html

    Many tx

  • Problem with script to clone virtual machines

    Hello

    I created a script to clone virtual machines on a regular basis around a method posted by LucD and Simon Long here or on their blogs.

    Here is the part that does the actual work:

    $VM = get - VM $Machine.MasterVM
    # Send Email of departure
    .\startmail.ps1
    # Create new snapshot clone
    $CloneSnap = $VM | New-Snapshot - name "Instant Test" - Quiesce
    # Get the managed object display
    $VmView = $VM | Get-View
    # Get the managed folder object reference
    $CloneFolder = $VmView.parent
    # Construction specification clone
    $CloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec
    $CloneSpec.Snapshot = $VmView.Snapshot.CurrentSnapshot
    # Make the linked disc specification
    $CloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec
    $CloneSpec.Location.Datastore = (get-Datastore-name $Machine.BackupDS). Extensiondata.MoRef
    $CloneSpec.Location.Host = (get-vmhost-name $Machine.BackupHost). Extensiondata.MoRef
    $CloneSpec.Location.Transform = [Vmware.Vim.VirtualMachineRelocateTransformation]: sparse
    $CloneName = "$vm - BU - $date"
    # Create clone
    $vmView.CloneVM ($cloneFolder, $cloneName, $cloneSpec)
    # Write newly created VM to stdout as confirmation
    Get - VM $CloneName
    # Remove snapshot created for clone
    $Snap = get-Snapshot - VM (VM-Get-name $Machine.MasterVM)-name $CloneSnap | Remove-Snapshot - confirm: $False
    #Send full email
    .\endmail.ps1

    I want to use in an environment composed of 3 servers ESXi 4.0 with a local data store each. This works well in my test environment, but not in that productive.

    Here, I get this error:

    Exception, calling 'CloneVM' with '3' or the arguments: "it was not correct to specified parameters.
    Spec.Location.pool ".
    C:\script\vm-backup\backup.ps1:98 char: 18
    + $vmView.CloneVM < < < < ($cloneFolder, $cloneName, $cloneSpec)
    + CategoryInfo: NotSpecified: (:)) [], MethodInvocationException)
    + FullyQualifiedErrorId: DotNetMethodException

    In a comment on his blog, made Simon refers to an error in the data store, but it seems very well here.

    By comparing the values of the characteristics to those of my testbed everything looks good, too.

    Does anyone of you can tell me where to look for the problem?

    Thanks in advance

    Christian

    That's correct, 1 by Server default resource pool.

    You can do

    Get-ResourcePool-name resources-site (Get - VMHost - name MyEsx)

    to get the default pool for a specific ESX Server

    CAB, you add a line in your original script

    $CloneSpec.Location.Pool = (get-ResourcePool-name resources-site (Get - VMHost - name MyEsx)). Extensiondata.MoRef

    This should be the correct MoRef

    The message seems to indicate that the target VM already partially exist.

    Remove it before you run your script once again.

  • How to add all the tabs open as I used to?

    How to add all the tabs open as I used to?

    You can go to bookmark all tabs by right-clicking a tab, or use the hotkey Ctrl + Shift + D

  • How to check the file for the virtual machine size Esxi shell

    Anyone who can tell me how to check the file for the virtual machine size Esxi Shell. I tried this command-h ls but does not work.

    Have you checked "ls-lh', it will provide information as the attached screenshot." "

  • How to add the symbol for the brand to use?

    I saw how to add copyright and brand symbols, but anyone know how to add the symbol of the brand to use (SM)?

    Thank you.

    Mac OS > FInder > edit > special characters > type of service in the lower-right search

    Problem is many fonts do not have this, then you might want to set an exhibitor SM.

  • How to install an operating system on a virtual machine using the ISO file?

    Hello

    I use vmware workstation version 6. I have different kinds of opersting systems likeFedora, Ubuntu, Windows xp CD to install on my virtual machines using the CD-ROM drive.  . I want to know is possible to install a virtual machine via an ISO file?

    Thank you

    mypass

    Yes

    Click on "Menu" > "new" > "virtual machine".

    Click on "Customize."

    Select "next".

    Select "install-disk (iso)".

    Click 'Browse '.

    the rest is explained

    _________________________

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

  • Syntax to create a new virtual machine using vCLI

    I use few of ESX 3.5 servers and a server vCenter 2.5 in my lab. I installed vCLI in vCenter server. I would like to know the command to create a new virtual machine through the vCLI. Use of the below details to provide the syntax / command.

    • Name of VM - windows2003
    • CPU - 2
    • Memory - 2096 MB
    • Name of ESX - esxserver1
    • Storage - disk 30 GB C and 40 GB D drive (these two must be placed in a storage centralized. i.e., data store name is - "filer1.lun123"

    Expecting more details.

    Thank you

    Ganesh

    VCLI orders are mainly used for configurations of the host, although as part of the installation of vCLI, you get also vSphere SDK for utilities Perl - http://www.vmware.com/support/developer/viperltoolkit/viperl41/doc/vsperl_util_index.html that provide additional canned scripts, which allows you to create a single set of virtual machines using the vmcreate.pl script. There is an example on how to use a script

  • 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

  • Virtual MACHINE using GHS restore CD

    I'm new to VMware and I'm trying to implement a virtual machine using XP Home.  I created the virtual machine and I am trying to use the restaurant 3 CD to install the operating system.  The first CD works fine, but the second can not open the file .ghs.  When I try to open the .ghs file it shows same not she, but a .gho file is there, but does not work.

    Any suggestions?   I need to convert a .iso?  If so, how?

    Thank you.

    Theoretically, you can't use restore CD to configure a new virtual machine, because they are technically linked to the computer to which they belong.

    Because the virtual hardware for a virtual machine is completely different with the material belonging to the restore CD, I don't expect that it will work well. For the case, it works well, you could face activation problems, due to the completely different (virtual) hardware.

    You might need a copy of XP retail to do a clean install of XP.

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

  • 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

  • Screen burn in

    I got my nexus 6 for all 26hrs now. I have about 8 hours of screen time and I noticed a few small image burn. On a grey full screen, you can see the line where is the notification bar and the same where the keys to the software. Other than I'm in lov

  • &lt; Closed &gt; did not get the bike g xt1033 update

    We didn't get Lollipop was updated again in India even soak test... Please do something moto.in another country u provides this update in November, but in India na not u... Why...? Give a logical response of means. Thank you

  • coordinates the desktop icons

    The coordinates of the icons on the desktop in XP Pro. should be included in the registry somewhere.It may be in...HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Bags\1\Desktop\ItemPos1024x768 (1)But it's not as simple as I thought it would be.Do

  • OfficeJet 8610: Feeds on several pages

    What can I do to make this printer to feed properly?  When I try to print a file that contains several pages, it will print correctly for a few pages, then it will feed 2 or 3 pages slightly staggered.  When the file is a numbered series of sequentia

  • How to stop calendar reminders telephone win opening on vista desktop

    I need to stop a nag screen that appears. I have Vista on the desktop. Several months ago, I synced my Win smartphone for desktop Calendar. Since then, I got screens of occasional reminder with lists of items of the agenda of the phone, asking us to