Hello Adai,
You can use part of certified commmand "remove volume", only concerning checking, dismounting and offlining and create a new one that could be have this look:
param (
[parameter(Mandatory=$true, HelpMessage="Cluster IP address")]
[string]$Cluster,
[parameter(Mandatory=$true, HelpMessage="Volume name")]
[string]$VolumeName,
[parameter(Mandatory=$true, HelpMessage="Storage Virtual Machine name")]
[string]$VserverName
)
# connect to cluster
Connect-WfaCluster $Cluster
$lastConnectedCluster = $Cluster
$clusterInfo = Get-NcCluster
# Testing volume existence. As this command doesn't throw exception if
# ErrorAction is 'Stop' and the volume isn't found. So, an explicit check.
$vol = Get-NcVol -Name $VolumeName -Vserver $VserverName
if(!$vol)
{
throw "Volume '$VolumeName' not found on Storage Virtual Machine '$VserverName'"
}
# Dismount the volume from the Storage Virtual Machine namespace if it is not the Storage Virtual Machine root volume
if (!$vol.VolumeStateAttributes.IsVserverRoot)
{
Get-WFALogger -Info -message $("Dismounting volume: " + $VolumeName + " on Storage Virtual Machine " + $VserverName)
Dismount-NcVol -Name $VolumeName -VserverContext $VserverName -Force -ErrorAction Stop
}
$volState = (Get-NcVol -Name $VolumeName -VserverContext $VserverName).State
if($volState -ne "offline")
{
Get-WFALogger -Info -message $("Offlining volume: " + $VolumeName + " on Storage Virtual Machine " + $VserverName)
Set-NcVol -Name $VolumeName -VserverContext $VserverName -Offline -ErrorAction Stop
}
François