Restore the snapshots on several virtual machines on multiple hosts?

I seem to have a mental block.  I need to write a script that will allow me to return to the current snapshot for all VMs on a given host.  I really like he must be all hosts in a specific folder, find all the virtual machines on the hosts, then roll them all would support for previous snapshots.

I took this to the Administrator's guide:

$vms = get-vm-location (get-file pods)

foreach ($vm in $vms) {set-VM - vm $vm - snapshot (get-snapshot - vm $vm - name class_start)}

For some reason I can't wrap my head around it today.  I know that I have all the elements in my head, can't seem to put it together.  Help?

That's how I'd do.  It seems that the easiest way to understand.

$vms = get-vm-location (get-file pods)

foreach ($vm to $vms)

{

# Get last snapshot.

$snapshot = get-Snapshot - $vm VM | Select - 1 last

# To return to the last snapshot.

Set-VM - VM $vm - Snapshot $snapshot

}

Tell me if you have any questions.

Tags: VMware

Similar Questions

  • 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

  • Change the default location of the snapshot for a virtual machine

    Hello. I found this tutorial

    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 1002929

    on hos to move the default location for the snapshots of a virtual computer. How ever what I don't understand is where can I covering the line in the file *.mvx, "workingDir = "new_path_location" ? I just start typing at the end of the file? The file can be edited in Notepad of windows or I should connect to the host using putty and correct it in nano, for example?

    For example, in the same document, they used

    workingDir = "/vmfs/volumes/46f1225f-552b0069-e03b-00145e808070/vm-snapshots"

    I think that " 46f1225f-552b0069-e03b-00145e808070 " is an identifier for the volume. True or not? If yes how can I list all the volumes that are mapped to the host or vCenter Server identifiers?

    Thank you!

    alexiaesx wrote:

    Hello. I found this tutorial

    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalID=1002929

    on hos to move the default location for the snapshots of a virtual computer. How ever what I don't understand is where can I covering, in the file *.mvx, line "workingDir = "new_path_location" ? I just start typing at the end of the file? The file can be edited in Notepad of windows or I should connect to the host using putty and correct it in nano, for example? in any case around, either Notepad or vi or nano - both will be fine.

    For example, in the same document, they used

    workingDir = "/vmfs/volumes/46f1225f-552b0069-e03b-00145e808070/vm-snapshots"

    I think that " 46f1225f-552b0069-e03b-00145e808070 " is an identifier for the volume. True or not? Yes its unique identifier for your vmfs volumes, but its better if you provide your name of store data instead, as if your data store name is XYZ, provide/vmfs/volumes/xyz/vm-snapshot, you can do it using UUID as well but you need to type for long and its not easy to remember.

    If yes how can I list all the volumes that are mapped to the host or vCenter Server identifiers?

    using the cli

    list of esxcli storage vmfs

    using ssh console, this should provide you with all the information for the disks

    Fdisk-lu

    Another thing,

    CD vmfs/volumes /.

    LS - lah

    You can see your vmfs volumes

  • The list of all virtual machines to a host group in Virtual Machine port group

    Ladies and gentlemen,

    I would like to create a powershell script to list all my virtual machines to a host, but a group of Machine virtual PortGroup... It is possible...? I see only found Internet see the VirtualPortGroup of the host...

    Thanks in advance & looks

    All your VMS have a mapping single portgroup or it not with multiple NICs on different port groups?

    If they are all the same, then the following should work:

    Get-VM | Select Host, Name, @{N="PortGroup";E={$_.NetworkAdapters[0].NetworkName}} | Sort PortGroup, Name, Host
    

    If you found this information useful, please consider the allocation of points for correct or helpful.

    Alan Renouf

    http://Virtu-al.NET

  • Sharing the drive between several virtual machines

    Hi all

    We have a configuration with a SAN (Dell Compellent) and use vSphere 6 to host a number of Windows servers. We now have a giant machine of Windows with a large number of small files for a particular application.

    Now, we would like to create a cluster with a LoadBalancer in front of him, so that we can handle more load. To do this, we want to create a disk that is shared between 2 (or more) of windows machines.

    One of the problems is that NTFS is not a supported clustered file system. So, I did a lot of research on Google to see what my options are. In my opinion, they are the following:

    1. set up a Cluster Shared Volume (CSV) Microsoft (use SMB if I read the documentation)

    2. the user Windows shares on a separate file server

    3. the user NFS (depreacted under Windows)

    4. switch to Linux and use NFS

    The problem I have, is that they use all the network traffic. For example, option 2 is ridiculous slow. NFS under Linux is also a way slower than the local drive (managed by VMWare iSCSI) disk access and NFS on windows does not appear to be

    support very well.

    I know that there are aware filesystems, clustered as VMFS etc. Is there a way to access it directly from my Windows VM or are there devices SAN which is directly accessible from the virtual Windows machine?

    Or maybe there are other solutions to set up a shared drive?

    I know that there are aware filesystems, clustered as VMFS etc. Is there a way to access it directly from my Windows VM or are there devices SAN which is directly accessible from the virtual Windows machine?

    VMFS is a really clustered file system and allow access of multiple virtual machine the same amount of storage (data store) which is different from that to create a virtual disk (hard) and present to multiple virtual machines. You can do this, BUT the guest virtual machine should take care of several accesses to the hard, for Windows, you must turn on the feature... without this clustering with failover data may be corrupted.

    I think the best and supported solution for you is to create another cluster with Failover Cluster functionality and create a resource sharing files with files that will access your NLB nodes.

  • Controlling multiple virtual machines on multiple hosts?

    Hello

    My apologies for what will clearly be a newbish question because I just started using PowerCLI yesterday. I have 6 servers hosts with 10 virtual machines on each and every VM with a snapshot.

    I created a script for

    (1) connect to Host #1

    (2) to reset all 10 VMS to the snapshot (a)

    (3) power on all virtual machines (simultaneously)

    (4) connect to the host #2... Rinse and repeat at host #6.

    It takes a little more than 5 minutes. I'm sure that this process will speed up if I find the answers below:

    Two questions:

    There's a way to connect to all servers at the same time, so can I have step #3 works on all servers host 6.

    -Is it possible to have the step #2 run simultaneously on each host to save on time?

    Thank you very much!

    With the Connect-VIServer cmdlet, you can connect to several servers in vSphere.

    Only condition is that you can use the same credentials, or this UNIQUE authentication is implemented.

    When you switch to view "multiple" with the Set-PowerCLIConfiguration cmdlet, you can run cmdlets against all those servers at the same time.

    You can now do a 'Get - VM"which will return all the virtual machines on all connected servers vSphere.

  • 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"))}

  • How to find the age of a child and snapshot number snapshot for a virtual machine.

    Hi all

    How to find the age of a snapshot for a virtual machine child count and snapshot.

    This code snippet should help... Assuming that you have the following entries:

    VM (VC:VirtualMachine)

    snapshot (VC:VirtualMachineSnapshot)

    System.log("====== Snapshot details for VM: "+snapshot.config.name+" ======");
    var snapshotTrees = vm.snapshot.rootSnapshotList;
    System.log("Snapshot Tree Count: "+snapshotTrees.length);
    for each (snapshotTree in snapshotTrees){
        showSnapshotInfo(snapshotTree, snapshot);
    }
    
    function showSnapshotInfo(snapshotTree, selectedSnapshot){
        if(selectedSnapshot == snapshotTree.snapshot){
            System.log("====================");
            System.log("Name: "+snapshotTree.name);
            System.log("Id: "+snapshotTree.id);
            System.log("Description: "+snapshotTree.description);
            System.log("createTime: "+snapshotTree.createTime);
            System.log("quiesced: "+snapshotTree.quiesced);
            System.log("replaySupported: "+snapshotTree.replaySupported);
            System.log("backupManifest: "+snapshotTree.backupManifest);
            System.log("snapshot id: "+snapshotTree.snapshot.id);
            System.log("state: "+snapshotTree.state.value);
            var childSnapshotList = snapshotTree.childSnapshotList;
            if(childSnapshotList != null){
                System.log("childSnapshotList length: "+snapshotTree.childSnapshotList.length);
            }
            System.log("");
        }
        if(snapshotTree.childSnapshotList != null){
            System.log("Children found: "+snapshotTree.childSnapshotList.length);
            for each (childSnapshotTree in snapshotTree.childSnapshotList){
                showSnapshotInfo(childSnapshotTree, selectedSnapshot);
            }
        }
    }
    

    During the passage of one of my virtual machines, here is an example of output I get:

    [2014-06-12 15:19:21.493] [I] Snapshot Tree Count: 1
    [2014-06-12 15:19:21.493] [I] ====================
    [2014-06-12 15:19:21.494] [I] Name: before upgrade to 5.0.1
    [2014-06-12 15:19:21.494] [I] Id: 31
    [2014-06-12 15:19:21.494] [I] Description:
    [2014-06-12 15:19:21.495] [I] createTime: Mon Mar 19 2012 13:48:57 GMT-0400 (EDT)
    [2014-06-12 15:19:21.495] [I] quiesced: false
    [2014-06-12 15:19:21.495] [I] replaySupported: null
    [2014-06-12 15:19:21.495] [I] backupManifest: null
    [2014-06-12 15:19:21.496] [I] snapshot id: snapshot-83
    [2014-06-12 15:19:21.496] [I] state: poweredOff
    [2014-06-12 15:19:21.496] [I] childSnapshotList length: 1
    [2014-06-12 15:19:21.496] [I]
    [2014-06-12 15:19:21.497] [I] ====================
    [2014-06-12 15:19:21.497] [I] Name: Before 5.1 upgrade
    [2014-06-12 15:19:21.497] [I] Id: 36
    [2014-06-12 15:19:21.497] [I] Description:
    [2014-06-12 15:19:21.498] [I] createTime: Fri Sep 21 2012 21:59:58 GMT-0400 (EDT)
    [2014-06-12 15:19:21.498] [I] quiesced: false
    [2014-06-12 15:19:21.498] [I] replaySupported: null
    [2014-06-12 15:19:21.498] [I] backupManifest: null
    [2014-06-12 15:19:21.499] [I] snapshot id: snapshot-84
    [2014-06-12 15:19:21.499] [I] state: poweredOff
    [2014-06-12 15:19:21.499] [I] childSnapshotList length: 1
    [2014-06-12 15:19:21.499] [I]
    [2014-06-12 15:19:21.500] [I] ====================
    [2014-06-12 15:19:21.500] [I] Name: Before Named Instance
    [2014-06-12 15:19:21.500] [I] Id: 37
    [2014-06-12 15:19:21.501] [I] Description:
    [2014-06-12 15:19:21.501] [I] createTime: Mon Nov 11 2013 13:40:46 GMT-0500 (EST)
    [2014-06-12 15:19:21.501] [I] quiesced: false
    [2014-06-12 15:19:21.501] [I] replaySupported: null
    [2014-06-12 15:19:21.502] [I] backupManifest: null
    [2014-06-12 15:19:21.502] [I] snapshot id: snapshot-236
    [2014-06-12 15:19:21.502] [I] state: poweredOff
    [2014-06-12 15:19:21.502] [I]
    
  • 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

  • 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 size of my Virtual Machine

    I'm on Fusion 3.1 (and Windows XP in Fusion on a MacBookPro Leopard). I put my Windows Virtual Machine to be 40 GB size but I just ran OmniDiskSweeper and it shows that the virtual machine takes 53 GB. I see the same size in the Finder.

    Two questions: first, how is it possible for the virtual machine to limit growth, I gave him? Second, is there a way for me to downsize (safely). I did not quite in the virtual machine (mainly my installation of Windows) and a handful of programs so it's weird that she's so big.

    I have disabled Auto-protect.

    I have two snapshots, one of when I first set up the virtual machine and one of very recently. I once had a bunch of other photos but I deleted them. I mention this because I read in another thread that "orphan" instant can hang out somewhere but I don't know where to look to see if this is the reason for the growth of my virtual machine.

    Thanks a lot for your suggestions.

    Abe Z.

    AMZ1 wrote:

    One thing I didn't get your last answer: if snapshots are not backup, and the creation of a snapshot causes the basic disk that you want to stop growing, which are good for snapshots? Or in other words, your response, it looks like I should stop creating snapshots, Yes?

    In which case I should rely only on periodically manually save the virtual machine by copying in the Finder on an external drive?

    What I said was "Snapshots are not backups in the traditional sense of the word and should not be relied upon as such either." However, using clichés absolutely has merit and value but how to use them effectively and efficiently seems to escape most of the users.  As a general rule, I treat a not different Virtual Machine and a physical Machine, then when it come to back up the user data and the ability to quickly restore the entire construction as well as user data.  I use snapshots mainly for short periods of time, and then either delete them when I don't want to lose changes made along the way, or if I go back to a previous snapshot.  For example, I can run on a given snapshot and say a single snapshot for a week and if all was well I'll delete it and take another or if I need to do something that could end up with bad results I'll take a snapshot to do what I do and if I have a problem just go back to the previous snapshot or the basic disk as appropriate.  The trick is user data constantly backed up out of the Virtual Machine itself, as well as at some point in time I never have to worry about the State of and reason for any data or instant and what action I might have to or want to take.

    There are many other cases workers scenarios about how/when to use snapshots and it was just a bit of food for thought because I don't have time now to get deeper into it but the snapshots are a good thing to use as and when necessary, but do not count on them to replace the traditional methods/methodologies for backup/recovery of data user or any backup/restore system but use then as a another tool in the digital Toolbox.

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

  • Closing and reopening the workstation with running virtual machines

    I have recently upgraded to 10 Workstation and I am having a strange problem. In preferences, I have checked option which says "continue to VMs run after the closure of workstation. In workplace planned 9 this option worked exactly, but workstation 10 seems that partially works as expected. In Workstation 9 I could close my computer, and then open then in from the tray icon to always see my virtual machines running with the small green icon play on them. However, in the 10 workstation I close the workstation and all my virtual machines continue to run, but when I reopen it workstation all my virtual machines appear in the workstation as if they are off; but they run because I can RDP for them. If I right click on one of them all is grey with the exception of mark it as a favorite and delete. I can't power off, change the settings, see the console, or anything like that. The shows the icon that VMs are being run, but even suspend, stop or suspend tray icon options or background open VMs do not work either. The only way I found actually to get my computer working again is to use the Task Manager to kill the task of vmware - vmx.exe. As soon as the task is killed for each workstation running, they operate again in the workstation.

    If anyone has encountered this problem, or know a fix for this? I have run several virtual machines and never have any idea that vmware - vmx.exe is for what VM when needing to change something on one of them. I make sure that I can kill them all in order to make a change to one of them.

    David Moore

    Ok. I have this problem. However, the fix has been an awareness in desperate need of repair. I ended up uninstalling the VMware Workstation and then remove all references to the registry with REGEDIT. I then restarted the computer and reinstalled VMware Workstation again. After this heavy treatment, it works again the way it should work. It seems that the upgrade to the latest version of Workstation 9 to the latest version of 10 break something somewhere.

    By the way, Dayworker, it was and is version 10.0.3.

  • Undetected after the fresh install ESXi virtual machines

    Hello

    I have to say I really enjoyed working with ESXi, but I run a quick question for the moment.

    I initially installed ESXi 5 on an SD card and created several virtual machines via vSphere Client Windows. Because of the card SD comes off on the reboot (using a Dell R610), I have now decided to install ESXi 5 on a USB key. However, when I open the Windows of vSphere client, I do not see the virtual machines on the host, but I see that they are always present in the VMFS data store that I created earlier. When I boot from the SD card, they appear very well.

    I have to migrate somehow?

    Thank you very much for your help!

    As this is a new installation of ESXi you can save the VMs from the data store as the inventory.xml on the new facility can be empty.

    Measures to save the virtual machine using vmx are available on Ko http://kb.vmware.com/kb/1006160

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

Maybe you are looking for