NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

General Discussion

Powershell script for aggregate utilization is showing data in 1 cell

Khulbe1
3,305 Views

Team - I am new to powershell and I am trying to create a script which can show us aggregate size, physical-used, physical-used-percent and committed capacity. I have taken few scripts from here n there and tried creating one with my requirements. Except committed space I am able to get the data but all the result in getting imported in 1 cell. Also if someone can help in how to get committed capacity that would be great!!

 

$netappcs = gc E:\Script\Health_check\test.txt
Get-Module ImportExcel | Import-Module
Import-Module DataONTAP
$User = "*******"
$PWord = ConvertTo-SecureString -String '********' -AsPlainText -Force

$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord

foreach($netapp in $netappcs)
{
Connect-NaController $netapp -Credential $cred
$a = Get-NcCluster
$clus = $a.ClusterName
#$clusip = $a.NcController
$b = Get-NcNode
$node = $b.Node
$nodehealth = $b.IsNodeHealthy
$Netagg = "aggr show -aggregate * -fields size, physical-used, physical-used-percent"
Invoke-NcSsh -Command $Netagg | Select-Object Value, NcController | Export-Excel -path "E:\Script\Aggregate_Utilization_-$((Get-Date).ToString('dd-MM-yyyy')).xlsx" -TableStyle Medium16 -AutoSize
}

1 REPLY 1

TzwaynY
2,676 Views

Hello khulbe1,

if you want to export the Results you got there from powershell to excel correctly, you need to install the Powershell Excel-Modul. With that module you should be able to get the output you want.

 

And for the Aggr Sizes you need:

 

$GetNcAggr = Get-NcAggr

$GetNcAggr.TotalSize /1GB

$GetNcAggr.Available /1GB <- This will get you the Available Date in GB. And with that you can do the calculation for the percentage.

 

Public