I’m trying to run a powershell command that will find users with a ProhibitSendQuota over 40GB and then reduce the quota to the company standard 2.1GB limit. I have found the below command and has worked for any users over 9GB
That is strange. I am running the code as you have it above; testing both 1GB and 14GB (as a number of users are set to 1 or 14) and it filtered as one would expect.
Can you copy the code line you’re using in the console exactly like you’re using it and paste it here formatted as code using the preformatted text button ( </> ) ?
So per the MS docs page’s example, have you tried wrapping your quota in quotes? Admittedly I cannot reproduce your issue even not using quotes, but would be worth a shot.
You can only use the Filter parameter to look for the value Unlimited for this property. For example, Get-Mailbox -Filter "ProhibitSendQuota -eq 'Unlimited'" or Get-Mailbox -Filter "ProhibitSendQuota -ne 'Unlimited'" .
You can’t use the Filter parameter to look for size values of this property. Instead, use this syntax: Get-Mailbox | where "$_.ProhibitSendQuota -<Operator> '<Size>'" . For example, Get-Mailbox | where "$_.ProhibitSendQuota -lt '70GB'" .
$Mailboxes = Get-Mailbox -ResultSize Unlimited | Select DisplayName, Database, IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota, Alias
foreach ($Mailbox in $Mailboxes){
write-output $Mailbox.ProhibitSendQuota.substring(0,4)
}
Will get the command to return email address and then will be able to use an IF statement to check if the quota is over a certain value and then use the email address to run a command to reduce the quotas
Please do not post images of code as this is not helpful. Instead click on the preformatted text button ( </> ) and paste the code as text where you’ve been told.
And please do not add another post - edit the existing one and correct the formatting.
This is because Exchange stores that property value as a string, so what you are asking the where to do is compare on a string to an int or int64 which won’t work.
If you were using the Exchange snap-in OnPrem that presents a serialized value with multiple methods to convert it to bytes, MB, GB. But with a remote session which you have to do with Exchange Online then you just have a string .
As a workaround if you get a mailbox with the correct ‘prohibitsendquota’ string you can run a filter with that. This will only get you part of the way there but you can at least return fewer mailboxes to parse