~/2014/04/28/powershell-netapp-gather-volume-information.md

PowerShell: NetApp – Gather Volume Information

---
author: 
date: 
updated: 
read: 1 min
in:   [dotps, ps, scripts]
tags: [netapp, powershell, script]
---

$ grep -n '^#' post.md

This is a simple script to gather volume information including dedupe schedule and autogrow settings. I’m going to combine this with my snapshot script in the future to make a recommended dedupe schedule based on the average snapshot times.

Requirements

  • PowerShell 2.0 or later.
  • NetApp Data ONTAP PowerShell Toolkit 1.2 or later (the DataONTAP module). The script imports it if it is not already loaded and stops with an error if the version is older.
  • NetApp 7-Mode controllers reachable over HTTPS.
  • An account on each controller that can read volume, autosize and dedupe (SIS) information.

Parameters

NameTypeRequiredDescription
nodesarrayYesOne or more controllers to connect to. When prompted, enter one per line and press Enter on an empty line to continue.
usernamestringYesAccount used to connect to every controller, for example <domain>\<username>.
passwordSecureStringYesPassword for the account. Prompted for as a secure string when not supplied.
IsVerboseswitchNoDisplay the collected property table for each volume as it is gathered.

The same credentials are used for every node in nodes.

Usage

Pass the controllers and account on the command line. You are prompted for the password.

powershell
& '.\NetApp-Gather Volume Information.ps1' -nodes "<filer-1>","<filer-2>" -username "<domain>\<username>" -IsVerbose

Or run the script with no parameters and answer the prompts.

powershell
& '.\NetApp-Gather Volume Information.ps1'
text
cmdlet NetApp-Gather Volume Information.ps1 at command pipeline position 1
Supply values for the following parameters:
nodes[0]: <filer-1>
nodes[1]: <filer-2>
nodes[2]:
username: <domain>\<username>
password: *************

The results are written to GatherVolumeInformation_<timestamp>_Detail.csv in the same folder as the script.

Script

powershell
<#
.SYNOPSIS
    Gathers NetApp 7-Mode volume information, including dedupe schedule and autogrow settings.
.DESCRIPTION
    Connects to each node with the Data ONTAP PowerShell Toolkit and collects
    details for every online volume that is not read-only: aggregate, total
    size, used, available, dedupe (SIS) status and schedule, and autogrow
    status, maximum size and increment size. The results are written to
    GatherVolumeInformation_<timestamp>_Detail.csv in the script folder.
.PARAMETER nodes
    One or more controllers to connect to. When prompted, enter one per line and press Enter on an empty line to continue.
.PARAMETER username
    Account used to connect to every controller, for example <domain>\<username>.
.PARAMETER password
    Password for the account. Prompted for as a secure string when not supplied.
.PARAMETER IsVerbose
    Display the collected property table for each volume as it is gathered.
.EXAMPLE
    & '.\NetApp-Gather Volume Information.ps1' -nodes "<filer-1>","<filer-2>" -username "<domain>\<username>" -IsVerbose
.EXAMPLE
    & '.\NetApp-Gather Volume Information.ps1'

    cmdlet NetApp-Gather Volume Information.ps1 at command pipeline position 1
    Supply values for the following parameters:
    nodes[0]: <filer-1>
    nodes[1]: <filer-2>
    nodes[2]:
    username: <domain>\<username>
    password: *************
