HPE Nimble Storage Solution Specialists

Script to find NSs Snapshots

Occasional Visitor

Script to find NSs Snapshots

Hey Everyone,  I thought I'd share my script to automate the discovery and email the System Snapshots created by expanding a volume. 

Create a service account, log into the machien were you want the password to reside and run the script from.  Then create the encrypted password with this command:

Read-Host "PASSHERE" -AsSecureString | ConvertFrom-SecureString | Out-File "C:\location\to\pass.txt"

The password file can only be unencrypted with the service account, so make the scheduled task to run as that user.

#loads encrypted password
$securePass = Get-Content C:\location\to\pass.txt

#Decrypts password
$pass = $securePass | ConvertTo-SecureString
$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($pass)
$decrypted = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr)

#Email parrameterss.
$EmailFrom = “emailfrom@address.com”
$EmailTo = “emailt@address.com”
$Subject = “NSs Snapshots”
$SMTPServer = “smtp.address.com”

#Plink command that gets the snaps
$Body1 = plink -ssh IPADDRESS -batch -l LOCALNIMBLEUSER -pw $decrypted "snap --list --all | grep NSs"
$Body2 = plink -ssh IPADDRESS -batch -l LOCALNIMBLEUSER -pw $decrypted "snap --list --all | grep NSs"

#Sends email
Send-MailMessage -from $EmailFrom -to $EmailTo -subject $Subject -smtpserver $SMTPServer -body @"
SAN1 Snapshots

SAN2 Snapshots


#Variable Cleanup
$securePass = 1234
$pass = 1234
$Ptr = 1234
$decrypted = 1234


Re: Script to find NSs Snapshots

Hi Ryan

I would recommend our official toolkit (https://www.powershellgallery.com/packages/HPENimblePowerShellToolkit/3.0.0)But the method posted above looks ok too.

Hope this helps.!


I work for HPE

Accept or Kudo

[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]