Start A Guest VM using Powershell and PowerCLI
This script is for
scheduled task to check a VM (guest) and make sure it is running. If the VM is
down it restarts it.
Note: Depending on your server you may need to install PowerShell if it is not
already installed. Also, PowerCLI is not installed by default.
#this
line loads PowerCli
Add-PSSnapin
VMware.VimAutomation.Core
#
This line connects to the vCenter server
Connect-VIServer
-Server vCENTERIPHERE -User LOGINNAMEHERE -Password PASSWORDHERE
#this
line checks the powerstate
$objState
= Get-VM GUESTVMNAME | Select-Object PowerState
If
($objState -match "ff") {Get-VM GUESTVMNAME | Start-VM}
#if
you need to check multiple machines just add the last two lines and change the
VM guest name
Comments
Post a Comment