rename several virtual machines based on the State of food & VM name

I'm looking for a powershell script to rename the virtual machine based on the state name and vm power.  For example, I have several virtual machines with a - temp at the end of the name of the server.  Some are turned on and some are turned off.  I am wanting to rename only those who is off

Thank you

tjw82

Assuming that - temp is part of the name

Get - vm | where {$_.powerstate - eq "poweredoff"} | foreach {Set-machine virtual - VM $_ - name (($_.name).)} Replace ("temp", "delete"))}

Tags: VMware

Similar Questions

  • Start the virtual machine based on the load of another virtual machine

    Hi all

    I am looking for a solution that will start the VM on request depending on the load on the other virtual machines, perhaps in the same resource pool. Essentially, the expected result would be something like this:

    -When the dv01 reaches 75% CPU usage for 15 minutes,

    -Boot VM02

    -Once dv01 was less 40% use for 30 minutes,

    -Close the VM02

    This could also be a new virtual machine that is upwards of a model and Sysprep, rather than one that just sits there, offshore and unused.

    I hope that the final objective is clear. Does anyone have recommendations on how to do it? I just did a quick search on certain clauses that I thought would be relevant and did not really turn anything upwards.

    Thanks for your comments!

    -James

    jamesgreen wrote:

    Hi all

    I am looking for a solution that will start the VM on request depending on the load on the other virtual machines, perhaps in the same resource pool. Essentially, the expected result would be something like this:

    -When the dv01 reaches 75% CPU usage for 15 minutes,

    -Boot VM02

    -Once dv01 was less 40% use for 30 minutes,

    -Close the VM02

    This could also be a new virtual machine that is upwards of a model and Sysprep, rather than one that just sits there, offshore and unused.

    I hope that the final objective is clear. Does anyone have recommendations on how to do it? I just did a quick search on certain clauses that I thought would be relevant and did not really turn anything upwards.

    Thanks for your comments!

    -James

    with raise vm02, you can set the alarm action to run a script that will start vm02.

    PowerCLI command would be

    Start-VM - vm VM02

    you could probably add an alarm if dv01 has a less than 40% cpu

    run another script

    the command is:

    stop-vmguest - vm-VM02

  • Sorting of virtual machines based on the record, they are in

    I want to sort vm based on the record, they are everyone knows how to do this? Even better export to the excel sheet.

    You want only the name of folder or the complete file path?

    If it's only the name of the folder, you can use a slight variation on the script in the list of VMS by folder name.

    Something like that

    $report = @()
    
    Get-Folder | %{
      $folder = $_.Name
      $_ | Get-VM | %{
        $row = "" | select FolderName, VMName
        $row.FolderName = $folder
        $row.VMName = $_.Name
        $report += $row
      }
    }
    $report | Sort-Object -Property FolderName | Export-Csv "C:\VM-by-folder.csv" -NoTypeInformation
    
  • Need help updated the VMX file on several Virtual Machine

    All,

    Can anyone help with a problem I'm having?  Here is a brief explanation of what is happening and what we need to solve.

    Recently we found out that we need to add a line in the file VMX of several virtual machines.  In the past, I was able to do this, but would have cold start the virtual machine for the changes to take effect.  Starts cold won't be a problem, because we can program it.

    However, no one knows a way to add this line in the file VMX virtual machines in a cluster.

    Here's the line I need added:

    Devices.hotplug = "false".

    Here is a script that was used earlier (esx 3.0 days) to keep the VM tools updated on reboot.  At this point, if the virtual machine has been turned on, this change could not do through the UI.  However, this script worked to update the .vmx file and then we have cold reboots for the changes to take effect.

    Get-viserver - < Server > - < user > - < password >

    $viview = get-Cluster-name NOMCLUSTER | Get - VM | foreach-object {get-view ($_.ID)}
    $viview | {foreach-object
    $vmConfigSpec = new-Object VMware.Vim.VirtualMachineConfigSpec
    $vmConfigSpec.Tools = new-Object VMware.Vim.ToolsConfigInfo
    $vmConfigSpec.Tools.afterPowerOn = 'True '.
    $vmConfigSpec.Tools.afterResume = 'True '.
    $vmConfigSpec.Tools.beforeGuestStandby = 'True '.
    $vmConfigSpec.Tools.beforeGuestShutdown = 'True '.
    $vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle".
    $_. ReconfigVM ($vmConfigSpec)
    }

    The exact script can be found in Disable HotPlug

  • Several virtual machines attached to port VM group

    Hi all

    So I did research on the internet and on this forum and I have not found a good answer to my question. So I would check that I can create a unique Virtual Machine port group and attach multiple virtual machines and run them simultaneously. I basically want to have each VM attached to this switch, but instead to a separate port group, it seems that I can just attach to the same port group that puts on the vSwitch.

    Is there problems of L2 with MAC address or ARPing or something like that? I realize that I have to ensure that each VM has correctly configured the IP settings. I know there are problems, but I am wanting clarification of the people who have done this before. Are there problems of interface as with a real switch speed or who is not serious in a vSwitch?

    Thank you!

    -GNS

    You can attach multiple virtual machines to the same group of port without problems, this is how normally environment are created. Have a look here for more details: vSphere Standard switches

    The image below shows several virtual machines connected to the same port group:

  • vRA 6.2 API - is possible to ask a new virtual machine based on a machine of model using the API

    Hello

    Is this possible in version 6.2 API at the request of a new virtual machine based on a model of Machine catalog?

    Thanks for the help in advance,

    Pieter

    Yes, you need to specify the new virtual machine in json format and publish it on/catalog-service/api/consumer/requests

  • Rename all the virtual machine files in the data store

    Hello

    We have renamed one of the name of the server of our virtual machine running on esx3.5. In addition, we have renamed this server in VC to reflect the new name of the server. Please tell us how we can rename all files in this virtual machine residing in the data store to reflect the new name of the server.

    Appreciate your quick response.

    Thanks in advance...

    You can use sVMotion and move it to another data store or migrate from cold.  Two tasks will rename the underlying set of files.

  • Create several virtual machines from the same base image

    Hi all

    Is there any vi api sdk by which I can create several virtual machines form same base vmdk file?

    All create the VM from the base VMDK file will have their own delta vmdk file that will refer to the same base VMDK file. Only changes that are performed on each virtual machine are saved on their respective delta vmdk files.

    Thanks in advance...

    Hello

    What you are referring is called Clones related, in the current VI API, there is no method that supports this feature. You can take a look at CloneVM_Task() http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.VirtualMachine.html#clone if you want to implement a full clone and this will require you to have access to vCenter.

    In the next version of vSphere, vSphere SDK THAT will provide a way to implement the related Clones and it will be a parameter you can specify CloneVM_Task() , more precisely in the VirtualMachineRelocateSpec where you will specify diskMoveType to createNewChildDiskBacking

    You can find more information once vSphere of GA and the new QAnywhere VI documents are released, but if you are looking to implement related Clones today, you can take a look at the product of VMware View 3, which provides support for linked Clones or you can take a look at two scripts that I wrote which creates linked Clones similar to that of the view :

    Clones related to ESX

    CLones related to ESXi

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

    William Lam

    VMware vExpert 2009

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

    repository scripts vGhetto

    http://Twitter.com/lamw

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

  • Question about the volume on several virtual machines sharing

    Hey!

    Try to use vmkfstools on Vi remote CLI, but he says that he is not recognized as an internal or external command... Is there an easy way to share data between several virtual machines? If so, how? Also if we are implementing raid 5 are we building our vitrual (windows 2008 Server) with the typical c: or d: drives? That is to say. You put the Windows Server 2008 on a separate virtual C: drive and data on a disk separate from virtual D:? Or is it no more? What about the Windows swap files? Must create us virtual drives, JUST for page files? Sorry I know this is a lot, but any help would be greatly appreciated!

    Thank you!

    1. is there an easy way to share data between several

    virtual machines? If so, how? A CIFSor NFS share would be preferable. Since I got you guess the VMS are mainly Windows you want to go with a CIFS share. You can run a virtual NAS appliance  (http://www.openfiler.com/community/download/)

    Also if we are implementing raid 5 are we building

    our vitrual Server (windows server 2008) with the typical c: or d: drives?

    That is to say. You put the Windows Server 2008 on a separate virtual C: drive

    and the data on a virtual disk from D:? Or does not everything

    more? Yes design you virtual as your physical systems i.e. separate Boot/system information application. just build you VMs how you would with physical systems (especially true of SQL or Exchange).

    What about the Windows swap files? We create virtual drives

    Yet, ONLY for page files? Never did it for physical so no systems

  • Can not find templates of virtual machine by using the command 'Get Template '.

    Hi all

    My apologies if this question was asked before, but not could not find any information about this.

    For some reason when I use the command Get-model PowerCLI I get no results even though I have models on the data store. Using a command such as Get - VM works as expected, but for some reason that the command Get-model just can't find anything. There is something pressing that I may have missed in my virtual environment configuration?

    The environment consists of a data center with a 5.1 ESXi host and several virtual machines residing on it. I also have a virtual appliance of vCenter to manage the host.

    Thank you

    Matt

    Hi Matt,

    When you run Connect-VIServer, you connect to the server ESXi and vCenter?

    I just tested the two:

    • SE connect-VIServer-ESXi Server

      • Get-model didn't recover all data
    • SE connect-VIServer-Server vCenter
      • Get model retrieved data

    Maybe that's the case?

    Hope this helps,

    Steven.

  • Workstation - Bat file to run several Virtual Machines

    I am currently using the following .bat file to launch several virtual machines:

    Start "" /b "C:\Users\Abe\Desktop\Virtual machine 1.lnk".

    Start "" /b "C:\Users\Abe\Desktop\Virtual machine 2.lnk".

    My problem is that start each machine's own instance of VMware.  Is it possible to build a script (.bat or other) who will start the virtual machines in a single instance of VMware Workstation.

    Regards and thanks in advance

    k

    You can create a file of commands like this:

    vmrun start "C:\VM\VM1.vmx".

    vmrun start "C:\VM\VM21.vmx".

    This would open up two virtual machines in the same GUI - at least that's the way it works on my Windows 7 host with 9 Workstation.

  • Create several virtual machines from a

    Is it possible to create multiple virtual machines a build? I have a 2008 R2 vm. instead of having to rebuild the whole system from scratch is there a way to make a template or something to create several virtual machines a build? I am using vcenter 5 and I have 2 servers esxi 5.

    You can create a template by right-clicking the virtual machine and choose Clone to the model and give the datstore where you want to save after that you will have a model using this model to deploy the virtual machine using Customization Wizard.

  • Connect physical hard disks to the virtual machine (and leave the data intact)

    Hello

    I'm looking to virtualize a SOHO headless server, that I use mainly for secure file storage.

    Currently, the system runs Linux installed on a small disc and has two drives 1.5 TB, used exclusively for data, in a cluster of ZFS mirroring. (I use the ZFS-fuse Linux-based application).

    I want virtualization for two reasons. One is to make administration easier and safer - avoid having to connect a keyboard and the physical monitor to the box from time to time. The other is that the machine is a bit more powerful to handle the load, and I'm hoping to make it work on other, more challenging tasks.

    Now, there is a catch. These discs are as highly important. I mean the data on them. What I need is to convert the current Linux system to a virtual machine, or re - install Linux on a virtual machine (don't like that), then connect the physical disks to the virtual machine as if they were actually connected.

    I certainly don't want to vmware touches those disks somehow.

    I've read the documentation, but I'm a noob when it comes to server virtualization and system engineering and don't quite understand if this is possible or not. These discs are not a SAN, they are physically connected to the server, I want to install vSphere on. (Of course, I'll log out when I run the setup of vSphere. But I need plug them again later, and they need to be sure that vmware will leave them alone and pass them to the virtual machine transparent.)

    Sigmoid wrote:

    Oh yes, the cluster mirrored ZFS. It is essentially a software RAID type thingie.

    http://en.Wikipedia.org/wiki/ZFS

    A material, or the point of view of virtualization, it appears two hard drives with a single huge partition on each that is not transparent to anyone, except the implementation of ZFS.

    OK, means that you can break the RAID, connect the drives to different host and configure RAID once again, right?

    Let's do it this way

    1. We will need a disc player more for VM, cause on flash, we install ESXi
    2. I will share ZFS :-), all you need to do with that before you install ESXi
    3. make the BACKUP!
    4. Disconnect the data host drives
    5. install ESXi 4.1 U1 free version on flash
    6. Download the site VMware vSphere client
    7. Connect the VM disk to ESXi
    8. customer help create the virtual machine and install the OS on it
    9. stop the virtual machine and esxi
    10. connect DATA drives to the ESXi host
    11. begin to ESXi
    12. See how to add RDM on youtube, after client use, change first hardware VM--> add a new hard disk--> choose Raw Device Mapping--> (physical or virtual) mode--> store it with folder VM - FACT
    13. Start the virtual machine, now your VM should see both drives, with good data course :-)

    I have just made this procedure (add ROW with data in Linux VM) on ubuntu VM, works well

  • the request to turn off this virtual machine failed because the corresponding vmware tools script didn't run successfully

    using vmware fusion 2.0.5

    the request to turn off this virtual machine failed because the corresponding vmware tools script didn't run successfully

    now vmware cant off power

    is vmware tools script to run when windows is running

    If I power off (mac - force quit) now... what happens

    VMware Fusion 2.x...

    VMware Fusion (menu bar) > help > VMware Fusion help > running VMware Fusion and Virtual Machines > Shutting Down a virtual machine operating system

    VMware Fusion (menu bar) > help > VMware Fusion help > running VMware Fusion and Virtual Machines > Options for VMware Fusion food orders

    VMware Fusion (menu bar) > help > VMware Fusion help > running VMware Fusion and Virtual Machines > orders of switching power supply from the default Options

    ==========

    Note: It's like pulling the plug of the wall on a physical computer. Whatever this is not saved will be lost and there is always the possibility of corrupting the file system where preforming a hard stop! (Even if you have no choice but to do.)

    VMware Fusion menu bar > VM > press the option key and select Power Off

    By pressing the keys alt/option "Shutdown called" changes to "Power Off".

    Note: It also changes orders of "Suspend comments" and "Restart Guest' too.

    Or if this does not work then...

    On the library Virtual Machine ctrl - click on the target of the Virtual Machine and select Show in Finder and delete the .vmss file, the ctrl + click the target package of Virtual Machine, and then after the merger closed. Note: All that was not justified for the suspended state will be lost by deleting the .vmss file. Note: However: you have no other choice if the Virtual Machine does not suspend/resume/stop/start correctly.

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

Maybe you are looking for