Virtual Kim

@Kim_Bottu … Virtually Gung Ho

Put ESXi host in Maintenance, move specific VM to specific ESXi host, create backup of Host configuration

Write-Host
#1. Script puts $Host in Maintenance mode.
#2. Script moves the specific VM’s to a specific host called $Destination
#3. Script will create a backup of the ESXi configuration of host $Host to C:\HostBackups
# If the script seems to hang, tap the space bar, the script will continue.
# Change the name of $VMHost, $Destination and the reference to the specific VM’s (VMSpecial*) in the script.

$VMHost = host1.esxi.local
$Destination = host2.esxi.local

#1. Script puts Host in Maintenance mode.

Write-host Put Host in Maintenance mode and allow the execution of code while the host is still not in maintenance mode.

$task = Set-VMHost -VMHost $VMHost -State “Maintenance” -RunAsync

Write-Host

#2. Move the specific VM’s to specific $Destination

Write-host
Get-VM -Name VMSpecial* | Move-VM -Destination $Destination
Write-Host

write-host SPecific VM’s have been moved

Write-Host

#3. Back up ESXi configuration to C:\HostBackups

Write-Host “Backing up ESXi config to C:\HostBackups”

Write-Host

Get-VMHostFirmware -VMHost $VMHost -BackupConfiguration -DestinationPath C:\HostBackups

Write-Host “Backup is completed!”

Write-Host

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on March 16, 2015 by in Backup, ESXI, PowerCLI, Script and tagged , , , .
Follow Virtual Kim on WordPress.com

Blog Stats

  • 25,689 hits
%d bloggers like this: