I am using WFA 3.1 on Windows. I'm looking at the cm_storage 'Remove Volume' command. I believe I have found an issue with the existing powershell script. (I haven't reviewed the perl side, and am not a perl script writer.)
On line 29, where you define $vsmAsSource, you are performing a get-ncsnapmirror to determine if the volume is the source of a snapmirror relationship. The problem with that command is that if the snapmirror destination lives outside the clusteryou are currently connected to, it will return with 0 results. This then causes an error later down the line of the command since the volume still potentially has a snapmirror relationship connected to it. In its place you should be running the 'get-ncsnapmirrordestination' commandlet to get the true results.
Attached is my stab at fixing the powershell script. It worked for me. (Note: I have barely tested this so there could be more enhancements needed)
From the logic provided we are able to get Snapmirror destination cluster name which is not FQDN , so we can’t connect to destination cluster using cluster name, and there is limitation to get destination cluster IP, we suggest before removing source volume on snapmirror relation ,User has to remove snapmirror relation using "Remove Snapmirror" command and Release snapmirror information on source cluster using "Release SnapMirror" command and run "remove volume" command to remove source volume