Community maintenance is complete. Thank you for your patience!

Microsoft Virtualization Discussions

AutoSize

JSHACHER11

Hi guys,

I would like to get the values of Autosize (maximum and increments) for all the volumes in the filer

I've tried 'Get-NaVol | Get-NaVolAutosize' but it gives no names of the volumes

any ideas?

Cheers

1 ACCEPTED SOLUTION

JGPSHNTAP

Ah, when you write things quick in notepad this happens...  Ok, give this a whilr

$global=@()
[Int64]$Unit=1GB

$vols = Get-navol

$vols | % {

$volume = $_

$autosize = get-navolautosize $volume -ea "silentlycontinue"

If ($autosize.isEnabled) {


$customobject = new-object psobject
     add-member -inputobject $customobject -membertype noteproperty -name Volume -value $volume
     add-member -inputobject $customobject -membertype noteproperty -name Autosize -value "enabled"
     add-member -inputobject $customobject -membertype noteproperty -name Max -value ([System.Math]::Floor($autosize.maximumsize/$unit))
     add-member -inputobject $customobject -membertype noteproperty -name increment -value ([System.Math]::Floor($autosize.incrementsize/$unit))


$global += $customobject


}

}
$global | ft -autosize

and then you can dump it to excel

$global | export-csv c:\temp\autosize.csv -notypeinformation

View solution in original post

12 REPLIES 12

JGPSHNTAP

You're looking for something like this

$autosize = get-navolautosize $name -ea "silentlycontinue"

$unit = 1gb

If ($autosize.isEnabled) {

  [System.Math]::Floor($autosize.maximumsize/$unit)

[System.Math]::Floor($autosize.incrementsize/$unit)

}

You can start with that in your loop, I use that for an excel output so it's a little different, but those are the properties you need

So in your case

$vols = Get-navol

