Public/Set-HPDCCacheSize.ps1

Function Set-HPDCCacheSize {
    <#
        .SYNOPSIS
            Sets the maximum size, in MB, that the cache can grow to.
        .DESCRIPTION
            Sets the maximum size, in MB, that the cache can grow to. If the AllocationPolicy is 'Static', the cache will be instantiated at this size.
        .PARAMETER DiskNumber
            The number of the disk to set the cache size for.
        .PARAMETER CacheSize
            The size of the cache.
        .INPUTS
            System.Int
        .OUTPUTS
            Returns 0 when successful. Otherwise, it returns an error code.
        .EXAMPLE
            Set-HPDCCacheSize -DiskNumber 0 -CacheSize 256
 
            Set's the cachesize for disk 0 to 256 MB
        .LINK
            about_functions_advanced
        .LINK
            about_CommonParameters
        .LINK
            http://h10032.www1.hp.com/ctg/Manual/c06173592
    #>

    [CmdletBinding(
        SupportsShouldProcess = $true,
        ConfirmImpact = "Medium"
    )]
    Param(
        [Parameter(
            Mandatory = $true,
            HelpMessage = "The number of the disk to set the cache size for."
        )]
        [Int]$DiskNumber,
        [Parameter(
            Mandatory = $true,
            HelpMessage = "The size of the cache in MB."
        )]
        [ValidateScript( {
                [Convert]::ToInt64($_)
            })]
        [Int]$CacheSize
    )
    If ($Null -ne $HpDC) {
        If ($PSCmdlet.ShouldProcess($DiskNumber, "Set cache size to $CacheSize MB")) {
            $Ret = $HpDC.SetCacheSize($DiskNumber, $CacheSize)
            If ($Ret.ReturnValue -gt 0) {
                Throw "Cache size NOT set on disk $DiskNumber - Error: $Ret.ReturnValue"
            } Else {
                Write-Output "Cache size set to $CacheSize MB on disk $DiskNumber on next boot"
            }
        }
    }
}