0

Snapmirror status using Powershell

Netapp provide a Powershell Toolkit that you can use to administrate your Netapp appliance. In this example I will be explaining how you can get your Snapmirror status using Powershell.

Before we begin, make sure you have downloaded and installed the Netapp Powershell Toolkit. You will need a NOW login in order to get the download. A tutorial for getting the toolkit can be found here.

The Code

Import-Module DataOnTap

function Connect-Filer([string]$filer, [string]$user, [string]$pass)
{
	# Create an encrypted string which the API will use
	$password = ConvertTo-SecureString $pass -AsPlainText –Force
	# Create a credential object in powershell.
	$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 
		$user,$password
	# Connect to the Filer using the credential created above.
	$connection =  Connect-NaController $filer -Credential $cred
}

function Get-SnapmirrorStatus()
{
	#Query the Filer for the current SnapMirror Status and save it to a variable.
	$smStatus = Get-NaSnapmirror | Format-Table -Wrap -AutoSize -Property Source,LagTimeTS |  
		Out-String 

	return $smStatus
}

Usage Example

# Check NetApp Snapmirror status.
# Connect to the filer
Connect-Filer "SAN NAME or IP" "username" "password"

#Get SnapMirror Status.
$snapMirrorStatus = Get-SnapmirrorStatus
Write-Host $snapMirrorStatus

Output of script

The script will output your Snapmirror sources and lag times. You can see an example of this below:

Example Snapmirror status output.

Example Snapmirror status output.

This is how you get the Snapmirror status using Powershell. If you want to know how to get your SnapVault status take a look at this post.

Subscribe to my feed either by E-mail or by RSS to receive updates as they happen.

Jason Edwards