PureSnap

PowerShell Module for automating the cloning of a PureSystem disk volume for any application.


The PureSnap module consists of 3 cmdlets called, Show-ArPureHostVols, Copy-ArPureHostVol, and
Get-ArCredential.

The cmdlets require that the module, PureSystemPowerShellSDK module be installed along with this module. The RESTAPI exposed by the PureSystemPowerShellSDK module is used to communicate with the PureSystem storage arrays.

Recommended by not required is to install the CredentialManager module.

On the initial execution of either cmdlet, a Storage Admin will need to enter the appropriate password for the Pure account created.

Show-ArPureHostVols

Lists PureSystem disk volume information for a specified host name.

Example1

Show-ArPureHostVols
      
  vol             name        lun hgroup
  ---             ----        --- ------
  testdummy02_T   testdummy02   1
  testdummy01_S_X testdummy02   2

  name            created              source        Size(GB)
  ----            -------              ------        --------
  testdummy02_T   2017-06-05T21:19:59Z                     10
  testdummy01_S_X 2017-06-09T19:20:33Z testdummy01_S       10

The default pureName option value is "Pure001" and the default hostName value is
ProdSQL001.

Lists the volumes masked to "ProdSQL001" on PureSystem array, "Pure001" when no options are specified.

Execute the following for command line for detailed help:

Get-Help Show-ArPureHostVols -full

Copy-ArPureHostVol

Copies a host's volume to a new snap volume to be masked to a different host.

If the new volume exists, it must be masked to the target host and will be overwritten.

If the new volume does not exist, it will be created and masked to the target host.

Example2

Copy-ArPureHostVol -pureName Pure001 -source ProdSQL001 -volname ProdSQL001_L -target DevSQL001

 Verifies that the disk volume, ProdSQL001_L is masked to the source server, ProdSQL001 and creates or overwrites a new snap disk volume, ProdSQL001_L_X.

 The new snap disk volume, ProdSQL001_G_X will be masked to the target server, DevSQL001 if need be.

 A different suffix can be applied to the new disk volumen by specifying the -suffix option.

 If the command is successful, a 0 result will be returned otherwise will have failed. If an invalid parameter is passed no result value will be returned.

Manually Validation

To validate that the target server has the snapshot mounted, enter the following command.

Show-ArPureHostVols -pureName Pure001 -hostName ProdSQL001

The above cmdlet is the long version of the cmdlet. Since Pure001 is the default value for -pureName the following example yields the same results.

Show-ArPureHostVols -hostName ProdSQL001

This module is not executing any host side commands. It is expected that the proper action will have been taken on the host side prior copying a volume.

Get-ArCredential

This cmdlet will get or change the credential storage in Credential Manager used for logging into a PureStorage array or Admin account for Windows server.

If Credential Manager can not retrieve the credential, then it will attempt to retrieve the credential from the encrypted file.

This cmdlet is called by the other cmdlets as needed, so there isn't a need to run it individually to create credentials. The one exception will be if a current credential's password has changed. To change the password of an existing credential.

EXAMPLE change password

To change the password for an AD 'account' login credential

$cr = Get-ArCredential $env:USERNAME 'STORAGE_ADM' 'Server' -changepw

If the USERNAME is in the specifed AD group, then the AD account credential is changed.

Note this is changing the credential stored in Windows Credential Manager only.

EXAMPLE get credential from Windows Credential Manager

$cr = Get-ArCredential $env:USERNAME 'STORAGE_ADM' 'Pure'

If the USERNAME is in the specifed AD group, then the AD account credentials are returned.

Installation

With newer versions of Windows, PowerShell is installed by default but not likely enabled.

Using either Cortana or the 'Run', enter or select 'PowerShell' to launch the PowerShell console (Run as Administrator). Once the PowerShell console window is displayed enter the following command.

set-executionpolicy -unrestricted

PureSnap Module Changes

First modify CheckSum file

The checksum file consist of five lines of parameters that need to be changed to match your environment.

5553b9d9c91f6e15478c2b49e7d2d1e5
smtp-mailserver.org
group-emailaddress.org
my-emailaddress.org
2035551212@sms.net#Craig
pure-login-account-name

The last line is the local Pure account name used as the default login to the array. This is a
local account on the PureStorage array.

If the PureStorage array has been configured to accept AD credentials, then the $env:USERNAME can be used to access the array.

Regardless of the credential type used, the first execution requires entry of the access credential which will be
storage in Windows Credential Manager. Should the Credential Manager not be available, then the credential will be cached locally in an encrypted file.

Second modify PureSnap.psm1 file (optional)

This file has hard coded references to a default array name of Pure001 and hostnames of ProdSQL001 and DevSQL001.

If you will always specify all of the command line options for each of the cmdlets, then changing this file is optional.

Register the local PowerShell Gallery called, PSStorage on your computer by entering the following commands.

Below a SMB share location is being referenced, but it could be a local path reference too.

$Path = '\\my.org\Storage\PSStorage'

$repo = @{
Name = 'PSStorage'
SourceLocation = $Path
PublishLocation = $Path
InstallationPolicy = 'Trusted'
}

Register-PSRepository @repo

Copy all the PureSnap module files to a local directory and then publish the module to your local PowerShell repository setup above.

Publish-Module -Name PureSnap -Repository PSStorage.

Register PSRepository called, PSGallery on your computer by entering the following commands.

$Path = 'https://www.powershellgallery.com/api/v2'

$repo = @{
Name = 'PSGallery'
SourceLocation = $Path
PublishLocation = $Path
InstallationPolicy = 'Trusted'
}

Register-PSRepository @repo

The PowerShell PSGalleries, PSGallery and PSStorage are now registered as a trusted repositories. Verify the respositories are available by entering the following command.

Get-PSRepository

PureSnap module installation from local Repository

Enter the following command, to install the PureSnap module.

Install-Module PureSnap -repository PSStorage

Credential Manager module installation from PSGallery

Enter the following command, to install the CredentialManager module.

Install-Module CredentialManager -repository PSGallery  

PureSystemPowerShellSDK module installation from PSGallery

Install-Module PureStoragePowerShellSDK -repository PSGallery

The PureSnap cmdlets are now ready for execution. On the initial execution only, a
account password will need to be entered by a Storage Admin. This credential is
then stored in the Windows Credential Manager by default. Should the Credential Manager
not be available, then the credential will be cached locally in an encrypted file.