Microsoft Virtualization Discussions

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

JOHNVILLA
4,278 Views

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

etc.......

Any ideas?

1 ACCEPTED SOLUTION

cknight
4,278 Views

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: http://poshoholic.com/tag/out-string/

View solution in original post

2 REPLIES 2

cknight
4,279 Views

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: http://poshoholic.com/tag/out-string/

wmorlett
4,278 Views

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.

Public