 |
Find-ExchangeDBFreeSpace |
-
-
-
-
-
- if (Test-Path "FreeSpaceGreaterThan1GB.csv")
- {
- Remove-Item "FreeSpaceGreaterThan1GB.csv"
- }
-
-
- $rows = "Servername," + "Mailbox Store," + "Free Space (MB),"
- Add-Content FreeSpaceGreaterThan1GB.csv $rows
-
- $ExchServer = 'server1','server2'
- foreach ($Server in $ExchServer)
- {
-
- $WmidtQueryDT = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-1))
-
- $1221 = Get-WmiObject -computer $ExchServer -query ("Select * from Win32_NTLogEvent Where Logfile='Application' and Eventcode = '1221' and TimeWritten >='" + $WmidtQueryDT + "'")
-
- foreach ($event in $1221)
- {
-
- $MBXStoreLocationStart = $event.Message.IndexOf("Storage Group") + 16
- $MBXStoreLocationFinish = $event.Message.IndexOf("has") - 2
- $MBXStoreLocation = $event.Message.SubString($MBXStoreLocationStart, $MBXStoreLocationFinish - $MBXStoreLocationStart)
-
-
- $MBLocationStart = $event.Message.IndexOf("has") + 4
- $MBLocationFinish = $event.Message.IndexOf("megabytes") - 1
- $MBLocation = $event.Message.SubString($MBLocationStart, $MBLocationFinish - $MBLocationStart)
- $result = [int]$MBLocation
-
- $ComputerName = $event.ComputerName
-
-
- if ($result -ge 3072)
- {
- $rowline = "$ComputerName," + "$MBXStoreLocation," + "$MBLocation,"
- Add-Content FreeSpaceGreaterThan1GB.csv $rowline
- }
- }
- }