automated on a virtual machine

Sometimes, my vm locks and goes in OFF power... so I have to turn on the virtual machine and all goes well.

I installed vsphere powercli to automate this operation, I need a script that resembles the virtual machine and if it finds the virtual machine in the turning off the power on the virtual machine.

the problem is that I am a newbie! who can help me achieve this script?

What follows will check every minute if the virtual machine is running.

If not, the script will start the virtual machine

$vmName = "MyVM.

{while ($true)}

Get-VM-name $vmName | where {$_.} PowerState - eq "PoweredOff"} |

Start-VM-confirm: $false

sleep 60

}

Tags: VMware

Similar Questions

  • Automation of the Virtual Machine

    Hi friends,

    I have a question, I 03 virtual machines on a host ESXi 5.
    For the moment that a virtual machine is running.
    Can I create a rule when the first reached 75% of VM memory usage, automatically runs the second virtual machine?
    I have to make it through the VMA?

    Thank you very much!

    script

  • Make sure that the version of the host is 5 + front to build a virtual machine in automation

    Hello

    I use PS for WebAccess to build virtual machines. Our group has hosts 4.x which will not support Windows 2012. In the script, I chose a host based on certain criteria, e.g. vm how she is already hosting, etc... But now that we have 5.x, I have of course the host is 5.x before attempting to build a virtual machine Windows 2012. Is there a simple way to do this? I searched and not found anything really simplistic for my situation.

    Thanks for any help!

    You can use the Version property that is returned by Get-VMHost

    Get-VMHost | Select the name, Version

  • Help - automation of the ad groups in assigning roles for a virtual machine

    Hi all, I have this doubt.

    We are the migration of vSphere 4.1 and 5.1

    Not by update manager, but manually adding hosts an accumulation 5.1!

    Here's the thing, each virtual machine that will be imported/created/deployed to this new vCenter 5.1 will have a corresponding pre configuration of group by our admin guy!

    For — for example, if the virtual computer name is vm_0123, a group called "SVR_VM_0123" would be ready and waiting to be assigned to this specific virtual machine, and then to a role. And this permission will be set at the virtual machine level.

    And now, all the virtual machines that will be added to 4.1 and 5.1 have their configuration of groups!

    So can automate us the "attribution" permissions on each computer virtual imported/created (a role common to the respective groups) through PowerCLI?

    Questions or suggestions are welcome!

    Thank you

    I assume you have the virtual computer name in the variable $vmName, then you could do

    $vm = get-VM-name $vmName

    New-VIPermission-body $vm - main ("SVR_" + $vmName) - role $role

    You can place these lines in a loop.

    This could be for example a loop, controlled by the content of a CSV file.

    Something like that

    Import-Csv C:\vmnames.csv | %{

    $vm = get - VM - name _.vmName $

    New-VIPermission-body $vm - main ("SVR_" + $_.vmName)-role $_.role

    }

    This means that the CSV file should look like this

    "vmName"; "" role.

    "vm1', 'administrator '.

    "vm2', 'read only '.

  • Is it possible to save the xp mode virtual machine?

    I was wondering if there is an image that I can back up so I did not reinstall every time I reformat

    Hello
     
     
    Yes you can do it manually.
    Here's how:
    1. open Windows Explorer and navigate to %USERPROFILE%/Virtual Machines. It is the default location of the files vmcx. You will see a Windows XP Mode.vmcx file. This XML file contains the full path to the files that make up your virtual machine. The default full paths are:

    %UserProfile%\AppData\Local\Microsoft\Windows virtual PC\Virtual Machines\Windows XP Mode.vhd

    %UserProfile%\AppData\Local\Microsoft\Windows virtual PC\Virtual Machines\Windows XP Mode.vmc

    2. When you browse to %USERPROFILE%\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines, you can see additional files depending on the State of the virtual machine (that is, is this hiberated or not). If the virtual machine XP Mode is put in hibernation, if these additional files will appear:

    Windows XP Mode.vmc.vpcbackup
    Windows XP Mode.vsv

    3. the vmc and vmc.backup files are XML files that contain full paths to vhd files. If you restore on a different path, you will need to modify the XML files so that all file references are accurate and consistent. Windows 7 does not a VMS-specific automated backup.

     
    I hope this helps.

    Thank you, and in what concerns:
    Shekhar S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.
    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Check if a virtual machine has connected network and connect if it isn't?

    Thus, creating a big deployment VM automation workflow, I need a way to check and make sure that the deployed virtual computer has its connected network. However, I can't seem to find a way to generate scripts which correctly. Any ideas?

    Hello

    There are different strategies. Look at the 'vim3waitDNSNameInTools' action, it waits until the virtual machine arrives with a given host name. Which ensures that this customization is done completely.

    Alternatively you can ping the virtual computer by using the System.isHostReachable () method, find an example here: Ping on the workflow server

    (I remember there were some problems with this method in previous versions, be sure to properly test ;-))

    Another strategy might be to use the operations of comments and call a ping of in the guest operating system (with which you shall vro network connection to the virtual machine itself, you can for example leave the guest operating system ping the address of the gateway or so)

    Kind regards

    Joerg

  • vRO 7 assign a workflow to change in a plan of action and its virtual machine

    Setting up the environment

    1 vRealize Automation 7.0

    2 vRealize Orchestrator 7.0 that comes with the vRA

    Action plan and configuration of custom workflow

    1 has created a plan of action that the provisions of a Windows Server VM

    • Action plan has already been published
    • Pu VM provisioned to the catalogue of services without any problem

    2. has created a workflow customized to update the properties of the configured virtual computer

    When I try to run the "assign a workflow to change in a plan of action and its virtual machine", I was not able to choose the model that I created at vRA.

    Anyone has the same problem and how we can solve this?

    Thank you!

    vRA 7 no longer uses the entitled it a state change. All happened to event broker now.

    If you want a walk through the check-out this blog post.

    The activation of the event Broker

  • How to access the appservice parent of the virtual machine/machine component in a Multi environment?

    Hello

    I worked on a project of automation of the vra. In Orchestrator I have access to all the information for a particular component VM (for example, vCACVm, vCenterVm, virtualmachineEntity, vCACHost, vCACVmProperties objects) in the multi machine environment. But I have no information for the parent appservice (usually there will be a 'fake' vm as parent for multi machine environment).  For example, if I need to know the virutalmachineID of this parent 'VM' how to do it through vCAC API? I checked around and out to the desperate. Someone from http://dailyhypervisor.com/vrealize-automation-vcac-6-1-building-vco-workflows-for-multi-machine-blueprints/ says vCACEntity.getlink (vCACHost, "ChildVirutalMachines"), which seems the only link between parents and children vms. I certainly know that there should be an easy way to connect the machine virtual parent/child and go to the other, but how?

    Any response is appreciated!

    Concession of thank you for your response. It is the most common way that we tried. However, all properties we don't see anything pointing to the parent app "appservice' of a vm component. Last night I thought I found the answer. A property is shared between 'parent' and 'children': provisioningGroupID; It turns out that the name confusion is actually for "business group" for all the virtual machines belong to this group of companies will have the same value, not only the family of multi machine.

  • How to unmanage a virtual machine that has been in service of the vRA

    According to the subject line, I'm looking for a way to unmanage a virtual machine that was put in service of vRA without destroying it.

    I tried adding "Unregister (Machine)" element of the right action, but it did not help.

    Have a look here: VMware KB: remove a VM management VMware vCloud Automation or Automation vRealize

  • How to disable the HA/DRS option on a virtual machine?

    I have a virtual machine running under VMware cluster of 8 ESXi hosts. I want HA/DRS must be disabled on this virtual machine, as well as VMware may not move this vm incase of any failure. Can someone help me on this request?

    Hello Krishna,

    Yes. You can do this in the DRS and HA game settings for each virtual machine individually in cluster settings.

    There are various tabs of options HA - VM and VM - DRS in the vSphere client.

    In the new web client, these parameters are on a tab:

    Manage->-> VM overrides settings.

    Set the DRS automation level and priority to restart HA to disabled for this virtual machine. Also choose to leave it turned on like HA host Isolaiton response.

  • How can I move the "Virtual Machines" folder to the My Documents folder?

    VMwareFusion is to put the "Virtual Machines" folder in the Documents folder in the home folder (/users/ [username] / Documents), how can I move elsewhere (as/Library/Application Support)? The user Documents folder is not the right place for automated it system files, it is intended for personal documents.


    I am running VMware Fusion on OS X Yosemite (and the virtual machine is Windows 7).

    You can keep your virtual machines anywhere you want. Here are the steps to move:

    1 exit VMware Fusion. You can stop first of all of your running virtual machines.

    2. drag your virtual computers folder or the individual VM "files" where you / them. Filenames usually end in ".vmwarevm". There is no need to call the new folder "Virtual Machines" - you can call it anything you like.

    3. Launch VMware Fusion. If the library of the Virtual Machine window is not open, open it (Windows menu-> Virtual Machine library).

    4. ensure that all of your icons for the virtual machine are light gray and say "file not found".

    5. right click on each virtual machine in turn, and select Remove. When you are done, leave the window of Machine virtual library empty open.

    6. in the Finder, drag the icons of file virtual machine in their new location and drop them in library of virtual machines VMware Fusion window. Drop them one by one in the original order, you got, or rearrange icons later.

    7. run your virtual machines as before.

    When you create new virtual computers, navigate to the desired file before the Save.

    IMPORTANT NOTE: If you your folder of Machines ~/Documents/Virtual excluded from backups Time Machine, don't forget to change the exclusion to the new folder.

    Time Machine backups are not reliable for virtual machines. You must have another strategy. (I shut the virtual machine down, compress the 'file', and then move the compressed file to a folder that is included in the Time Machine backups. This isn't the only strategy, but it works for me.)

  • 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

    }

    }

  • Create new virtual machine of the model that have two hard drives in the different data store

    We do VM deploy automation with PowerCLI.

    There is already a model created with at least two hard drives to one side and each hard drive belong to difference datastore,

    In the model's operating system is Windows server 2008 R2 already installed VMware Tools and other software in the second (other than C: driver) driver

    We can successfully deploy a new virtual machine with this manually with vSphere client model.

    But when we try to make the deployment with PowerCLI, can not find examples of similar scripts in the document of reference,

    and we also google this question, still no similar question was found.

    Is this possible with PowerCLI? If it's possible could you give me some advice or an example of script, thank you!

    Best regards.

    I already found the solution.

    With the vSphere SDK .NET API, we can create the new virtual machine to the model

    Mainly used API listed below, sorry because I can not give the source code here.

    • VMware.Vim.VirtualMachineCloneSpec
    • VMware.Vim.VirtualMachineRelocateSpec
    • VMware.Vim.ManagedObjectReference
    • VMware.Vim.VirtualMachineRelocateSpecDiskLocator
    • VMware.Vim.ManagedObjectReference
    • CloneVM_Task

    For reference, you can take a look at this post and this post

    LucD , thanks for your help!

  • OsCustomizationSpec and OSCustomizationNicMapping they are a good way to set up the new virtual machine for the model

    I build a script to generate auto magicly VM when I have import information from a csv file. I have the latest PowerCli, I am trying to build servers r2 Sever 2012 model.  I tried several OsCustomizationSpec (OCS) of in the hope of getting something to work, but I had no luck so far.  In VCenter, it shows that it applies the OCS, but is not apear to have an impact on the server.  I have disabled UAC since the last time that I tried it so maybe that will make a difference.  I am under ESXi 5.1 update 2, just to try to give all the necessary information.  Ideally, I'd like Sysprep, the value of intellectual property, change the computer name and join the server to the domain.  That's all! lol I have the book "VMware vSphere PowerCLI Reffernece, automating vSphere Administration, I walked through step by step.  The new version of PowerCli seems not have the x 86 limitation as earlier versions of PowerCli.  I tried so many different things, I'm not sure what to put in place as a starting point.

    # Save the object credentials with permission to join the domain.
    $DomainCredentials = get-Credential "domain\testername."
    # Clone our Spec by adding the domain information.
    $Spec = get-OSCustomizationSpec "Windows Server 2012 R2"
    $Spec += get-OSCustomizationNicMapping - Spec $Spec
    #$Spec | Select *.

    # Get our VM
    # Change network settings
    Get - VM BigServername | Get-NetworkAdapter | Together-NetworkAdapter - NetworkName nic - 172.16.25 - VLAN225 - connected: $true '
    -Confirm: $false | out-null
    # Close the comments to make change.
    Stop-VMGuest - VM $VM - confirm: $false | out-null
    # Wait while feedback stops
    While ($vm. ExtensionData.Runtime.PowerState - not "poweredOff")
    {
    Start-Sleep - seconds 1
    $vm. ExtensionData.UpdateViewData ('Runtime.PowerState')
    }
    # Apply Spec customization to apply the new network settings
    Get - VM "BigServername" |
    Set-VM - OSCustomizationSpec "R2 Windows Server 2012" - confirm: $false |
    Start-VM

    I can rebuild the model, or something else, we must do this work.

    OR - is simply not the best way to configure the VM?  If not, what Sysprep?

    Good news, but first, I would really like to know where the log files are on which server to the OsCustomization process.

    I decided to reverse engineer and create a CSOS within vCeneter and once I got to work, I kept creating new CSO via PowerCli until I could get that to work, create a new virtual machine.  Once I got this to work, I have tryied to apply on a cloned vm, with no parameters. I got it works too.  I tried to go back to my original image, but I couldn't get this to work.  Something's wrong with this picture.  He wrath that the problem was related to the permissions on the local client.

    New OSCustomizationSpec - OrgName company OSType - Windows - ChangeSid-Server "vcenter.dom.com" - name PowerCliOnly4 - persistent administrator-Type FullName - AdminPassword! password123 - zone "Eastern (USA and Canada)" AutoLogonCount - 3 - domain dom dadmin - DomainUsername - DomainPassword! password123 NamingScheme - vm-Description "PowerCli Use only" - confirm: $false

    Get-OSCustomizationNicMapping - OSCustomizationSpec PowerCliOnly4 | Game-OSCustomizationNicMapping - Position 1 - IpMode UseStaticIP - IpAddress 10.10.10.98 - 255.255.255.0 - DefaultGateway 10.10.10.1 Dns subnet - mask "10.10.10.10","10.10.10.11" "-confirm: $false

    This seems to be very picky.  Because the area is one of the parameters, you cannot put it in the DomainUsername, no dom\dadmin. The part that I really want to know how to get more, is what happens if your vm has a different local administrator as the administrator account.  It turns out that FullName - is not the account that it to connect locally with tires. When I created the vCenter Medtronic Chondroitin, I put 'me' in the name and information of the Organization and that's what was settled in the FullName property:

    Name: PowerCliOnlyM
    Type: persistent
    ServerId: /VIServer = dom\[email protected]: 443.
    Server: vcenter.dom.com
    LastUpdate: 24/09/2014 13:33:19
    DomainAdminUsername: dadmin NO dom/dadmin here!
    DomainUsername: dadmin
    Description: PowerCli use only, done manually in vCenter.
    AutoLogonCount: 3
    ChangeSid: true
    DeleteAccounts: false
    DnsServer:
    DnsSuffix:
    Domain: vsi
    Full name: me
    GuiRunOnce:
    NamingPrefix:
    NamingScheme: Vm
    OrgName: CompanyTU
    OSType: Windows
    ProductKey:
    Time zone: (USA and Canada)
    Working Group:
    LicenseMode: NotSpecified
    LicenseMaxConnections:
    EncryptionKey: {-126, 3, 48, 108...}
    ExtensionData: VMware.Vim.CustomizationSpecItem
    ID: PowerCliOnlyM
    UID: /VIServer = vsi\[email protected]: 443/OSCustomizationSpec = PowerCliOnlyM /.
    Client: VMware.VimAutomation.ViCore.Impl.V1.VimClient
    AdminPassword: w
    DomainAdminPassword: N
    DomainPassword: N

    DNS: {10.10.10.10, 10.10.10.11}
    Wins                  :
    SpecId: PowerCliOnlyM
    Spec: PowerCliOnlyM
    SpecType: persistent
    NetworkAdapterMac:
    Position: 1
    IPMode: UseStaticIP
    IP address: 10.10.10.98
    Subnet mask: 255.255.255.0
    DefaultGateway: 10.10.10.1
    AlternateGateway:
    VCApplicationArgument:
    ID: /VIServer = dom\[email protected]: 443/OSCustomizationNicMapping = OSCustomizationNicMappingImpl-PowerCliOnlyM-persistent-1.
    UID: /VIServer = dom\[email protected]: 443/OSCustomizationNicMapping = OSCustomizationNicMappingImpl-PowerCliOnlyM-persistent-1.
    ExtensionData: VMware.Vim.CustomizationAdapterMapping
    Client: VMware.VimAutomation.ViCore.Impl.V1.VimClient
    Version: 1

    I think that it is good to know that the virtual machine reboot 4 or 5 times as it goes through this process.  It breaks is you try and do something for the virtual machine that interrupt the process.  I don't know that I'll think more questions in a second.

    In addition, it cost he had some problems with the put between quotation marks, single or double around the password, but I did not check this again, I just know that once I took them, he began to work.  I ran on other issues while testing as I was using a single IP address, so if I do not disable the test VM, the following would not work because of the conflct network, maybe I shouldn't admit that... lol

  • DRS Rule - separate virtual machines

    I have a DRS rule to separate the 2 virtual machines, but when I vmotion two virtual machines on the same host, it allows him to do. Why is this?

    I need to separate VMs on separate hosts at all times

    OK, I had the level of automation to manual, so he won't move the virtual machine. Once I changed it to automatic, its moved the VM on the host.

