Skip to content

Commit

Permalink
Updates Script and ReadMe
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankysWeb committed Jan 5, 2023
1 parent c273d45 commit fbbd73a
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 2 deletions.
111 changes: 111 additions & 0 deletions Get-ExchangeStatus.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#Database Status
write-host "
--------------------------------------------------------------------------------
Database Status
--------------------------------------------------------------------------------
" -foregroundcolor yellow
$Databases = Get-MailboxDatabaseCopyStatus -Server $env:Computername
foreach ($Database in $Databases) {
if ($Database.Status -eq "Mounted" -or $Database.Status -eq "Healthy") {
write-host "Database" $Database.DatabaseName "on Server" $Database.Mailboxserver "is " -NoNewline
write-host $Database.Status -ForegroundColor green
}
else {
write-host "Database" $Database.DatabaseName "on Server" $Database.Mailboxserver "is " -NoNewline
write-host $Database.Status -ForegroundColor red
}
}

#Queue Status
write-host "
--------------------------------------------------------------------------------
Queue Status
--------------------------------------------------------------------------------
" -foregroundcolor yellow
$Queues = Get-Queue -Server $env:Computername
foreach ($Queue in $Queues) {
if ($Queue.Status -eq "Ready") {
write-host "Queue" $Queue.QueueIdentity.Type "on Server" $Queue.QueueIdentity.Server "is " -NoNewline
write-host $Queue.Status -ForegroundColor green
}
else {
write-host "Queue" $Queue.QueueIdentity.Type "on Server" $Queue.QueueIdentity.Server "is " -NoNewline
write-host $Queue.Status -ForegroundColor red
}
}

#Service Status
write-host "
--------------------------------------------------------------------------------
Service Status
--------------------------------------------------------------------------------
" -foregroundcolor yellow
$ExchangeServices = Get-Service -DisplayName "Microsoft Exchange*" | where {$_.StartType -eq "Automatic"}
foreach ($ExchangeService in $ExchangeServices) {
if ($ExchangeService.Status -eq "Running") {
write-host "Service" $ExchangeService.ServiceName "on Server" $env:Computername "is " -NoNewline
write-host $ExchangeService.Status -ForegroundColor green
}
else {
write-host "Service" $ExchangeService.ServiceName "on Server" $env:Computername "is " -NoNewline
write-host $ExchangeService.Status -ForegroundColor red
}
}
#Volume Status
write-host "
--------------------------------------------------------------------------------
Volume Status
--------------------------------------------------------------------------------
" -foregroundcolor yellow
$props = @(
'DriveLetter'
'FileSystemLabel'
'FileSystem'
'DriveType'
'HealthStatus'
'OperationalStatus'
@{
Name = 'SizeRemaining'
Expression = { "{0:N3} Gb" -f ($_.SizeRemaining/ 1Gb) }
}
@{
Name = 'Size'
Expression = { "{0:N3} Gb" -f ($_.Size / 1Gb) }
}
@{
Name = 'PercentFree'
Expression = { "{0:P}" -f ($_.SizeRemaining / $_.Size) }
}
)

$Volumes = Get-Volume | Select-Object $props | where {$_.Size -gt 1GB}
foreach ($Volume in $Volumes) {
if ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -eq "Healthy" -and $Volume.PercentFree -gt 10) {
write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline
write-host $Volume.HealthStatus -ForegroundColor green -NoNewline
write-host " with " -NoNewline
write-host $Volume.PercentFree -ForegroundColor green -NoNewline
write-host " remaining capacity"
}
elseif ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -eq "Healthy" -and $Volume.PercentFree -lt 10) {
write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline
write-host $Volume.HealthStatus -ForegroundColor green -NoNewline
write-host " with " -NoNewline
write-host $Volume.PercentFree -ForegroundColor red -NoNewline
write-host " remaining capacity"
}
elseif ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -ne "Healthy" -and $Volume.PercentFree -gt 10) {
write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline
write-host $Volume.HealthStatus -ForegroundColor red -NoNewline
write-host " with " -NoNewline
write-host $Volume.PercentFree -ForegroundColor green -NoNewline
write-host " remaining capacity"
}
elseif ($Volume.FileSystem -eq "NTFS" -or $Volume.FileSystem -eq "ReFS" -and $Volume.HealthStatus -ne "Healthy" -and $Volume.PercentFree -lt 10) {
write-host "Volume" $Volume.Driveletter $Volume.FileSystemLabel "on Server" $env:Computername "is " -NoNewline
write-host $Volume.HealthStatus -ForegroundColor red -NoNewline
write-host " with " -NoNewline
write-host $Volume.PercentFree -ForegroundColor red -NoNewline
write-host " remaining capacity"
}
}
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# Get-ExchangeStatus
Display Exchange Server Health Status
# Get-ExchangeStatus.ps1

This script displays important Exchange Server health parameters such as database, queue, services and storage space.

## Usage

Download and copy this script to an Exchange Server.
Run the script or start it directly when loading the Exchange Management Shell.

## Tested Exchange / Windows Server Versions

- Exchange Server 2019
- Windows Server 2022

## Visit my Blog for an example

[FrankysWeb](https://www.frankysweb.de/kleines-script-um-den-exchange-server-status-zu-ermitteln/)

0 comments on commit fbbd73a

Please sign in to comment.