Public/Invoke-HPWFNextSession.ps1

Function Invoke-HPWFNextSession {
    <#
        .SYNOPSIS
            Forces the next session to immediately take effect without a reboot.
        .DESCRIPTION
            Forces the next session to immediately take effect without a reboot.
        .PARAMETER Driveletter
            The driveletter to force the next session on.
        .INPUTS
            System.IO.DriveInfo
        .OUTPUTS
            Returns 0 when successful. Otherwise, it returns an error code.
        .EXAMPLE
            Invoke-HPWFNextSession -DriveLetter C:
        .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
        )]
        [ValidateScript( {
                Test-IsDriveLetter $_
            })]
        [System.IO.DriveInfo]$DriveLetter
    )
    If ($Null -ne $HpWF) {
        If ($PSCmdlet.ShouldProcess($DriveLetter, "Force next for volume")) {
            $Ret = $HpWF.ForceNextSession($DriveLetter)
            If ($Ret.ReturnValue -gt 0) {
                Throw "Force next for volume $DriveLetter failed with error $Ret.ReturnValue"
            } Else {
                Write-Output "Force next for volume $DriveLetter succeeded!"
            }
        }
    }
}