So I found this script for generating reports for snapshots. I figured I can use it as a template and modify the commands for generating reports for offline volumes from multiple clusters. I'll review the links you sent me foreach loops and where-object and paste the command here again.
@"
===============================================================================
Title: Netapp Offline Volume notifications.ps1
Description: List offline volumes on the Netapp clusters.
Requirements: Windows Powershell and the Netapp Powershell Toolkit
Author: Ed Grigson
===============================================================================
"@
Import-module DataOnTap
#Age of snapshot (in days) before it's included in the report
#$WarningDays = 7
#List the filers you want to scan
$NetappList=("clusters")
#List of email recipients
$emailNotifications=("emailaddress")
#SMTP server - replace with your SMTP relay below
$emailServer="x.x.x.x"
$Now=Get-Date
#Generate HTML output that uses CSS for style formatting.
$emailContent = "<html><head><title></title><style type=""text/css"">.Error {color:#FF0000;font-weight: bold;}.Title {background: #0077D4;color: #FFFFFF;text-align:center;font-weight: bold;}.Normal {}</style></head><body>"
$emailContent += "<p>Please scan the list of offline volumes and destroy it if not needed"
#$emailContent += "<p>Only snapshots over $WarningDays days old are shown."
foreach ($netapp in $NetappList) {
$emailContent += "<h2>$Netapp</h2>"
$emailContent += "<table><tr class='Title'><td colspan='4'>Netapp Offline Volume Report</td></tr><tr class='Title'><td>List of Volumes"
$Report = @()
Connect-NcController $netapp | select Name,Address
Get-NcVol -Query @{State="*offline*"} | Format-Table Name,State,Aggregate,Vserver
$ParentName=$_.Name
$Snap = get-ncvol $ParentName | add-member -membertype noteproperty -name ParentName -value $ParentName -passthru | select ParentName,Name
$Report += $Snap
}
Foreach ($snapshot in ($Report | Sort-Object -property AccessTime)){
#see if the snapshot is older than the value specified in $WarningDays and if so include in report
if ($snapshot.AccessTime -le $Now.AddDays(-$WarningDays)) {
Reformat the snapshot size into Gb
$snapsize = "{0,20:n3}" -f (($snapshot.Total*1024)/1GB)
$emailContent += "<tr><td>$($snapshot.ParentName)</td><td>$($snapshot.Name)</td><td>$($snapshot.AccessTime)</td><td>$($snapsize)GB</td></tr>"
$emailContent += "</table></body></html>"
# Generate the report and email it as a HTML body of an email
$SmtpClient = New-Object system.net.mail.smtpClient
$SmtpClient.host = $emailServer
$MailMessage = New-Object system.net.mail.mailmessage
#Change to email address you want emails to be coming from
$MailMessage.from = "storagereport@domain.com"
foreach($email in $emailNotifications) {
$MailMessage.To.add($email)
}
$MailMessage.Subject = "Netapp Offline Volume Report"
$MailMessage.IsBodyHtml = 1
$MailMessage.Body = $emailContent
$SmtpClient.Send($MailMessage)