Page 1 of 1

Shared drives quota

Posted: Mon May 04, 2020 8:51 pm
by RebeccaIlene
Hi Team,

We have a powershell script that we use to monitor quota on windows shares.

However, the script returns a Warning when no data is in the folder.

WARNING: 0.00 GB of 600.00 GB used, 0.00% used.

Can someone please help fix this?

Here is the command definition and have attached the script as well.

check_quota_Copies=check_quota.ps1 -Path "M:\Shares\Copies" -Warn 20 -Crit 10

Thank you,
Rebecca Murray

Re: Shared drives quota

Posted: Tue May 05, 2020 2:14 pm
by ssax
You should be able to do this (adding .00 to both warn and crit):

check_quota.ps1 -Path "M:\Shares\Copies" -Warn 20.00 -Crit 10.00

Or change these lines:

Code: Select all

$percentUsed = "{0:n2}" -f ($quotaObject.Usage / $quotaObject.Size * 100)
$percentFree = "{0:n2}" -f (100 - $quotaObject.Usage / $quotaObject.Size * 100)
To these:

Code: Select all

$percentUsed = [int]($quotaObject.Usage / $quotaObject.Size * 100)
$percentFree = [int](100 - $quotaObject.Usage / $quotaObject.Size * 100)