netapp reporting

Fun with Powershell - Retrieve space utilization from Netapp systems

Alright, so my PowerShell adventures continue and this time, its taken me to the Netapp world. Now I am by no means a Netapp guru or claim to be one. This report was requested by my storage team and I wanted to explore this with PowerShell!

First in order to run any netapp related commands, you need to down the Netapp Tool Kit for Powershell which add a bunch of cmdlets. Click here to download that!

Once that is done, all you need to do is run the below script in PowerShell against your Netapp controller and you should see a neat html report generated in  the location specified in the script. I have also included the CSS to make it look pretty!

I have highlighted the values in bold that you will have to change as per your environment and once done, you should be one your way.

Import-Module DataONTAP

Hello, World!

$controller = Get-Content C:\powershell\Scripts\Netapp\controller.txt

$vservers = Get-Content C:\powershell\Scripts\Netapp\vserver.txt

$report = "\\server1\d$\wamp\www\main.html"

ConvertTo-Html –title "NDMP REPORTS" –body "<H1>NDMP REPORTS</H1>" -head "<link rel='stylesheet' href='http://meassets/css/style.css'>" | Out-File -Encoding unicode $report

ConvertTo-Html –title "NDMP REPORTS" –body "<H4>Date and time     $(get-date)</H4>" | Out-File -Encoding unicode -Append $report

$password = ConvertTo-SecureString -AsPlainText -Force "hello123"

$credential = new-object management.automation.pscredential "admin", $password

$one = foreach($control in $controller)


Connect-NcController $control -Credential $credential

ConvertTo-Html –body "<H2> $($control.ToUpper()) </H2>" | Out-File -Encoding unicode -Append $report

ConvertTo-Html -Body "<H4>$(Get-NcSystemVersion)</H4>" | Out-File -Encoding unicode -Append $report

$main = get-NcAggr |Select-Object Name,State,@{n="Total Space in TB";e {[math]::round($_.TotalSize / 1TB,2)}},

@{n="Available Space Remaining in TB";e={[math]::round($_.Available / 1TB,2)}},@{n="Utilized Percentage %";e={($_.Used)}}| ConvertTo-Html | Out-File -Encoding unicode -Append $report

$main2 = get-ncaggr| Measure-Object -Property Available,TotalSize -Sum | select-object @{name="Name";e={$_.Property}},@{name="Size in TB";e={[math]::round($_.sum / 1TB,2)}} | ConvertTo-Html –body "<H2>Summary: </H2>" |  Out-File -Encoding unicode -Append $report

ConvertTo-Html - Body "<br>================================================================================================</br>" | Out-File -Encoding unicode -Append $report

$global:CurrentNcController = $null



Send-MailMessage -SmtpServer -To -Subject "AWESOME NDMP REPORTS" -From -Priority High -Attachments $report