-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMBXandDBStats.ps1
67 lines (43 loc) · 1.87 KB
/
MBXandDBStats.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$filePath
)
# Generate a list with number of databases on each Exchange Server
Write-Host Getting count of databases on each server... -ForegroundColor "Cyan"
# Create a HashTable to store database count
$DBCount = @{}
#Get list of Exchange Servers
$Servers = (Get-ExchangeServer).name
ForEach ($Server in $Servers)
{
# Get-MaiboxDatabase on each server
$DBs = Get-MailboxDatabase -Server $server | sort name
# Add databases into the HashTable
$DBCount.Add($Server,$DBs.Count)
# Keep a running output so you see the work being done.
Write-Host $server $DBs.Count
}
Write-Host $nl
# Output the results to a text file named DatabasesPerServer.txt
$DBCount | sort server > $filePath\DatabasesPerServer.txt
# Generate a list with number of mailboxes per database
Write-Host Getting count of mailboxes on each database... -ForegroundColor "Cyan"
# Create a HashTable to store mailbox count
$MBXCount = @{}
# Get list of Mailbox Databases
$Databases = (Get-MailboxDatabase).name
ForEach ($Database in $Databases)
{
# Get-Maibox on each database
$MBXs = Get-Mailbox -Database $Database | sort name
# Add mailboxes into the HashTable
$MBXCount.Add($Database,$MBXs.Count)
# Keep a running output so you see the work being done.
Write-Host $Database $MBXs.Count
}
Write-Host $nl
# Output results to a text file named MailboxesPerDatabase.txt
$MBXCount | sort server > $filePath\MailboxesPerDatabase.txt
Write-Host $nl
Write-Host Output files are located in $filePath -ForegroundColor "Cyan"