Microsoft Virtualization Discussions

get-navol returns different results when run in console vs script


When I run get-navol from the PowerShell console I get the following formated results:

Name                      State       TotalSize  Used  Available Dedupe  FilesUsed FilesTotal Aggregate

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

backup                    online         1.0 TB   26%   761.5 GB False         106        32M aggr1

groups_snap               online       255.0 GB    0%   255.0 GB  True         114        11M aggr0

Local_backup              online         3.0 TB   86%   425.6 GB False         489        32M aggr1

users_snap                online       505.0 GB    0%   505.0 GB False         108        22M aggr0

vol0                      online        80.0 GB    1%    79.0 GB False          7k         3M aggr0

However, I run the same command from within a script, it is as if I was running get-navol | fl *

Autosize                     : NetApp.Ontapi.Filer.Volume801.Autosize

BlockType                    :

ChecksumStyle                : block

CloneChildren                :

CloneParent                  :

ContainingAggregate          : aggr0

DiskCount                    : 4

ExpiryDate                   :

ExpiryDateDT                 :

FilesPrivateUsed             :

FilesTotal                   : 10808871

FilesUsed                    : 107


Any ideas?


Re: get-navol returns different results when run in console vs script


All commands invoked via the PowerShell console are implicitly passed to Out-Default for formatting.  In your script, try piping Get-NaVol to Out-String for the same effect (and you can even adjust the formatting width).  This article explains this more fully:

View solution in original post

Re: get-navol returns different results when run in console vs script


Yep, figured this out.  The fix was to pipe out to ft (format table) on the first command in the script.  | ft -AutoSize.  Piping out to | ft -AutoSize on the second command alone did not seem to work.

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums