Anyone who’s tried to remove Snapmirror relationships using the NetApp commandline knows how painful it is. Recently, I had a need to remove all snapmirror relationships from a number of NetApp storage systems and figured I’d play with NetApp’s PowerShell toolkit to see if I could semi-automate the process.

Below are some notes and some code snippets that may help if you ever need to do this yourself.

Environment Setup

If you haven’t got them already, download and install PowerShell 4.0 and the latest NetApp DATAONTAP Powershell toolkit

Open up PowerShell and run:

import-module DATAONTAP

If you get an error about not being able to execute scripts, run:

 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned


I have a number of storage systems, each with many snapmirror relationships with other storage systems. All storage systems will accept the same credentials. I want to remove all snapmirror relationships associated with the destination storage systems.

We’ll be using the following NetApp cmdlets:


To find out more about these use:

get-help <cmdlet name> -full


First, you may wish to setup an authentication token. I like using this method as it’s relatively secure, and doesn’t involve embedding passwords into scripts

$authentication = Get-Credential

This asks for the credentials via an authentication popup, and stores those credentials in a new variable called $authentication that we can pass to the -Credential parameter when connecting to a storage system later on. Lovely.

Let’s connect to our destination storage system (that is, the one whose snapmirror relationships we want to kill with fire remove cleanly)

Connect-NaController -Name <storage system name> -Credential $authentication

OK, now, we need to get a list of all the snapmirror relationships on the storage system and pass those results to the command that will quiesce all of those relationships

Get-NaSnapmirror | foreach-object { invoke-nasnapmirrorquiesce -Destination $_.Destination }

This may take a while.

Once it’s done, this next code snippet will get that same list of snapmirror relationships and then:

  1. Grab the object in the Source field and use Regular Expressions to isolate the source storage system and put it in its own variable
  2. Pass that source storage system variable as well as the Source and Destination details to the Remove-NaSnapmirror cmdlet
  3. Use the authentication token to authenticate against the source storage system (in order to release the snapmirror relationship)
Get-NaSnapmirror | foreach-object {
#remove all characters after the : from the output of the source. This gives us the filer name that we can then pass to the Remove-nasnapmirror command
$sourcefiler = $_.Source -Replace '\:.*'
Remove-NaSnapmirror -destination $_.Destination -source $_.Source -sourcecontroller (connect-nacontroller $sourcefiler -credential $authentication -transient)

For every relationship to be removed, you’ll be asked if that’s really what you want to do. For safety’s sake, leave that in place. If you’re feeling cavalier, you can automatically say yes to that prompt by replacing the above Remove-NaSnapmirror line with:

Remove-NaSnapmirror -destination $_.Destination -source $_.Source -sourcecontroller (connect-nacontroller $sourcefiler -credential $authentication -transient) -confirm:$false

Your mileage may vary. Let me know how you get on!