Maybe you are looking for

  • 'Clear recent history... ". "erases cookies and! Cookies exceptions list even if the box of cookies is not checked

    By clicking on "clear recent history...» "erase all cookies and worse still the cookies exceptions list even if the box of cookies is not checked. Restart Firefox and restart of the operating system, the problem persists.

  • Phone ringing changes itself

    I upgraded my Razr Maxx to Jelly Bean, and everything seems to work perfectly with one minor exception to boring. The ringing of the phone will not stay where I put it, but keep coming back to 'Noisey One' which I used for a while, but had obtained e

  • Question CPU Upgrade Presario CQ61-217TU

    Hello Laptop model: CQ61-217TU http://h10025.www1.HP.com/ewfrf/wc/product?cc=us&LC=en&product=4004988 Laptop REPAIR:http://h10032.www1.HP.com/CTG/manual/c01740724.PDF P/N:VJ994PA #ABG BIOS: F.23 Latest (available) Old central processing unit: Celeron

  • Windows 7 Ultimate 64 bit - Activation? Help!

    Hello Recently, my computer was stolen, but the installation cd has not taken. I installed again on my new computer, but now he asks me an activation code, which I cannot find in the box, or on any of the manuals. Taken version was Win Ult 7 64-bit E

  • HP 2540 wireless connection problems

    My HP 2540 wireless printer is not recognized when I send prints, but I can scan and save her