How to get all 32-bit Snapshots on a 7-Mode System

Credit for this post goes to my esteemed colleague Aved Chammt

The following script can be used to obtain a list - in PowerShell and CSV - of all the 32-bit snapshots on a 7-Mode System, along with various information like “how many days old is the snapshot?”

Note: You need Data ONTAP 8.1.4P4 or better to see FsBlockFormat information.

How to Use?

Run in PowerShell like in the example below>


.\Get-32bitSnaps.ps1 -UserName root -Password YOURPASS -Controller 10.0.0.50


The Script (formatted for blogger with tabs replaced by two spaces)

Copy and paste into a text editor (Notepad, Notepad++ etcetera), and save as Get-32bitSnaps.ps1


Param(
  [Parameter(Mandatory=$true)][String]$UserName,
  [Parameter(Mandatory=$true)][String]$Password,
  [Parameter(Mandatory=$true)][String]$Controller
)

Import-Module DataONTAP
$SecPass = $Password | ConvertTo-SecureString -asPlainText -Force
$Cred = New-Object System.Management.Automation.PsCredential($UserName,$SecPass)
[Void](Connect-NaController $Controller -Credential $Cred)

$GetNaSystemInfo = Get-NaSystemInfo
$SerialNumber    = $GetNaSystemInfo.SystemSerialNumber
$SystemId        = $GetNaSystemInfo.SystemId
$SystemName      = $GetNaSystemInfo.SystemName

$Objects = @()
$Today = Get-Date
Get-NaVol | foreach {
  $VolumeName = $_.Name
  $Snapshots = Get-NaSnapshot -TargetName $_ | Where{ $_.FsBlockFormat -eq "32_bit" }
  $Snapshots | Foreach{
    $Object = New-Object PSObject
    Add-Member -InputObject $Object -MemberType NoteProperty -Name "System Name" -Value $SystemName
    Add-Member -InputObject $Object -MemberType NoteProperty -Name "System S/N" -Value $SerialNumber
    Add-Member -InputObject $Object -MemberType NoteProperty -Name "System ID" -Value $SystemId
    Add-Member -InputObject $Object -MemberType NoteProperty -Name "Volume" -Value $VolumeName
    Add-Member -InputObject $Object -MemberType NoteProperty -Name "Snapshot" -Value $_.Name
    Add-Member -InputObject $Object -MemberType NoteProperty -Name "BlockFormat" -Value $_.FsBlockFormat
    Add-Member -InputObject $Object -MemberType NoteProperty -Name "Days Old" -Value ($Today - $_.AccessTimeDT).Days
    $Objects += $Object
  }
}

$Objects | FT
$Objects | Export-CSV "$Controller.CSV" -NoTypeInformation


Example Output

Image: Get-32bitSnaps PowerShell output
Example CSV Output

Image: Get-32bitSnaps CSV Output

Comments