We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

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

Robert Logan
Robert Logan asked
on
Medium Priority
1,170 Views
Last Modified: 2018-03-13
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
Comment
Watch Question

Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer
CERTIFIED EXPERT

Commented:
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

Robert LoganSemi-retired Windows Tier III

Author

Commented:
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
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer
CERTIFIED EXPERT

Commented:
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

Robert LoganSemi-retired Windows Tier III

Author

Commented:
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
>>
Robert LoganSemi-retired Windows Tier III

Author

Commented:
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
Robert LoganSemi-retired Windows Tier III

Author

Commented:
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
>>
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer
CERTIFIED EXPERT

Commented:
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?
Robert LoganSemi-retired Windows Tier III

Author

Commented:
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      14393  1944
Lead SaaS Infrastructure Engineer
CERTIFIED EXPERT
Commented:
Found a problem with my examples, I can't use FSRM quote for testing, and I think the example I used was WMIC, but likely the issue is simply I missed some curlies, and needed to use the name instead of the label (label seems to work for WMIC, but not everything, name seems to be more universal.)

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

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Robert LoganSemi-retired Windows Tier III

Author

Commented:
Ben,
Nailed it.  Thank you so much!

Robert
Robert LoganSemi-retired Windows Tier III

Author

Commented:
Ben,
Nailed it.  Thank you so much!

Robert
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer
CERTIFIED EXPERT

Commented:
Glad to help! :)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.