-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGet-Mailbox_Departments.ps1
47 lines (24 loc) · 1.16 KB
/
Get-Mailbox_Departments.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$Results = ForEach ($User in (Get-ADUser -Filter * -Properties Department,Mail))
{ $Mailbox = Get-Mailbox $User.Name -ErrorAction SilentlyContinue
If ($Mailbox)
{ $Mail = $Mailbox | Get-MailboxStatistics -ErrorAction SilentlyContinue
If ($Mail.TotalItemSize.Value -eq $null)
{ $TotalSize = 0
}
Else
{ $TotalSize = $Mail.TotalItemSize.Value.ToMB()
}
New-Object PSObject -Property @{
Name = $User.Name
SamAccountName = $User.SamAccountName
Email = $User.Mail
Department = $User.Department
MailboxSize = $TotalSize
IssueWarningQuota = $Mailbox.IssueWarningQuota
ProhibitSendQuota = $Mailbox.ProhibitSendQuota
ProhibitSendReceiveQuota = $Mailbox.ProhibitSendReceiveQuota
MailboxItemCount = $Mail.ItemCount
}
}
}
$Results | Select Name,SamAccountName,Email,Department,MailboxSize,IssueWarningQuota,ProhibitSendQuota,ProhibitSendReceiveQuota,MailboxItemCount | Export-Csv c:\Scripts\7-2MailboxSizeByDepartment.csv -NoTypeInformation