PowerCLI: Stop your Virtual Infrastructure

Hi guys,.

Today we had a power failure and we were force to a part of the closure of our virtual infrastructure to saved some powers for our critical virtual machines, we spent some time in the shutdown process, my question is, how can I automate this process using PowerCLI and at the same time work on other tasks?, I found a script for this but it stop the entire cluster (ESX and VMs) all we need is a script that check each host ESX (or Cluster), looking for virtual machines defined in the script I want to stop, he will do it one by one and checking that the virtual machine is a full stop before you start the process with the other in the list, if for some reason any VM hang time fail safe module where he goes to this fair and stops the machine Virtual anyway, as verification will be nice to get an e-mail us the result.

All ideas are welcome, we experience ever this situation before so I'm open to suggestions in how to approach the issue in the best way, I read online that this can be done by using the priority settings VM defined in the settings of HA or creating folders for virtual machines and stop records based on the priority assigned to the forders VMs at this point, I am very new in PowerCLI and all I have is LucD book.

Thanks in advance.

The AureusStone script works, but if you want a little more advanced than the shutdown procedure, you could do something like that.

The script will read the names of the VM to a CSV file that has this format

"vmName".

"vm1.

"vm2.

"vm3.

The script is powered all the guests who are in the CSV file.

First, he'll try a stop comments, as VMware tools are running.

The script will wait $maxWaitTime seconds from the end.

If the guest is still on, the script will try to power off the power.

Still, the script will wait $maxWaitTime seconds.

If the virtual machine is still running, the script will try to kill him.

When all the guests are made, the script will send an e-mail

$sleepTime = 5 $maxWaitTime = 45
$report = @()
$vmNames = Import-Csv "C:\emergency-shutdown.csv" -UseCulture | %{$_.vmName}

Get-VM -Name $vmNames | where {$_.PowerState -eq "PoweredOn"} | %{

# Guest shutdown     if($_.Extensiondata.Guest.ToolsRunningStatus -ne "guestToolsNotRunning"){
        Shutdown-VMGuest -VM $_ -Confirm:$false        $waitTime = 0        while((Get-VM $_.Name).PowerState -ne "PoweredOff" -and $waitTime -lt $maxWaitTime){
            sleep $sleepTime            $waitTime += $sleepTime        }
        $line = $_.Name + " guest shutdown"    }

# Power off     if((Get-VM $_.Name).PowerState -ne "PoweredOff"){
        Stop-VM -VM $_ -Confirm:$false        $waitTime = 0        while((Get-VM $_.Name).PowerState -ne "PoweredOff" -and $waitTime -lt $maxWaitTime){
            sleep $sleepTime            $waitTime += $sleepTime        }
        $line = $_.Name + " powered off"    }

# Kill     if((Get-VM $_.Name).PowerState -ne "PoweredOff"){
        Stop-VM -VM $_ -Kill -Confirm:$false -RunAsync
        $line = $_.Name + " killed"        sleep $sleepTime    }

# Problem guest     if((Get-VM $_.Name).PowerState -ne "PoweredOff"){
        $line = $_.Name + " problematic shutdown"    }

    $report += $line
}

$from = "[email protected]" $to = "[email protected]" $subject = "Emergency shutdown report " + (Get-Date -Format "yyyy/MM/dd hh:mm")
$body = $report 

$smtpServer = "your smtp server"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($from, $to, $subject, $body)

Tags: VMware

