Public/Protect-HPWFVolume.ps1
Function Protect-HPWFVolume { <# .SYNOPSIS Adds a volume to the protected list for the next session. .DESCRIPTION Adds a volume to the protected list for the next session. .PARAMETER DriveLetter The driveletter to add to the protected list. .INPUTS System.IO.DriveInfo .OUTPUTS Returns 0 when successful. Otherwise, it returns an error code. .EXAMPLE Protect-HPWFVolume -DriveLetter C: .EXAMPLE Another example of how to use this cmdlet .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, "Enable protection on volume")) { $Ret = $HpWF.ProtectVolume($DriveLetter) If ($Ret.ReturnValue -gt 0) { Throw "Enabling protection on volume $DriveLetter failed with error $Ret.ReturnValue" } Else { Write-Output "protection on volume $DriveLetter succeeded!" } } } } |