0

Snapvault 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 Snapvault 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-SnapvaultStatus()
{
	#Query the Filer for the current SnapMirror Status and save it to a variable.
	$svStatus = Get-NaSnapvaultSecStatus | Format-Table -Wrap -AutoSize -Property Primary,LagTimeTS | 
		Out-String

	return $svStatus
}

Usage Example

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

#Get SnapVault Status.
$snapVaultStatus = Get-SnapvaultStatus
Write-Host $snapVaultStatus

Output of script

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

Example Snapmirror status output.
Example Snapvault status output.

This is how you get the Snapvault status using Powershell. If you want to get your Snapmirror status you can follow my Snapmirror tutorial here.

Subscribe to my feed either by E-mail or by RSS.

Jason Edwards