Thursday, May 5, 2016

PowerCLI Add RAM and Reservation to VM cluster

# Add the PowerCLI snapin
    Write-Host "Adding PowerCLI Snapin" -ForegroundColor Green
    Add-PsSnapin vmware.vimautomation.core


####Set VM RAM to 3500
#############################################

# Inputs
$clusterObj = Get-Cluster -Name 'XenDesktop'
$vmPrefix = 'PCDCW732'

# Create VM cust spec
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.MemoryMB = 3072

# Get VM Objects
$vms = $clusterObj | Get-VM | where {$_.Name -match $vmPrefix}

# Perform reconfiguration
$vms | %{
 $currentVM = $_
 ($currentVM).ExtensionData.ReconfigVM_Task($spec)
}

###VM reservation
########################
# Inputs
$clusterObj = Get-Cluster -Name 'XenDesktop'
$vmPrefix = 'PCDCW732'

# Create VM cust spec
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.memoryReservationLockedToMax = $true

# Get VM Objects
$vms = $clusterObj | Get-VM | where {$_.Name -match $vmPrefix}

# Perform reconfiguration
$vms | %{
 $currentVM = $_
 ($currentVM).ExtensionData.ReconfigVM_Task($spec)
}

No comments:

Post a Comment

Vmware NSX SSL creation 

Using OpenSSL for NSX Manager SSL import: Creates CSR and 4096 bit KEY Creating NSX 6.4.2 SSL    openssl req -out nsxcert.csr -newkey rsa:40...