$vols | % {

$volume = $_

$autosize = get-navolautosize $name -ea "silentlycontinue"

$unit = 1gb

If ($autosize.isEnabled) {

$max =  [System.Math]::Floor($autosize.maximumsize/$unit)

$inc =  [System.Math]::Floor($autosize.incrementsize/$unit)

write-host "Autosize:  enabled " & "maximum size: "  $max & "increment size: " $inc

}

Give that a shot, I didn't test it

JSHACHER11

results:

===================

Ampersand not allowed. The & operator is reserved for future use; use "&" to pass ampersand as a string.

At C:\autosize.ps1:9 char:35

+ write-host "Autosize:  enabled " & <<<<  "maximum size: "  $max & "increment size: " $inc

    + CategoryInfo          : ParserError: (:) [], ParseException

    + FullyQualifiedErrorId : AmpersandNotAllowed

==================

thank you

JSHACHER11

I've changed it to this:

===================

$vols = Get-navol

$vols | % {

$volume = $_

$autosize = get-navolautosize $name -ea "silentlycontinue"

$unit = 1gb

If ($autosize.isEnabled) {

$max =  [System.Math]::Floor($autosize.maximumsize/$unit)

$inc =  [System.Math]::Floor($autosize.incrementsize/$unit)}

write-host "Autosize:  enabled "

write-host "maximum size: "  $max

write-host "increment size: " $inc

===================

but now I am getting this:

Get-NaVolAutosize : Cannot bind argument to parameter 'Name' because it is null.

At C:\autosize.ps1:4 char:30

+ $autosize = get-navolautosize <<<<  $name -ea "silentlycontinue"

    + CategoryInfo          : InvalidData&colon; (:) [Get-NaVolAutosize], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,DataONTAP.PowerShell.SDK.Cmdlets.Volume.G

   etNaVolAutosize

Autosize:  enabled

maximum size:

increment size:

JGPSHNTAP

change $name to $volume

But we should do this the right way with custom objects

$global=@()

$vols = Get-navol

$vols | % {

$volume = $_

$autosize = get-navolautosize $volume -ea "silentlycontinue"

$unit = 1gb

If ($autosize.isEnabled) {

$customobject = new-object psobject

     add-member -inputobject $customobject -membertype noteproperty -name Volume -value $volume

     add-member -inputobject $customobject -membertype noteproperty -name Autosize -value "enabled"

  add-member -inputobject $customobject -membertype noteproperty -name Max -value [System.Math]::Floor($autosize.maximumsize/$unit)

  add-member -inputobject $customobject -membertype noteproperty -name increment -value [System.Math]::Floor($autosize.incrementsize/$unit)}

$global += $customobject

}

$global | ft -autosize

###

Try that

JSHACHER11

results:

===========================

Add-Member : The SecondValue parameter is not necessary for a member of type "NoteProperty" and should not be specified

. Do not specify the SecondValue parameter when adding members of this type.

At C:\autosize2.ps1:13 char:13

+   add-member <<<<  -inputobject $customobject -membertype noteproperty -name increment -value [System.Math]::Floor($a

utosize.incrementsize/$unit)}

    + CategoryInfo          : InvalidOperation: (:) [Add-Member], InvalidOperationException

    + FullyQualifiedErrorId : Value2ShouldNotBeSpecified,Microsoft.PowerShell.Commands.AddMemberCommand

JGPSHNTAP

Ah, when you write things quick in notepad this happens...  Ok, give this a whilr

$global=@()
[Int64]$Unit=1GB

$vols = Get-navol

$vols | % {

$volume = $_

$autosize = get-navolautosize $volume -ea "silentlycontinue"

If ($autosize.isEnabled) {


$customobject = new-object psobject
     add-member -inputobject $customobject -membertype noteproperty -name Volume -value $volume
     add-member -inputobject $customobject -membertype noteproperty -name Autosize -value "enabled"
     add-member -inputobject $customobject -membertype noteproperty -name Max -value ([System.Math]::Floor($autosize.maximumsize/$unit))
     add-member -inputobject $customobject -membertype noteproperty -name increment -value ([System.Math]::Floor($autosize.incrementsize/$unit))


$global += $customobject


}

}
$global | ft -autosize

and then you can dump it to excel

$global | export-csv c:\temp\autosize.csv -notypeinformation

View solution in original post

JSHACHER11

....like a charm!!

thank you

now you just need to explain the 'Floor' command please

JGPSHNTAP

Yeah - that's easy

$global=@()
[Int64]$Unit=1GB

$vols = Get-navol

$vols | % {

$volume = $_
$size = ([System.Math]::Floor($_.totalsize/$unit))
$autosize = get-navolautosize $volume -ea "silentlycontinue"

If ($autosize.isEnabled) {


$customobject = new-object psobject
     add-member -inputobject $customobject -membertype noteproperty -name Volume -value $volume
  add-member -inputobject $customobject -membertype noteproperty -name size -value $size
     add-member -inputobject $customobject -membertype noteproperty -name Autosize -value "enabled"
     add-member -inputobject $customobject -membertype noteproperty -name Max -value ([System.Math]::Floor($autosize.maximumsize/$unit))
     add-member -inputobject $customobject -membertype noteproperty -name increment -value ([System.Math]::Floor($autosize.incrementsize/$unit))

$global += $customobject


}

}
$global | ft -autosize

Ok - enjoy, I need to get back to work.. if you want total volsize, use that full cmdlet.  As for objects, you need to read up on them, they are pretty powerful

JSHACHER11

thanks

JGPSHNTAP

Floor is just round down to next whole number.. You can play with the formatting, but you should be more interested in the custom objects.  You can export and import them.. Much easier for scripting

JSHACHER11

OK, you have my attention

so custom objects are basically properties that we have added to the 'get-navolautosize' cmdlet - what you would normally see with the get-member command, correct?

JSHACHER11

is it possible to get a table of the max autosize and the volume size (and volume name) - something like this:

name  max_autosize  vol_size

--------   -----------------     ----------

vol0         124GB         104GB   

vol5         640GB         421GB

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public