Similar Questions

  • Virtual Infrastructure Client server stop

    We currently manage many machines ESX from a server running Windows 2 k 3 and Virtual Infrastructure Client. If stop us the windows 2 k 3 machine, it will have no effect on the correct ESX servers? All virtual machines will always be operational?

    HA is not dependent on vCenter except for the initial Setup.  So, if you are closing vCenter, maybe just the value of DRS 5 stars leaving HA as it is.  After all if there is a hardware failure, you still want your guests to failover.

  • Cannot stop a virtual machine

    ESX 3.5

    Hello

    I can't stop a running virtual machine.

    There's no way to have a clean shutdown because the virtual machine is not responding (os: ubuntu server 4.x)

    Virtual infrastructure client power off command closes with error: operation failed as another task is underway

    Same error to connect to the server esx and vmware-cmd by train

    & gt; VMware-cmd web2.vmx stop

    VMControl error - 999: unknown error: SoapError: ServerFaultCode (0): (the operation failed because another task is in progress.)

    & gt; VMware-cmd web2.vmx hard stop

    VMControl error - 999: unknown error: SoapError: ServerFaultCode (0): (the operation failed because another task is in progress.)

    Thanks for your suggestions,

    Valter

    You can try one of the following methods of the cli:

    VM-help - x - list of vmid

    VM-support - X < vmid > to kill him...

    or

    PS - auxwww | grep-i < vmname >

    Find the PID and kill-9 pid

    See also http://communities.vmware.com/docs/DOC-2290

  • How can I stop the virtual keyboard appear gestures?

    Hello

    How can I stop the virtual keyboard to appear coincidentally in my game? There is no reason for the player to use the keyboard for the game, so I want to disable it.

    My current solution is to wait for the NAVIGATOR_KEYBOARD_STATE with the NAVIGATOR_KEYBOARD_OPENING State and by calling virtualkeyboard_hide(). But which causes the keyboard to appear a few pixels down before disappearing again.

    Is there a way of elequent more disable the gesture of virtual keyboard?

    Thank you

    Claudine

    I'm afraid, is not possible. If BlackBerry Advisor does not fix me don't waste your time on this. If a user low blows to the left of the keyboard is displayed regardless of your application.

  • I get an error "the disk hard virtual parent is in a saved state. Discard the saved state or stop the virtual machine and try again. "during the installation of XP mode.

    I have Win7 Pro SP1 x 64.  I downloaded WindowsXPMode_en - us.exe (from Microsoft downloads) and run it.  The installation seems to work OK (I've specified a different location for the parent virtual hard disk file).  Then, installation happening and I provide the information requested (name of user and password for the XP Mode), updates Windows and OK to the issue of sharing.  The installation program then reports the following error:

    The disk hard virtual parent is in a saved state.  Discard the saved state or stop the virtual machine and try again.

    I get the error even if I try manually configure XP Mode (use the Setup Wizard).  I downloaded the installer XPMode (3 times) and reinstalled several times, always with the same result.  If it helps, I can't locate anywhere .vsv file.

    Any idea what's going on?

    Original title: XP Mode Setup error

    Hi smithnr10,

     

     

    You must post your question in the TechNet forums because it caters to an audience of it professionals.

    To do this, you must consult the link-

    http://social.technet.Microsoft.com/forums/en-us/w7itprovirt/threads

     

    Hope this helps!

  • Stop the virtual machine

    I'm looking for a script to stop vm...

    Script works fine, but I have a few Questions or details

    $csv = import-csv C:\xxx.csv

    Foreach ($line in $csv)

    {

    Write-Host “====================================================================”

    Write-Host "$line treatment".

    $vminfo = get-view-Id ($line.vm) USER.USER

    Write-Host "checking the VMware Tools on $line... »

    # If we have the VMware tools installed

    If ($vminfo.config.Tools.ToolsVersion - eq 0)

    {

    Write-Host "($line.vm) don't have vmware tools installed, strong power this one.

    # Hard power off.

    Stop-VM ($line.vm)-confirm: $false

    }

    on the other

    {

    write-host "I'll try to stop $vm.

    # Turn off with elegance

    Get - VM ($line.vm) | Stop-VMGuest-confirm: $false | Out-Null

    }

    }

    1. my code below what I'm missing / or hurt?

    $vminfo = get-view-Id ($line.vm) USER.USER

    Write-Host "checking the VMware Tools on $line... »

    2. Tools a lot of combination

    Tools installed - but not running

    tools not install

    Are that both will have to stop-vm?

    3.

    I got a simple code, it will cover the tools stuff?

    $vm = Get-VM
    $vm | where {$_. Comments . State -eq "Running"} | Shutdown-VMGuest -confirm:$false
    $vm | where {$_. Comments . State -eq "NotRunning"} | Stop-VM -Confirm:$false


    4. I want to stop 50 virtual machines simultaneously, how the


    Your script seems to be ok.

    When the VMware tools are installed you can do a gracefull shutdown (Stop-VMGuest) within the guest where OS the obligation for the VMware tools.

    The next option is to stop the virtual machine (VM-Stop), with what would be the power button on a physical computer.

    No phasing out of the BONES and a potential risk on the corruption of the OS.

    With switch RunAsync that the cmdlet returns immediately, it will not wait until the underlying vSphere method is complete.

    The method will continue, but in the background.

    You should check these tasks to background (Get-task), to monitor the successful completion.

    To manage VMS in batches of 25 and wait 60 seconds between batches, you could do something like that

    $vms = get - VM

    $step = 25

    $start = 0

    for ($loop = 0; $loop - the ([math]: ceiling ($vms.)) Step Count / $)-1); $loop ++) {}

    $vms [$start... ($Start+$Step-1)] | where {$_.} Guest.State - eq "Running"} | Stop-VMGuest-confirm: $false - RunAsync

    $vms [$start... ($Start+$Step-1)] | where {$_.} Guest.State - eq "Keep"} | Stop-VM-confirm: $false - RunAsync

    sleep 60

    $start += $step

    }

  • Client of Virtual Infrastructure ESX v3.0.2

    Is there a newer release or replacement beyond VMWare Virtual Infrastructure Client 2.0?  Even if our server is VMware ESX Server 3.0.2, when you download client is still v2.

    Thank you

    Virtual Infrastructure Client version corresponds to the version number of Virtual Center ot - so for ESX 3.0.x version of Virtual Center number is 2.0.x and the VI Client is 2.0.  If you want to upgrade your environment to ESX 3.5/VC 2.5 your VI client will go to 2.5 - and if you upgrade to vSphere all numbders version 4.0

    If you find this or any other answer useful please consider awarding points marking the answer correct or useful

  • You must stop your request before the engine may stop

    I have an integrated application that uses LV DSC 6.0.2. The application starts and stops the engine tag programmatically. The application works fine, but on some machines, I'll get continuously the next dialog box when I try to stop the engine of the tag:

    "You must stop your request before the engine may stop"

    It's strange, because it only happens on some machines (it seems that it can occur on computers with ONLY of DSC Run-Time installed, not the full dev system. DSC LV).

    The dialog seems to refer to the application of 'control' which tries to stop the engine... it isn't telling me that my devices servers need to be stopped.

    This dialog box does not seem logical, I should be able
    to build an application that can start and stop the engine... and why I get this dialog on some machines but not on others?

    John Paul,

    There are two points that we should ask ourselves:
    1: you can have different loops while in your application where you read/write to and from the engine of the tag with the read/write Tag.vi. These screws has a stop of production which must be wired first the while loop. If you have cases where you do not connect this output to your time stop loop you could access the engine while you want to stop the engine in another loop with the Shutdown.vi engine. -> Make sure you have all drivers of DSC to access loops has stopped before you turn off the engine.

    2nd: I guess he was once an issue of race with the DSC engine condition and how it access to shared memory with the read/write Tag.vi. But this condtion of race must be agreed with the version of LabVIEW DSC
    6.1 or with other fixes for LabVIEW DSC 6.0.2. You can download patches (in this case, particularly the BVRTDatabase.dll) driver update page & of NOR: www.ni.com/support/ > Option 3, drivers and updates > Search drivers and updates > type 'LabVIEW DSC' > choose LabVIEW Datalogging and Supervisory Control 6.0.2 fixes.
    You must apply the patches of this as well on your DSC 6.0.2 Run Time System!

    I hope that one of the help of two suggestions to solve your problem.

    Concerning
    Roland

    FTP://FTP.NI.com/support/LabVIEW/labviewdsc/fixes/6.0.2/

  • HP Officejet Pro 8610: hp officejet 8610 printer error "Please stop your printer, and then click.

    When I turn on my HP Officejet Pro 8610 - it goes through its cycle - once it ends the initialization of the startup LCD flashes a Blue Screen of Death with B8931C7C for less than a second, then the screen shows printer error "Please stop your printer, and then click.

    I've tried so far, I've tried it unpluggin at the back, wait 15 seconds and 60 seconds.  Also this operation and in him plugging in several power strips and directly into the wall outlet.

    I was able to restore the default settings at one time.  This questions has gradually deteriorated to the point that wow its very pretty in a loop without end with failure - consistantly crashing after start up - please advise.

    Hi @mrberad,

    Welcome to the Forums of HP Support!

    I understand that your printer HP Officejet Pro 8610 is stuck in an error state. I'd be happy to help you and don't forget to come back to this thread and check "Accept as Solution" if I helped successfully will solve you the problem. If you want to say 'Thank you' to my effort to help, click on the "thumbs up" to give me a Kudos.

    I can see how frustrating, it would be for you. The error you receive is usually related to a general printer error, sometimes leading to a hardware problem.

    I take a flashlight and look inside the obstruction.

    Use this guide to check obstructions:

    I see that you reset the default printer. Have you tried a reset complete semi? I can send you this information in a private message. In the forum next to your handle name simply click on the envelope to see.

    If you have completed all the above steps and your product still has a problem, service the product.

    If the printer is buyer's remorse period, you can take that back at the point of sale or contact HP.

    Contact HP for service in all countries except Asia-Pacific.
    What you can do, is to use the following link to create yourself a file number, then call and it can help to expedite the appeal process:
    Step 1. Open the link: www.hp.com/contacthp/
    Step 2. Enter the product number or select Auto detection
    Step 3. Scroll up to "still need help? Fill out the form to select your contact options.
    Step 4. Scroll down and click on options contact HP - click Get phone number
    File number and phone number are displayed.

    Please reply to this message with the result of your troubleshooting. I can't wait to hear strings attached good luck!

  • Your system is low on virtual memory. Windows is increasing the size of your virtual memory paging file. This process may be denied requests for some applications.

    When I start my laptop I get "your system is low on virtual memory. Windows is increasing the size of your virtual memory paging file. This process may be denied requests for some applications. "and my laptop takes forever or does not open my programs. any help? Thank you.

    less than low disk space,

    What seems to be the case, it's that your windows is having a hard time resize its file for virtual memory.

    my suggestion is to remove "auto" at that time, and then set a custom format.

    I recommend that you set the initial size of 2 and max at 1152.

    Here's how to put a link:

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-the-size-of-virtual-memory

    DB·´¯'·.. ¸ > DatabaseBen, Retired Professional - Analyst - Database Developer's - accounting - former veteran of the Armed Forces - @Hotmail.com 'share nirvana mann' - dbZen ~ ~ ~ >

  • Is client vSphere was previously known as Virtual Infrastructure Client?

    Is client vSphere was previously known as Virtual Infrastructure Client if not, what is Virtual Infrastructure Client? What its use?

    Yes, vSphere Client in current versions of release of vSphere used be known as VI Client Virtual Infrastructure 3. See one of the old brochure of vmware Web site at the following url for 3 VI.

    http://www.VMware.com/files/PDF/vi_brochure.PDF

  • Commands to start and stop a virtual machine hosted by VMware player

    Where can I find the commands to start and stop a virtual machine hosted by VMware player on a host Windows Server 2008 R2 (64-bit)?

    I need to start and stop the virtual computer from a script as I could do this by selecting the ' power on ' and his 'guest stop' or at least 'power off' options of the GUI of VMware player.

    If a control interface is not available, is available if I update to VMware Workstation?

    Concerning

    Marius

    With the player, the VIX API is a separate download (on the same page you downloaded the install drive in), so I guess you will have to install the separate package to use it.  But it's pretty easy to do...

  • Most were frequently reported issues in the virtual infrastructure

    Hai everybody,

    I will lead administration vmware in my organization newly implemented. I have good theoretical knowledge on VMware Virtual Infrastructure 3. so before you go to that I want to know the mostfrequently took place at problems with solutions. Is there any room for this good response.

    Thanking you.

    Hello

    Tips form my experience:

    1. Be very careful with snapshots - not to keep in them long - you could basically trouble and performance degradation when the shots become big
    2. try to avoid if possible the RDM (booking SCSI problems)
    3. Keep an eye on you, SAN - 80% of performance problems comes from a bad configuration of the SAN
    4. When you do the maintenance of the network always disable the monitoring host and DRS value manual
    5. VMFS using VI client, be sure to make and configure the maximum block size (8MB) - it will save you a lot of time in a future
    6. avoid VMFS extends if possible
    7. keep servers ESX/ESXi and vCenter to build the highest level - a lot of problems have been corrected in the new updates or patches
    8. restrict access to the server vCenter - not everything needs to access everything
  • Virtual infrastructure HA

    Salve,
    all'interno della mia internationalist stiamo implementazione di una virtual infrastructure, Vmware hypervisor con prevedendo, che personal Alta Affidabilita, Vmotion, como principi cardine fault tolerance.

    The sara cosi Architettura composed:

    Nr.2 gia ns server. possesso, con processore Xeon E54XX, equipaggiati con due schede iscsi each, sas 10 k 2.5 "hd;

    Nr.1, da server acquistare, con processore Xeon E56XX, equipaggiato con due schede iscsi, hd 15 k sas 3.5 ";

    Nr.1 storage iscsi controller double da acquistare (fujitsu dx60, dx80 oppure ibm ds3512) knew cui andare a collegare I have server in direct attach (especially nel caso di dx80 o ibm ds3512 che hanno 8 door iscsi)

    VMware Vsphere essential more o probabilmente Vsphere Advanced (per sfruttare it fault tolerance)

    I like to share con voi personal seguenti:

    (1) Ho appreso che e best practice proven architecture hardware dei nodi Server quanto più faux per avere una effective virtual infrastructure. Avere una sostanziale difference nei processori (E54XX ed E56XX) e negli interni AI Server (2.5 "e 3.5") Può published a problema serio di drive performance hard ed affidabilita?


    (2) Greece di outdo tra Server e sara 1.0 Gb/s ISCSI storage. como posso sapere e understand is questo non costituira UN collo di bottiglia all'infrastruttura works che questa supportera UN total di 8 Server virtuali per servizi di exchange 2007, sql, file server, dc, dns by a total di 40 users?

    Grazie.

    Ciao,.

    'a level is di principio' any switch e sufficiente, my be we want essere corretti, no..

    TRA him varies features che dovresti links nello choose a product of io annovererei:

    -full wire speed/non-blocking: name diversi usano termini diversi in no. e dello switch guarantee the contemporanea Velocità massima di su ability all the door

    -supporto by vlan tagging, to the usi Reed knew ESX e switch so you can use the same storage with iscsi

    -supporto per jumbo frames

    Altre funzioni sound very gradite is presenti ma no obbligatorie.

    Inizierei ad annoverare the door 10 Gbit o at least wear gbic by prevedere one ' expansion futura, oramaci if sta iniziando a spread.

    Ciao,.

    Luca.

    --
    Luca Dell'Oca
    [Assegnare punti a useful risposta e una a modo di say thank you]
  • A private virtual infrastructure design

    I'm looking for a few good strategies for the creation of the sectoral areas of virtual infrastructure where administrators can delegate control limited users to their own virtual machines.  I'm open to solutions and strategies such as applications that plug in vmware or to use what already exists in VMware based on the software - this reference books would be useful too.

    The concept is that some groups of virtual machines have their traffic segmented all LAN users, but able to commicate between them and able to access internet. All virtual machines for these users are in vSphere.  Another goal is to limit the licensing costs by allowing them to use an existing environment vSphere and buy more licenses as little as possible - giving them a limited admin functions but no control over the environment.

    vCloud Director will do that - but there is a cost associated.

    http://www.VMware.com/products/vCloud-Director/

    If you want something more profitable then PVlans will also control VM communication - but you need company more licenses.

    http://www.VMware.com/files/PDF/VMW_09Q1_WP_vSphereNetworking_P8_R1.PDF

    For delegated admin vSphere is very granular in this regard.

    Both ends of the spectrum - completely automated with a cost or cheapish and good mood

Maybe you are looking for

  • Cloud email &amp; gmail emails

    Hi all Thank you for taking the time to help me here. I am a small business owner and I'm working on a system solution / 'better' for how to store my emails. I have my apple mail account that I have every email of significance to the business for the

  • Re: Satellite C660-13R - graphics card update

    Hello I want a new graphics card for my laptop satellite, but I was told can not change just what I have in my room does not work the game diablo 3 and I don't have the money to buy a new pc, so I wanted to buy just a upgrade for it can anyone tell m

  • Is possible to create the WINS resource record in DNS server and how?

    Is possible to create the WINS resource record in DNS server and how? No resource record WINS I can create when it right click on and select "other new records".

  • LaserJet Pro M177fw: LaserJet Pro M177fw: paper hangs when printing

    Whenever I print the paper gets stuck less than halfway so that the printer display says 'Printing', I cleared the jam several times and tried different settings and it won't work. The book is very good, I tried it on LaserJet Pro my brother. I tried

  • How to recover deleted Windows 7 fonts without making a system restore

    Hello Last summer, I deleted a number of fonts Windows 7 I knew I was never going to use. Unfortunately, I accidentally deleted some I really wanted to delete. But I let it pass in time. Now, I wish I had some of those back that I accidentally delete