Public/Add-HPWFExclusion.ps1

Function Add-HPWFExclusion {
    <#
        .SYNOPSIS
            Adds a file or directory to the file exclusion list for the next session.
        .DESCRIPTION
            Adds a file or directory to the file exclusion list for the next session.
        .PARAMETER Path
            The path that needs to be excluded
        .INPUTS
            System.IO.FileInfo
        .OUTPUTS
            Returns 0 when successful. Otherwise, it returns an error code.
        .EXAMPLE
            Add-HPWFExclusion -Path C:\Excluded_Path
        .LINK
            about_functions_advanced
        .LINK
            about_CommonParameters
        .LINK
            http://h10032.www1.hp.com/ctg/Manual/c06173592
    #>

    [CmdletBinding(
        SupportsShouldProcess = $true,
        ConfirmImpact = $true
    )]
    Param(
        [Parameter(Mandatory = $true)]
        [System.IO.FileInfo]$Path
    )
    If ($null -ne $HpWF) {
        If ($PSCmdlet.ShouldProcess($Path, "Add to exclusion list")) {
            $Ret = $HpWF.AddExclusion($Path)
            If ($Ret.ReturnValue -gt 0) {
                Throw "Exclusion path $Path was NOT added. Error: $Ret.ReturnValue"
            } Else {
                Write-Output "Exclusion path $Path added successfully."
            }
        }
    }
}