.NOTES
    Author  : Thomas Lasswell (https://www.techcolumnist.com)
    Version : 1.1 (2026-09-20)
    Requires: Data ONTAP PowerShell Toolkit 1.2 or later, NetApp 7-Mode
    History : 1.0 2014-04-28 Initial version.
              1.1 2026-09-20 Fixed the timestamp in the CSV file name (it used minutes
                  where the month belongs) and the volume progress message.
#>
param (
    [Parameter(Mandatory = $true)]
    [Array]$nodes,
    [Parameter(Mandatory = $true)]
    [String]$username,
    [Parameter(Mandatory = $true, ParameterSetName = 'Secret')]
    [Security.SecureString]$password,
    [switch]$IsVerbose
)

# Create outfile information.
$exedir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$currentDate = (Get-Date -Format yyyyMMdd.HHmmss)
$outdetails = ($exedir + "\" + "GatherVolumeInformation_" + $currentDate + "_Detail.csv")

# Load ONTAP PowerShell Toolkit.
$module = Get-Module DataONTAP
if ($module -eq $null) {
    Import-Module DataONTAP
}

try {
    $requiredVersion = New-Object System.Version(1.2)
    if ((Get-NaToolkitVersion).CompareTo($requiredVersion) -lt 0) {
        throw
    }
} catch [Exception] {
    Write-Host "`nThis script requires Data ONTAP PowerShell Toolkit 1.2 or higher`n" -ForegroundColor Red
    return
}

$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password

# Declare object arrays.
$objDetail = @()

# Connect to each node individually.
foreach ($node in $nodes) {
    Write-Host "connecting to node $node..."
    $conn = Connect-NaController -Name $node -HTTPS -Credential $cred

    if ($conn -ne $null) {
        Write-Host "node connected, continuing on to volume calculations..."
        Write-Host "gathering node volumes..."
        $vols = Get-NaVol | Where-Object { $_.state -eq "online" -and $_.raidstatus -notmatch "read-only" }
        if ($vols -ne $null) {
            foreach ($vol in $vols) {
                Write-Host "`ngathering volume data for volume $vol..."
                $nasis = $null

                # Get volume details.
                Write-Host "    ... gathering volume details"
                $navol = Get-NaVol -Name $vol
                Write-Host "    ... gathering AutoSize details"
                $navolautosize = Get-NaVolAutosize -Name $vol
                Write-Host "    ... gathering Dedupe (SIS) details"
                if ($navol.Dedupe -eq "True") {
                    $nasis = Get-NaSis -Name $vol
                }
                if ($nasis -eq $null) {
                    $sissched = "None"
                }
                if ($nasis -ne $null) {
                    $sissched = $nasis.Schedule
                }

                # Format numbers.
                $ftotalsize = ConvertTo-FormattedNumber $navol.TotalSize DataSize "0.0"
                $favailable = ConvertTo-FormattedNumber $navol.Available DataSize "0.0"
                $fmaxsize = ConvertTo-FormattedNumber $navolautosize.MaximumSize DataSize "0.0"
                $fincrement = ConvertTo-FormattedNumber $navolautosize.IncrementSize DataSize "0.0"

                # Build array for details.
                $detailprop = @{
                    'Node'            = $node
                    'Volume'          = $vol
                    'Aggregate'       = $navol.Aggregate
                    'TotalSize'       = $ftotalsize
                    'Used'            = $navol.Used
                    'Available'       = $favailable
                    'DedupeEnabled'   = $navol.Dedupe
                    'DedupeSchedule'  = $sissched
                    'AutogrowEnabled' = $navolautosize.IsEnabled
                    'MaxSize'         = $fmaxsize
                    'IncrementSize'   = $fincrement
                }
                $objectD = New-Object -TypeName PSObject -Property $detailprop
                $objDetail += $objectD
                if ($IsVerbose) {
                    Write-Host "`n`nShowing Verbose Output...`n`n"
                    $detailprop
                }
            }
        }
    }
}

# Save files.
$objDetail | Select-Object Node, Volume, Aggregate, TotalSize, Used, Available, DedupeEnabled, DedupeSchedule, AutogrowEnabled, MaxSize, IncrementSize | Export-Csv -Path $outdetails -NoTypeInformation

Notes

  • Update 2026-09-20 (v1.1): the timestamp in the output file name was yyyymmdd.Hm.s, where mm is minutes, so it never contained the month. It is now yyyyMMdd.HHmmss, for example GatherVolumeInformation_20140428.140530_Detail.csv.