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 cluster you 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)