Microsoft Virtualization Discussions

AutoSize

JSHACHER11
7,165 Views

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
7,162 Views

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
7,125 Views

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
7,125 Views

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
7,125 Views

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
7,125 Views

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
7,125 Views

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
7,163 Views

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

JSHACHER11
7,125 Views

....like a charm!!

thank you

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

JGPSHNTAP
7,125 Views

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
7,125 Views

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
5,711 Views

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

JGPSHNTAP
5,710 Views

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
5,710 Views

thanks

Public