Public/Set-HPDCFlushCount.ps1

Function Set-HPDCFlushCount {
    <#
        .SYNOPSIS
            Sets the number of system flush operations that the flush operation can occur before causing a flush of the HpCache cache.
        .DESCRIPTION
            Sets the number of system flush operations that the flush operation can occur before causing a flush of the HpCache cache.
        .PARAMETER DiskNumber
            The disknumber to set the flush count for.
        .PARAMETER FlushCount
            The number of flush operations.
        .INPUTS
            System.UInt32
        .OUTPUTS
            Returns 0 when successful. Otherwise, it returns an error code.
        .EXAMPLE
            Set-HPDCFlushCount -DiskNumber 0 -FlushCount 5
        .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 disknumber to set the flush count for."
        )]
        [UInt32]$DiskNumber,
        [Parameter(
            Mandatory = $true,
            HelpMessage = "The number of flush operations."
        )]
        [UInt32]$FlushCount
    )
    If ($Null -ne $HpDC) {
        If ($PSCmdlet.ShouldProcess($DiskNumber, "Set the number of system flush operations to $FlushCount")) {
            $Ret = $HpDC.SetFlushCount($DiskNumber, $FlushCount)
            If ($Ret.ReturnValue -gt 0) {
                Throw "Flush count NOT changed on disk $DiskNumber - Error: $Ret.ReturnValue"
            } Else {
                Write-Output "Flush count set to" $FlushCount "on disk" $DiskNumber "on next boot"
            }
        }
    }
}