Link to home
Start Free TrialLog in
Avatar of Robert Logan
Robert LoganFlag for United States of America

asked on

How do I display the output of Get-FsrmQuota in GB rather than Kb?

RE: Windows Server: File Server Resource Manager.

Is it possible to display the results of Get-FsrmQuota in GB rather than Kb?  

Here's the code I run in PowerShell -

Get-FsrmQuota | Select-Object Path, Usage | Sort-Object Path

Here's the result:

Path                                                 Usage
----                                                 -----
E:\Resources\Groups\Accounting                 33421165568
E:\Resources\Groups\Arboretum                  63962508288
E:\Resources\Groups\Biometrics                  1689715712
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

You can do it in-line this way:

Get-FsrmQuota | Select-Object Path, @{"Name"="Usage (GB)"; "Expression"=$([math]::Round(($_.Usage / 1GB),2))} | Sort-Object Path

Open in new window

Avatar of Robert Logan

ASKER

Thanks for replying.  I'm headed out for the weekend but when I tried that command in a PS window, I got the following error.  (I'll be back Monday.)

Select-Object : The "Expression" key has a type, System.Decimal, that is not valid; expected types are {System.String,
System.Management.Automation.ScriptBlock}.
At line:1 char:17
+ ... FsrmQuota | Select-Object Path, @{"Name"="Usage (GB)"; "Expression"=$ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Select-Object], NotSupportedException
    + FullyQualifiedErrorId : DictionaryKeyIllegalValue1,Microsoft.PowerShell.Commands.SelectObjectCommand
Maybe adding this might help ".ToString()" as shown below:

Get-FsrmQuota | Select-Object Path, @{"Name"="Usage (GB)"; "Expression"=$([math]::Round(($_.Usage / 1GB),2)).ToString()} | Sort-Object Path
Hmm, Try this alternative version, starting with the most stripped down version:

Most Stripped down (no Rounding):
Get-FsrmQuota | Select Path, @{Expression={$_.Usage / 1GB;Label="Usage_GB"} | Sort-Object Path

Open in new window


Alternate rounding version:
Get-FsrmQuota | Select Path, @{Expression={$([math]::Round(($_.Usage / 1GB),2));Label="Usage_GB"} | Sort-Object Path

Open in new window

Sajen Jose:  When I run your code, it dumps me into a ">>" prompt.

PS C:\Windows\system32> Get-FsrmQuota | Select-Object Path, @{"Name"="Usage (GB)"; "Expression"=$([math]::Round(($_.Usage / 1GB),2)).ToString
>>
Sajen -- My mistake.  Your code generates a Path list but doesn't generate Usage (GB):

Path                                          Usage (GB)
----                                          ----------
E:\Resources\Groups\Accounting
E:\Resources\Groups\Applied Forest Management
E:\Resources\Groups\Arboretum
E:\Resources\Groups\AvianScienceCenter
E:\Resources\Groups\BandyRanch
E:\Resources\Groups\Biometrics
Ben Personick  --

When I run your either your first or second revision,  I get dumped into a ">>" prompt.

PS C:\Windows\system32> Get-FsrmQuota | Select Path, @{Expression={$_.Usage / 1GB;Label="Usage_GB"} | Sort-Object Path
>>

PS C:\Windows\system32> Get-FsrmQuota | Select Path, @{Expression={$([math]::Round(($_.Usage / 1GB),2));Label="Usage_GB"} | Sort-Object Path
>>
Sajan's Code is my code with a "To String" which may mean that it's generating a null value response...

  What version of Powershell are you running?
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      14393  1944
ASKER CERTIFIED SOLUTION
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ben,
Nailed it.  Thank you so much!

Robert
Ben,
Nailed it.  Thank you so much!

Robert