Public/Enable-HPDCDiskCaching.ps1
Function Enable-HPDCDiskCaching { <# .SYNOPSIS Enables caching on the specified disk .DESCRIPTION Enables caching on the specified disk .PARAMETER DiskNumber The disknumber to enable caching on. .INPUTS System.Int .OUTPUTS Returns 0 when successful. Otherwise, it returns an error code. .EXAMPLE Enable-HPDCDiskCaching -DiskNumber 0 This will enable disk caching on disk 0 .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)] [Int]$DiskNumber ) If ($null -ne $HpDC) { If ($PSCmdlet.ShouldProcess("DiskNumber: $DiskNumber", "Enable disk caching")) { $Ret = $HpDC.EnableCaching($DiskNumber) If ($Ret.ReturnValue -gt 0) { Throw "Caching NOT enabled on disk $DiskNumber - Error: $Ret.ReturnValue" } Else { Write-Output "Caching enabled on disk"$DiskNumber ForEach ($Item in $HPDCI) { If ($Item.DiskNumber -eq $DiskNumber) { Write-Warning "Caching set to $Item.CachingEnabled for disk $Item.DiskNumber on next boot" } } } } } } |