├── .gitattributes ├── README.md ├── LICENSE └── Get-ExchangeStatus.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Get-ExchangeStatus.ps1 2 | 3 | This script displays important Exchange Server health parameters such as database, queue, services and storage space. 4 | 5 | ## Usage 6 | 7 | Download and copy this script to an Exchange Server. 8 | Run the script or start it directly when loading the Exchange Management Shell. 9 | 10 | ## Tested Exchange / Windows Server Versions 11 | 12 | - Exchange Server 2019 13 | - Windows Server 2022 14 | 15 | ## Visit my Blog for an example 16 | 17 | [FrankysWeb](https://www.frankysweb.de/kleines-script-um-den-exchange-server-status-zu-ermitteln/) 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 FrankysWeb 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Get-ExchangeStatus.ps1: -------------------------------------------------------------------------------- 1 | #Database Status 2 | write-host " 3 | -------------------------------------------------------------------------------- 4 | Database Status 5 | -------------------------------------------------------------------------------- 6 | " -foregroundcolor yellow 7 | $Databases = Get-MailboxDatabaseCopyStatus -Server $env:Computername 8 | foreach ($Database in $Databases) { 9 | if ($Database.Status -eq "Mounted" -or $Database.Status -eq "Healthy") { 10 | write-host "Database" $Database.DatabaseName "on Server" $Database.Mailboxserver "is " -NoNewline 11 | write-host $Database.Status -ForegroundColor green 12 | } 13 | else { 14 | write-host "Database" $Database.DatabaseName "on Server" $Database.Mailboxserver "is " -NoNewline 15 | write-host $Database.Status -ForegroundColor red 16 | } 17 | } 18 | 19 | #Queue Status 20 | write-host " 21 | -------------------------------------------------------------------------------- 22 | Queue Status 23 | -------------------------------------------------------------------------------- 24 | " -foregroundcolor yellow 25 | $Queues = Get-Queue -Server $env:Computername 26 | foreach ($Queue in $Queues) { 27 | if ($Queue.Status -eq "Ready") { 28 | write-host "Queue" $Queue.QueueIdentity.Type "on Server" $Queue.QueueIdentity.Server "is " -NoNewline 29 | write-host $Queue.Status -ForegroundColor green 30 | } 31 | else { 32 | write-host "Queue" $Queue.QueueIdentity.Type "on Server" $Queue.QueueIdentity.Server "is " -NoNewline 33 | write-host $Queue.Status -ForegroundColor red 34 | } 35 | } 36 | 37 | #Service Status 38 | write-host " 39 | -------------------------------------------------------------------------------- 40 | Service Status 41 | -------------------------------------------------------------------------------- 42 | " -foregroundcolor yellow 43 | $ExchangeServices = Get-Service -DisplayName "Microsoft Exchange*" | where {$_.StartType -eq "Automatic"} 44 | foreach ($ExchangeService in $ExchangeServices) { 45 | if ($ExchangeService.Status -eq "Running") { 46 | write-host "Service" $ExchangeService.ServiceName "on Server" $env:Computername "is " -NoNewline 47 | write-host $ExchangeService.Status -ForegroundColor green 48 | } 49 | else { 50 | write-host "Service" $ExchangeService.ServiceName "on Server" $env:Computername "is " -NoNewline 51 | write-host $ExchangeService.Status -ForegroundColor red 52 | } 53 | } 54 | #Volume Status 55 | write-host " 56 | -------------------------------------------------------------------------------- 57 | Volume Status 58 | -------------------------------------------------------------------------------- 59 | " -foregroundcolor yellow 60 | $props = @( 61 | 'DriveLetter' 62 | 'FileSystemLabel' 63 | 'FileSystem' 64 | 'DriveType' 65 | 'HealthStatus' 66 | 'OperationalStatus' 67 | @{ 68 | Name = 'SizeRemaining' 69 | Expression = { "{0:N3} Gb" -f ($_.SizeRemaining/ 1Gb) } 70 | } 71 | @{ 72 | Name = 'Size' 73 | Expression = { "{0:N3} Gb" -f ($_.Size / 1Gb) } 74 | } 75 | @{ 76 | Name = 'PercentFree' 77 | Expression = { "{0:P}" -f ($_.SizeRemaining / $_.Size) } 78 | } 79 | ) 80 | 81 | $Volumes = Get-Volume | Select-Object $props | where {$_.Size -gt 1GB} 82 | foreach ($Volume in $Volumes) { 83 | if ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -eq "Healthy" -and $Volume.PercentFree -gt 10) { 84 | write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline 85 | write-host $Volume.HealthStatus -ForegroundColor green -NoNewline 86 | write-host " with " -NoNewline 87 | write-host $Volume.PercentFree -ForegroundColor green -NoNewline 88 | write-host " remaining capacity" 89 | } 90 | elseif ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -eq "Healthy" -and $Volume.PercentFree -lt 10) { 91 | write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline 92 | write-host $Volume.HealthStatus -ForegroundColor green -NoNewline 93 | write-host " with " -NoNewline 94 | write-host $Volume.PercentFree -ForegroundColor red -NoNewline 95 | write-host " remaining capacity" 96 | } 97 | elseif ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -ne "Healthy" -and $Volume.PercentFree -gt 10) { 98 | write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline 99 | write-host $Volume.HealthStatus -ForegroundColor red -NoNewline 100 | write-host " with " -NoNewline 101 | write-host $Volume.PercentFree -ForegroundColor green -NoNewline 102 | write-host " remaining capacity" 103 | } 104 | elseif ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -ne "Healthy" -and $Volume.PercentFree -lt 10) { 105 | write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline 106 | write-host $Volume.HealthStatus -ForegroundColor red -NoNewline 107 | write-host " with " -NoNewline 108 | write-host $Volume.PercentFree -ForegroundColor red -NoNewline 109 | write-host " remaining capacity" 110 | } 111 | } --------------------------------------------------------------------------------