Tag Archives: vCenter

Enable Hot Add vCPU and Memory on VMs using PowerShell (V2)

This is a script which will allow you to enable the Hot Add vCPU and Memory feature on all or a sub set of your VMs.

IMPORTANT NOTE – the script will recursively power off each VM defined in CSV (unless Hot Add is already enabled), apply the config then power each VM back on. So make sure you run this script in an outage window.

When creating the CSV, make sure to include the header row – Name.

The script will also generate a log file.

Continue reading

Enable Hot Add vCPU and Memory on VMs using PowerShell

I’ve got a new version of this script at this link.

This is a simple script which will allow you to enable the Hot Add vCPU and Memory feature on all or a sub set of your VMs.

IMPORTANT NOTE – the script will recursively power off each VM defined in CSV, apply the config then power each VM back on. So make sure you run this script in an outage window.

When creating the CSV, make sure to include the header row – Name.

#Function to generate wait time progress bar
function Start-Sleep($seconds) {
    $doneDT = (Get-Date).AddSeconds($seconds)
    while($doneDT -gt (Get-Date)) {
    $secondsLeft = $doneDT.Subtract((Get-Date)).TotalSeconds
    $percent = ($seconds - $secondsLeft) / $seconds * 100
    Write-Progress -Activity "Sleeping" -Status "Sleeping..." -SecondsRemaining 
    $secondsLeft -PercentComplete $percent
    [System.Threading.Thread]::Sleep(500)
    }
Write-Progress -Activity "Sleeping" -Status "Sleeping..." -SecondsRemaining 0 - 
Completed
}

#Variables
$HotAddVMs = Import-CSV c:\temp\hot_add_disabled_vms.csv
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.CpuHotAddEnabled = "True"
$vmConfigSpec.MemoryHotAddEnabled = "True"

Foreach ($VM in ($HotAddVMs)) {
    
    #Shutdown Guest OS / Power off VM
    Get-VM $VM.Name | Shutdown-VMGuest -Confirm:$false

    #Wait for VM to power off before executing config cmd  
    section – in which case the config cmd will fail 
    while((Get-VM $VM.Name).PowerState -ne 'PoweredOff') {

    Start-Sleep -Seconds 10
    }
    
    #Execute config cmd
    $VMConfig = Get-View -VIObject $VM.Name
    $VMConfig.ReconfigVM($vmConfigSpec)

    #Power on VM
    Get-VM $VM.Name | Start-VM   
}


Veeam V9.0 U2: Backup AlwaysOn SQL instance hosting vCenter database

Recently I was troubleshooting a Veeam backup issue for a client who is utilizing the Always-On SQL architecture in their environment.  The client was receiving the following error when trying to backup any of their Always-On SQL instances:

“Failed to freeze guest, wait timeout”

Note that the backup jobs started failing right after migrating the client’s vCenter databases across to the Availability Groups hosted on the Always-On SQL instances.

The only bit of literature I could find on backing up AlwaysOn SQL instances was in this (not very helpful) Veeam guide.

So I’ve dug a little deeper and found this Veeam KB article, which suggests the issue maybe with the vCenter database failing to be excluded from Application-Aware image processing.

Continue reading