Introduction:
The SANtricity PowerShell toolkit included with the NetApp PowerShell toolkit version 4.1 does not properly find member volumes in an asynchronous mirror group. Specifically, the Get-NeAsyncMirrorGroupPairs cmdlet is not functioning correctly. This article provides steps to correct this until the next release of the NetApp PowerShell Toolkit.
Step 1:
The first step is to find the location of the SANtricity module. By default, the SANtricity PowerShell toolkit is installed in C:\Program Files (x86)\NetApp\NetApp PowerShell Toolkit\Modules\NetApp.SANtricity.PowerShell. The name of the file to find is NetApp.SANtricity.Functions.psm1. If you are not sure where the module is installed or simply want to confirm a default installation, then run the following commands from a PowerShell session. Make sure PowerShell is launched as an Administrator.
PS> (Get-Module -ListAvailable -Name NetApp.SANtricity.PowerShell).ModuleBase
C:\Program Files (x86)\NetApp\NetApp PowerShell Toolkit\Modules\NetApp.SANtricity.PowerShell
With Windows Explorer, navigate to the directory where the SANtricity PowerShell module is installed.
Step 2:
The next step is to update the file called NetApp.SANtricity.Functions.psm1. With your editor of choice, add the following function to the end of NetApp.SANtricity.Functions.psm1. Start by making a backup copy of this file. Again, ensure the editor is launched with Administrator privilege.
<#
.SYNOPSIS
This function returns asynchronous mirror pair volumes.
.DESCRIPTION
An asynchronous mirror pair is an association between two volumes. The volumes are located on
different storage arrays and linked together through an asynchronous mirror group (AMG). An
AMG can have many volumes participating in the same AMG. This cmdlet displays the volumes
in this AMG
.PARAMETER Credential
A Netapp.PowerShell.Credential.NeCredential object. Typically instantiated with Get-NeProxySystemCredential.
.PARAMETER MirrorId
The Id of the AMG to query for participating volumes.
#>
function Get-NeAsyncMirrorGroupPairs()
{
param( [string] $SystemId, [Netapp.PowerShell.Credential.NeCredential] $Credential, [string]$MirrorId)
$module = Get-Module -Name NetApp.SANtricity.PowerShell
$modulePath = $module.ModuleBase
$url = $Credential.Url
$endpoint = "v2/storage-systems/$SystemId/async-mirrors/$MirrorId/pairs"
$user = $Credential.Credential.UserName
$assemblyPath = Join-Path -Path $modulePath -Child "NetApp.SANtricity.PowerShell.dll"
[Reflection.Assembly]::LoadFile($assemblyPath) | Out-Null
$client = New-Object Netapp.Santricity.RestClient.WebService -ArgumentList @(,$url)
$loginResult = $client.Login($user, $([Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR( $cred.Credential.Password ))))
$result = $client.Get($endpoint)
$result
}
Save the file and exit the editor.
Step 3:
The final step is to reload the module to pick up the changes. The existing module file is signed by NetApp. When PowerShell detects the edit, it will not load the module. In the PowerShell window, change the execution policy to RemoteSigned.
PS> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Please do not change the execution policy if you do not understand the ramifications of making this change. The execution policy only needs to be changed until the next release of the NetApp PowerShell Toolkit. If you work behind a firewall and do not use PowerShell scripts from untrusted sources, then this is a perfectly safe change.
Now you can open a new PowerShell window or new instance of the PowerShell Integrated Scripting Environment. You can now exercise Get-NeAsyncMirrorGroupPairs by using the pre-defined function instead of the cmdlet bundled in the assembly.