Public/Set-HPWFAlertMarker.ps1

Function Set-HPWFAlertMarker {
    <#
        .SYNOPSIS
            Sets the red, yellow, and return to green marker levels for the protected volume.
        .DESCRIPTION
            Sets the red, yellow, and return to green marker levels for the protected volume.
        .PARAMETER DriveLetter
            The driveletter of the protected volume to set
        .PARAMETER RedMarker
            The value for the red marker.
        .PARAMETER YellowMarker
            The value for the yellow marker.
        .PARAMETER GreenMarker
            The value for the green marker.
        .INPUTS
            System.IO.DriveInfo
            System.Int
        .OUTPUTS
            Returns 0 when successful. Otherwise, it returns an error code.
        .EXAMPLE
            Set-HPWFAlertMarker -DriveLetter C: -RedMarker 256 -YellowMarker 512 -GreenMarker 768
        .LINK
            about_functions_advanced
        .LINK
            about_CommonParameters
        .LINK
            http://h10032.www1.hp.com/ctg/Manual/c06173592
    #>

    [CmdletBinding(
        SupportsShouldProcess = $true,
        ConfirmImpact = "Medium"
    )]
    [OutputType('HPWriteManager.Alert.Marker.Information')]
    Param(
        [Parameter( Mandatory = $true )]
        [ValidateScript( { Test-IsDriveLetter $_ })]
        [System.IO.DriveInfo]$DriveLetter,
        [Parameter( Mandatory = $true )]
        [ValidateScript( { [Convert]::ToInt64($_) })]
        [int]$RedMarker,
        [Parameter( Mandatory = $true )]
        [ValidateScript( { [Convert]::ToInt64($_) })]
        [int]$YellowMarker,
        [Parameter( Mandatory = $true )]
        [ValidateScript( { [Convert]::ToInt64($_) })]
        [int]$GreenMarker
    )
    Begin { }
    Process {
        If ($null -ne $HpWF) {
            If ($PSCmdlet.ShouldProcess($DriveLetter, "Set Red/Yellow/Green marker to: $RedMarker / $YellowMarker / $GreenMarker")) {
                $Ret = $HpWF.SetAlertMarkers($DriveLetter, $RedMarker, $YellowMarker, $GreenMarker)
                If ($Ret.ReturnValue -gt 0) {
                    Throw "Setting alert markers on volume $DriveLetter failed with error $Ret.ReturnValue"
                } Else {
                    $Markers = [PSCustomObject]@{
                        DriveLetter  = $DriveLetter
                        RedMarker    = $HPPVI.RedMarker
                        YellowMarker = $HPPVI.YellowMarker
                        GreenMarker  = $HPPVI.GreenMarker
                    }
                    $Markers.PSObject.TypeNames.Insert(0, 'HPWriteManager.Alert.Marker.Information')
                }
            }
        }
    }
    End {
        If ($Markers) {
            Return $Markers
        }
    }
}