Monday, January 2, 2017

Custom WFA Command : Set volume autosize threshold percentage

Set volume autosize threshold percentage

When you modify a volume, these are 2 settings you can't modify in the default command.  So here is a custom command to do it.

Download DAR

For the nerds among us :), here is the code

param (
   [parameter(Mandatory=$true, HelpMessage="Cluster IP address")]
   [parameter(Mandatory=$true, HelpMessage="Volume name")]
   [parameter(Mandatory=$true, HelpMessage="Storage Virtual Machine name")]
   [parameter(Mandatory=$false, HelpMessage="The threshold percentage when autogrow must be triggered")]
   [parameter(Mandatory=$false, HelpMessage="The threshold percentage when autoshrink must be triggered")]

# connect to controller
Connect-WfaCluster $Cluster

#testing volume existence. this command somehow doesn't throw exception if
# ErrorAction is 'Stop' and the volume isn't found. adding if block

$vol = Get-NcVol -Name $VolumeName -Vserver $VserverName
   throw "Volume '$VolumeName' not found on Storage Virtual Machine '$VserverName'"

if (!$GrowThresholdPercent -and !$ShrinkThresholdPercent)
   throw "At least one of the volume attributes that can be modified by this command must be provided."

   $vol | Set-NcVolAutoSize -ShrinkThresholdPercent $ShrinkThresholdPercent -ErrorAction Stop

   $vol | Set-NcVolAutoSize -GrowThresholdPercent $GrowThresholdPercent -ErrorAction Stop

No comments :

Post a Comment