Carl Billington
asked on
Find all mailboxes that are under 1024MB
I would like to find all mailboxes in our Exchange 2010 environment that are under 1024MB who are NOT a member of the security group; 'Mailbox Quota Policy'.
Thank you.
Thank you.
ASKER
Thanks. The script is not working. It is still reports users who are a member of the AD security group 'Mailbox Quota Policy'. I have changed change line 33 to my group name.
I think line 33 should have $aduser instead of $user
if ($aduser.MemberOf -notmatch "Mailbox Quota Policy")
if ($aduser.MemberOf -notmatch "Mailbox Quota Policy")
ASKER
Thanks but no results are displaying now.
Try this one. I am going through the script but I do not have exchange so I cannot test, it seems everything was there but I think some changes needed to be made. Let me know
$2007snapin = Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.Admin
if ($2007snapin)
{
$AdminSessionADSettings.ViewEntireForest = 1
}
else
{
$2010snapin = Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010
if ($2010snapin)
{
Set-ADServerSettings -ViewEntireForest $true
}
}
Import-Module ActiveDirectory
$report = @()
Write-Host -ForegroundColor White "Collecting mailbox list"
$mailboxes = @(Get-Mailbox -resultsize unlimited -IgnoreDefaultScope)
Write-Host -ForegroundColor White "Collecting report data"
$mailboxcount = $mailboxes.count
$i = 0
#Loop through mailbox list and find the aged mailboxes
foreach ($mb in $mailboxes)
{
$i = $i + 1
$pct = $i/$mailboxcount * 100
Write-Progress -Activity "Collecting mailbox details" -Status "Processing mailbox $i of $mailboxcount - $mb" -PercentComplete $pct
$aduser = Get-ADUser $mb.samaccountname -Properties Enabled,AccountExpirationDate,memberof
if ($aduser.MemberOf -notmatch "Mailbox Quota Policy")
{
$tempstat = $mb | Get-MailboxStatistics
if ($tempstat.TotalItemSize -lt 1024mb)
{
$userObj = New-Object PSObject
$userObj | Add-Member NoteProperty -Name "DisplayName" -Value $tempstat.DisplayName
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $tempstat.TotalItemSize
$report = $report += $userObj
}
}
}
$report | Sort-Object TotalItemSize
ASKER
Thanks, but the script is still listing users who are a member of Mailbox Quota Policy security group.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You're a genius!!!
:) glad to help
change line 33 to your group name
Open in new window