<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get-ncvol command to generate a list of offline volumes from multiple clusters and send a report in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-ncvol-command-to-generate-a-list-of-offline-volumes-from-multiple-clusters/m-p/159037#M6224</link>
    <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@"&lt;BR /&gt;===============================================================================&lt;BR /&gt;Title: Netapp Offline Volume notifications.ps1&lt;BR /&gt;Description: List offline volumes on the Netapp clusters.&lt;BR /&gt;Requirements: Windows Powershell and the Netapp Powershell Toolkit&lt;BR /&gt;Author: Ed Grigson &lt;BR /&gt;===============================================================================&lt;BR /&gt;"@&lt;/P&gt;
&lt;P&gt;Import-module DataOnTap&lt;/P&gt;
&lt;P&gt;#Age of snapshot (in days) before it's included in the report&lt;BR /&gt;#$WarningDays = 7 &lt;BR /&gt;#List the filers you want to scan&lt;BR /&gt;$NetappList=("clusters")&lt;BR /&gt;#List of email recipients&lt;BR /&gt;$emailNotifications=("emailaddress") &lt;BR /&gt;#SMTP server - replace with your SMTP relay below&lt;BR /&gt;$emailServer="x.x.x.x"&lt;BR /&gt;$Now=Get-Date&lt;/P&gt;
&lt;P&gt;#Generate HTML output that uses CSS for style formatting.&lt;BR /&gt;$emailContent = "&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&amp;lt;style type=""text/css""&amp;gt;.Error {color:#FF0000;font-weight: bold;}.Title {background: #0077D4;color: #FFFFFF;text-align:center;font-weight: bold;}.Normal {}&amp;lt;/style&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;"&lt;BR /&gt;$emailContent += "&amp;lt;p&amp;gt;Please scan the list of offline volumes and destroy it if not needed"&lt;BR /&gt;#$emailContent += "&amp;lt;p&amp;gt;Only snapshots over $WarningDays days old are shown."&lt;/P&gt;
&lt;P&gt;foreach ($netapp in $NetappList) { &lt;BR /&gt;$emailContent += "&amp;lt;h2&amp;gt;$Netapp&amp;lt;/h2&amp;gt;"&lt;BR /&gt;$emailContent += "&amp;lt;table&amp;gt;&amp;lt;tr class='Title'&amp;gt;&amp;lt;td colspan='4'&amp;gt;Netapp Offline Volume Report&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr class='Title'&amp;gt;&amp;lt;td&amp;gt;List of Volumes"&lt;BR /&gt;$Report = @()&lt;BR /&gt;Connect-NcController $netapp | select Name,Address&lt;BR /&gt;Get-NcVol -Query @{State="*offline*"} | Format-Table Name,State,Aggregate,Vserver&lt;BR /&gt;$ParentName=$_.Name&lt;BR /&gt;$Snap = get-ncvol $ParentName | add-member -membertype noteproperty -name ParentName -value $ParentName -passthru | select ParentName,Name&lt;BR /&gt;$Report += $Snap&lt;BR /&gt;}&lt;BR /&gt;Foreach ($snapshot in ($Report | Sort-Object -property AccessTime)){&lt;BR /&gt;#see if the snapshot is older than the value specified in $WarningDays and if so include in report&lt;BR /&gt;if ($snapshot.AccessTime -le $Now.AddDays(-$WarningDays)) {&lt;BR /&gt;Reformat the snapshot size into Gb&lt;BR /&gt;$snapsize = "{0,20:n3}" -f (($snapshot.Total*1024)/1GB)&lt;BR /&gt;$emailContent += "&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;$($snapshot.ParentName)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$($snapshot.Name)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$($snapshot.AccessTime)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$($snapsize)GB&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$emailContent += "&amp;lt;/table&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;"&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;# Generate the report and email it as a HTML body of an email&lt;BR /&gt;$SmtpClient = New-Object system.net.mail.smtpClient&lt;BR /&gt;$SmtpClient.host = $emailServer &lt;BR /&gt;$MailMessage = New-Object system.net.mail.mailmessage&lt;BR /&gt;#Change to email address you want emails to be coming from&lt;BR /&gt;$MailMessage.from = "storagereport@domain.com" &lt;BR /&gt;foreach($email in $emailNotifications) {&lt;BR /&gt;$MailMessage.To.add($email)&lt;BR /&gt;}&lt;BR /&gt;$MailMessage.Subject = "Netapp Offline Volume Report" &lt;BR /&gt;$MailMessage.IsBodyHtml = 1&lt;BR /&gt;$MailMessage.Body = $emailContent&lt;BR /&gt;$SmtpClient.Send($MailMessage)&lt;/P&gt;</description>
    <pubDate>Thu, 27 Aug 2020 13:51:54 GMT</pubDate>
    <dc:creator>RayR</dc:creator>
    <dc:date>2020-08-27T13:51:54Z</dc:date>
    <item>
      <title>Get-ncvol command to generate a list of offline volumes from multiple clusters and send a report.</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-ncvol-command-to-generate-a-list-of-offline-volumes-from-multiple-clusters/m-p/159005#M6220</link>
      <description>&lt;P&gt;Get-ncvol command to generate a list of offline volumes from multiple clusters and send a report.&amp;nbsp; I'm new to using powershell and would like to get some help on this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 10:55:42 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-ncvol-command-to-generate-a-list-of-offline-volumes-from-multiple-clusters/m-p/159005#M6220</guid>
      <dc:creator>RayR</dc:creator>
      <dc:date>2025-06-04T10:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get-ncvol command to generate a list of offline volumes from multiple clusters and send a report</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-ncvol-command-to-generate-a-list-of-offline-volumes-from-multiple-clusters/m-p/159036#M6223</link>
      <description>&lt;P&gt;Do you have any code written yet that we could take a look at it and give feedback on? Some ideas to get you started:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Look at the "Add-NcCredential" cmdlet in the PowerShell Toolkit to cache credentials to clusters to make connecting to them easier when running scripts/functions (check out the&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/get-help?view=powershell-7" target="_self"&gt;Get-Help&lt;/A&gt; cmdlet to get more information, syntax, examples, etc. for cmdlets if you are not familiar with it already).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You will need to use &lt;A href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7" target="_self"&gt;foreach loops&lt;/A&gt; to loop through a collection of your cluster hostnames.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. If you're not familiar with it already, look at the &lt;A href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/where-object?view=powershell-7" target="_self"&gt;Where-Object&lt;/A&gt; cmdlet, which allows you to select objects from command output based on their properties (like the state of a volume, for example). Pipes are your friend!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. What format are you expecting this report to be in? If email, you can use the "Send-MailMessage" cmdlet to format and send the relevant output to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps - feel free to hit me up with any code that you're struggling with or any follow-up questions and I'll lend a hand.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Donny&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 13:25:22 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-ncvol-command-to-generate-a-list-of-offline-volumes-from-multiple-clusters/m-p/159036#M6223</guid>
      <dc:creator>donny_lang</dc:creator>
      <dc:date>2020-08-27T13:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get-ncvol command to generate a list of offline volumes from multiple clusters and send a report</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-ncvol-command-to-generate-a-list-of-offline-volumes-from-multiple-clusters/m-p/159037#M6224</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@"&lt;BR /&gt;===============================================================================&lt;BR /&gt;Title: Netapp Offline Volume notifications.ps1&lt;BR /&gt;Description: List offline volumes on the Netapp clusters.&lt;BR /&gt;Requirements: Windows Powershell and the Netapp Powershell Toolkit&lt;BR /&gt;Author: Ed Grigson &lt;BR /&gt;===============================================================================&lt;BR /&gt;"@&lt;/P&gt;
&lt;P&gt;Import-module DataOnTap&lt;/P&gt;
&lt;P&gt;#Age of snapshot (in days) before it's included in the report&lt;BR /&gt;#$WarningDays = 7 &lt;BR /&gt;#List the filers you want to scan&lt;BR /&gt;$NetappList=("clusters")&lt;BR /&gt;#List of email recipients&lt;BR /&gt;$emailNotifications=("emailaddress") &lt;BR /&gt;#SMTP server - replace with your SMTP relay below&lt;BR /&gt;$emailServer="x.x.x.x"&lt;BR /&gt;$Now=Get-Date&lt;/P&gt;
&lt;P&gt;#Generate HTML output that uses CSS for style formatting.&lt;BR /&gt;$emailContent = "&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&amp;lt;style type=""text/css""&amp;gt;.Error {color:#FF0000;font-weight: bold;}.Title {background: #0077D4;color: #FFFFFF;text-align:center;font-weight: bold;}.Normal {}&amp;lt;/style&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;"&lt;BR /&gt;$emailContent += "&amp;lt;p&amp;gt;Please scan the list of offline volumes and destroy it if not needed"&lt;BR /&gt;#$emailContent += "&amp;lt;p&amp;gt;Only snapshots over $WarningDays days old are shown."&lt;/P&gt;
&lt;P&gt;foreach ($netapp in $NetappList) { &lt;BR /&gt;$emailContent += "&amp;lt;h2&amp;gt;$Netapp&amp;lt;/h2&amp;gt;"&lt;BR /&gt;$emailContent += "&amp;lt;table&amp;gt;&amp;lt;tr class='Title'&amp;gt;&amp;lt;td colspan='4'&amp;gt;Netapp Offline Volume Report&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr class='Title'&amp;gt;&amp;lt;td&amp;gt;List of Volumes"&lt;BR /&gt;$Report = @()&lt;BR /&gt;Connect-NcController $netapp | select Name,Address&lt;BR /&gt;Get-NcVol -Query @{State="*offline*"} | Format-Table Name,State,Aggregate,Vserver&lt;BR /&gt;$ParentName=$_.Name&lt;BR /&gt;$Snap = get-ncvol $ParentName | add-member -membertype noteproperty -name ParentName -value $ParentName -passthru | select ParentName,Name&lt;BR /&gt;$Report += $Snap&lt;BR /&gt;}&lt;BR /&gt;Foreach ($snapshot in ($Report | Sort-Object -property AccessTime)){&lt;BR /&gt;#see if the snapshot is older than the value specified in $WarningDays and if so include in report&lt;BR /&gt;if ($snapshot.AccessTime -le $Now.AddDays(-$WarningDays)) {&lt;BR /&gt;Reformat the snapshot size into Gb&lt;BR /&gt;$snapsize = "{0,20:n3}" -f (($snapshot.Total*1024)/1GB)&lt;BR /&gt;$emailContent += "&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;$($snapshot.ParentName)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$($snapshot.Name)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$($snapshot.AccessTime)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$($snapsize)GB&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$emailContent += "&amp;lt;/table&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;"&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;# Generate the report and email it as a HTML body of an email&lt;BR /&gt;$SmtpClient = New-Object system.net.mail.smtpClient&lt;BR /&gt;$SmtpClient.host = $emailServer &lt;BR /&gt;$MailMessage = New-Object system.net.mail.mailmessage&lt;BR /&gt;#Change to email address you want emails to be coming from&lt;BR /&gt;$MailMessage.from = "storagereport@domain.com" &lt;BR /&gt;foreach($email in $emailNotifications) {&lt;BR /&gt;$MailMessage.To.add($email)&lt;BR /&gt;}&lt;BR /&gt;$MailMessage.Subject = "Netapp Offline Volume Report" &lt;BR /&gt;$MailMessage.IsBodyHtml = 1&lt;BR /&gt;$MailMessage.Body = $emailContent&lt;BR /&gt;$SmtpClient.Send($MailMessage)&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 13:51:54 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-ncvol-command-to-generate-a-list-of-offline-volumes-from-multiple-clusters/m-p/159037#M6224</guid>
      <dc:creator>RayR</dc:creator>
      <dc:date>2020-08-27T13:51:54Z</dc:date>
    </item>
  </channel>
</rss>

