Putting aside why this happened and how it could have been prevented, we just needed to fix it quickly. So, I put on my PowerCLI hat and pounded out the following....
$findvm = Read-Host -Prompt "Missing VM Name"
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false
$esxservers = get-content "c:\esxiplist.txt"
Connect-VIServer -Server $esxservers
$vmlist = (Get-VM | select -expandproperty name)
foreach ($vm in $vmlist)
{
if ($vm -eq $findvm)
{
Write-Host "$findvm was located on $esxserver"
exit
}
}
Write-Host "$findvm was not located on any host"
The file
esxiplist.txt
contained the IP addresses for each host (one per line). This could be made a lot prettier but for our purposes worked well enough to locate the SQL server plus another handful of critical VMs which were also down. This script assumes that your login credentials are the same for each ESX host.
No comments:
Post a Comment