Quota Management - Get-FSRMQuota (results in GB)

Welcome Forums General PowerShell Q&A Quota Management - Get-FSRMQuota (results in GB)

This topic contains 1 reply, has 2 voices, and was last updated by

6 months, 2 weeks ago.

  • Author
  • #113476

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member


    Hello, I am using the following command to retrieve stats from FSRM but cannot figure out how to return both Size and Usage in GB.  I don't understand what the @ is doing here.. building an array ? Help much appreciated.


    Get-FsrmQuota | Format-Table Path, Size, @{Label="Usage GB"; Expression={$($_.size/1GB) -as [int] }} -auto


    This commend displays only the Usage in GB, size is still in bytes.

  • #113480

    Topics: 8
    Replies: 1190
    Points: 639
    Helping Hand
    Rank: Major Contributor

    The posted code is using a Calculated Expression\Property. Rather then running a for loop to create a new custom object, you can leverage calculated expressions to reformat or really do anything inside of a column. Basically, the defined expression is code, so your code would look something like:

    $(19899999947 / 1GB) -as [int]

    The $() wrapper is more a order of operations to ensure the math is completed before using -as [int] to do rounding for you. The 1gb is a multiplier so that you don't need to do exponential math for 1024 times 3,4,5 etc.

    #Create a test object
    $test = [pscustomobject]@{Path='d:\www\example.com';Size=3758096384}
    #You create another column called SizeGB and divide the value of Size by 1gb
    $test | Select-Object Path, Size, @{Name='SizeGB';Expression={$_.Size / 1gb}}
    #You can add the current date using nothing in the current test object. Notice it is using Label not Name, same difference, potato potater
    $test | Select-Object Path, Size, @{Name='SizeGB';Expression={$_.Size / 1gb}}, @{Label='CurrentDate';Expression={(Get-Date)}}
    #You can also change the Size column to do the math
    $test | Select-Object Path, @{Name='Size';Expression={$_.Size / 1gb}}


    PS C:\Users\Rob> $test | Select-Object Path, Size, @{Name='SizeGB';Expression={$_.Size / 1gb}}
    Path                     Size SizeGB
    ----                     ---- ------
    d:\www\example.com 3758096384    3.5
    PS C:\Users\Rob> $test | Select-Object Path, Size, @{Name='SizeGB';Expression={$_.Size / 1gb}}, @{Label='CurrentDate';Expression={(Get-Date)}}
    Path                     Size SizeGB CurrentDate         
    ----                     ---- ------ -----------         
    d:\www\example.com 3758096384    3.5 10/8/2018 9:47:49 AM
    PS C:\Users\Rob> $test | Select-Object Path, @{Name='Size';Expression={$_.Size / 1gb}}
    Path               Size
    ----               ----
    d:\www\example.com  3.5

    You can read more here: https://mcpmag.com/articles/2017/01/19/using-powershell-calculated-properties.aspx

The topic ‘Quota Management - Get-FSRMQuota (results in GB)’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort