Community

Subscribe
Highlighted
Accepted Solution

size in MB/GB

I was trying a script that will show more than 80% on all volumes - the output is in Bytes, how do I get it in GB?

Here is my command:

PS C:\Users\admin> Get-NaVol | select name,Aggregate,used,available,sizetotal | ? { $_.used -gt 80 } | ft -AutoSize

Name                               Aggregate      Used    Available     SizeTotal
----                                      ---------            ----     ---------          ---------
vol1                                 a_sata_1          86  67997564928  502511173632

vol2                                 a_sata_4          88 120586096640  971736350720
vol3                                 a_sata_1          89  42216550400  375809638400
vol4                                 a_sata_1          85  623957016576 4098472542208
vol5                                 sas_2               81 133199093760  692563476480

(....I know I need this somewhere >>>   /1gb )

Re: size in MB/GB

Hello, You can use hash tables to get this done.

Get-NaVol | select name,Aggregate,used,@{Name="Available(GB)";Expression={[math]::Round([decimal]$_.Available/1gb,0)}},@{Name="SizeTotal(GB)";Expression={[math]::Round([decimal]$_.sizetotal/1gb,0)}} | ? { $_.used -gt 80 } | ft -AutoSize


PS C:\Users\Vinith> Get-NaVol | select name,Aggregate,used,@{Name="Available(GB)";Expression={[math]::Round([decimal]$_.

Available/1gb,0)}},@{Name="SizeTotal(GB)";Expression={[math]::Round([decimal]$_.sizetotal/1gb,0)}} | ? { $_.used -gt 80

} | ft -AutoSize

Re: size in MB/GB

sweet!

What does the 0 do >>>  $_.sizetotal/1gb,0

I've tried with and without the 0 and it gives me the same result

Thanks

Re: size in MB/GB

I was trying that for 2 filers with no success - what am I doing wrong?

+++++++++++++++++++++++++++++++++++++

Import-Module Dataontap

$myNetAppUser = "root"

$myNetAppArrayPass = "password1"

$myNetAppPass = ConvertTo-SecureString $myNetAppArrayPass -AsPlainText -Force

$myNetappCred = New-Object -TypeName system.Management.Automation.PSCredential -ArgumentList $myNetAppUser,$myNetAppPass

$ntapArrays = "filer1","filer2"

function Get-VolOverEighty {

Get-NaVol | select name,Aggregate,used,@{Name="Available(GB)";Expression={[math]::Round([decimal]$_.Available/1gb,0)}},@{Name="SizeTotal(GB)";Expression={[math]::Round([decimal]$_.sizetotal/1gb,0)}} | ? { $_.used -gt 80 } | ft -AutoSize

}

Foreach ($array in $ntapArrays)

{

connect-nacontroller $array -Credential $myNetAppArrayCred | Get-VolOverEighty

}

+++++++++++++++++++++++++++++++

I'm getting this:

Connect-NaController : Cannot bind argument to parameter 'Name' because it is null.

Thanks

Re: size in MB/GB

Its for rounding off values, for example if you use ($_.sizetotal/1gb,2) it would round off to two decimal places.

Re: size in MB/GB

Replace below line

connect-nacontroller $array -Credential $myNetAppArrayCred | Get-VolOverEighty

with

connect-nacontroller $array -Credential $myNetAppCred | Get-VolOverEighty

$myNetAppArrayCred should be replaced with $myNetAppCred

Re: size in MB/GB

Connect-NaController : The requested name is valid, but no data of the requested type was found

At C:\scripts\over80_vol.ps1:22 char:21

+ connect-nacontroller <<<<  -name $array -Credential $myNetAppCred | Get-VolOverEighty

    + CategoryInfo          : NotSpecified: (Smiley Happy [Connect-NaController], SocketException

    + FullyQualifiedErrorId : System.Net.Sockets.SocketException,DataONTAP.PowerShell.SDK.ConnectNaController

If I connect and run the command on each filer separately, everything works...

Re: size in MB/GB

can you reinstall PStoolkit and try?, Install the latest version PSToolkit v2.3

Re: size in MB/GB

I was running 2.3 - regardless, I reinstalled...same thing

cheers

Re: size in MB/GB

Joel -

A few things I would do differently.

This is a little easier in my opinion

get-navol | Select Name,Aggregate,Used,@{Name="Available (GB)";E={convertto-formattednumber $_.available Datasize "0.00"}} | ? {$_.used -gt 80} | ft -autosize

But, I would do one more thing.  Have a search for a post I did about filer_report.  It will report on the filers with excel conditional formatting.  Give that a shot