New-ResourcePool
VMware: Creates a new resource pool
#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$VIServer,
[Parameter(Mandatory = $true)]
[pscredential]$VICredential,
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[string]$VMHost,
[bool]$CpuExpandableReservation,
[int64]$CpuLimitMhz,
[int64]$CpuReservationMhz,
[ValidateSet("Custom", "High", "Low", "Normal")]
[string]$CpuSharesLevel,
[bool]$MemExpandableReservation,
[decimal]$MemLimitGB,
[decimal]$MemReservationGB,
[ValidateSet("Custom", "High", "Low", "Normal")]
[string]$MemSharesLevel,
[int32]$NumCpuShares,
[int32]$NumMemShares
)
Process {
try {
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$pool = New-ResourcePool -Server $vmServer -Location $VMHost -Name $Name -Confirm:$false -ErrorAction Stop
$setArgs = @{ ErrorAction = 'Stop'; Server = $vmServer; ResourcePool = $pool; Confirm = $false }
if ($PSBoundParameters.ContainsKey('CpuExpandableReservation')) { $pool = Set-ResourcePool @setArgs -CpuExpandableReservation $CpuExpandableReservation }
if ($PSBoundParameters.ContainsKey('CpuLimitMhz')) { $pool = Set-ResourcePool @setArgs -CpuLimitMhz $CpuLimitMhz }
if ($PSBoundParameters.ContainsKey('CpuReservationMhz')) { $pool = Set-ResourcePool @setArgs -CpuReservationMhz $CpuReservationMhz }
if ($PSBoundParameters.ContainsKey('CpuSharesLevel')) { $pool = Set-ResourcePool @setArgs -CpuSharesLevel $CpuSharesLevel }
if ($PSBoundParameters.ContainsKey('MemExpandableReservation')) { $pool = Set-ResourcePool @setArgs -MemExpandableReservation $MemExpandableReservation }
if ($PSBoundParameters.ContainsKey('MemLimitGB')) { $pool = Set-ResourcePool @setArgs -MemLimitGB $MemLimitGB }
if ($PSBoundParameters.ContainsKey('MemReservationGB')) { $pool = Set-ResourcePool @setArgs -MemReservationGB $MemReservationGB }
if ($PSBoundParameters.ContainsKey('MemSharesLevel')) { $pool = Set-ResourcePool @setArgs -MemSharesLevel $MemSharesLevel }
if ($PSBoundParameters.ContainsKey('NumCpuShares')) { $pool = Set-ResourcePool @setArgs -NumCpuShares $NumCpuShares }
if ($PSBoundParameters.ContainsKey('NumMemShares')) { $pool = Set-ResourcePool @setArgs -NumMemShares $NumMemShares }
$result = $pool | Select-Object *
if ($null -ne $result) { $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force }
}
catch { throw }
finally { if ($null -ne $vmServer) { Disconnect-VIServer -Server $vmServer -Force -Confirm:$false -ErrorAction SilentlyContinue } }
}IP address or DNS name of the vSphere server
PSCredential object for authenticating with the server
Name for the new resource pool
Host on which to create the resource pool
CPU reservation can grow beyond the specified value
CPU usage limit in MHz
Guaranteed CPU in MHz
CPU allocation level: Custom, High, Low, Normal
Memory reservation can grow beyond the specified value
Memory usage limit in GB
Guaranteed memory in GB
Memory allocation level: Custom, High, Low, Normal
Number of CPU shares (used with Custom level)
Number of memory shares (used with Custom level)