diff --git a/Exchange Server/Basic Exchange Health Checks.ps1 b/Exchange Server/Basic Exchange Health Checks.ps1 new file mode 100644 index 0000000..4f37d8c --- /dev/null +++ b/Exchange Server/Basic Exchange Health Checks.ps1 @@ -0,0 +1,13 @@ +# Some basic Exchange Server checks to run after maintenance. +Write-Host -ForeGroundColor Yellow "Service Health" +Test-ServiceHealth +Write-Host -ForeGroundColor Yellow "MAPI Connectivity" +Test-MAPIConnectivity +Write-Host -ForeGroundColor Yellow "Mailbox Database Copy Status" +Get-MailboxDatabaseCopyStatus +Write-Host -ForeGroundColor Yellow "Cluster Node Status" +Get-ClusterNode +Write-Host -ForeGroundColor Yellow "Replication Health" +Test-ReplicationHealth +Write-Host -ForeGroundColor Yellow "Server Component State" +Get-ServerComponentState -Identity $env:COMPUTERNAME diff --git a/Exchange Server/Get DB Sizes.ps1 b/Exchange Server/Get DB Sizes.ps1 new file mode 100644 index 0000000..60b3e7b --- /dev/null +++ b/Exchange Server/Get DB Sizes.ps1 @@ -0,0 +1,4 @@ +Get-MailboxDatabase -Status | Sort-Object Name | ` + Select-Object Name, + @{Name='DB Size (Gb)';Expression={$_.DatabaseSize.ToGb()}}, + @{Name='DB Free Whitespace (Gb)';Expression={$_.AvailableNewMailboxSpace.ToGb()}} diff --git a/Exchange Server/Get Receive Connectors with External Relay Permissions.ps1 b/Exchange Server/Get Receive Connectors with External Relay Permissions.ps1 new file mode 100644 index 0000000..9ebd1d9 --- /dev/null +++ b/Exchange Server/Get Receive Connectors with External Relay Permissions.ps1 @@ -0,0 +1,10 @@ +$ReceiveConnectors = (Get-ExchangeServer | Get-ReceiveConnector).Where({$_.Enabled -eq $true}) | Sort-Object Name,Identity +$ExternalRelays = @() +foreach ($rc in $ReceiveConnectors) { + $dn = $rc.DistinguishedName + if (Get-ADPermission -Identity $dn -User "NT AUTHORITY\ANONYMOUS LOGON" | Where-Object {$_.ExtendedRights.RawIdentity -eq "MS-Exch-SMTP-Accept-Any-Recipient"}) { + $ExternalRelays += $rc + } +} + +$ExternalRelays | Select-Object Name,Server,Enabled -Unique diff --git a/Exchange Server/List All Exchange Server Virtual Directories.ps1 b/Exchange Server/List All Exchange Server Virtual Directories.ps1 new file mode 100644 index 0000000..d20360f --- /dev/null +++ b/Exchange Server/List All Exchange Server Virtual Directories.ps1 @@ -0,0 +1,2 @@ +# A fun way to find every cmdlet that gets Exchange virtual directories and then pipe that list to run it against the current server. +foreach ($c in ((Get-Command "Get*VirtualDirectory" -CommandType Function).Name)) {& $c -server $env:COMPUTERNAME | Format-List Name,InternalUrl,ExternalUrl} diff --git a/Exchange Server/Remove Old Exchange Server Log Files.ps1 b/Exchange Server/Remove Old Exchange Server Log Files.ps1 new file mode 100644 index 0000000..375a1bc --- /dev/null +++ b/Exchange Server/Remove Old Exchange Server Log Files.ps1 @@ -0,0 +1,21 @@ +<# +.SYNOPSIS +A script to clear old Exchange logs files. +.DESCRIPTION +This script will clear all Exchange Server log files under the installation's "Logging" path that are older than a set +number of days. (It will not touch database log files unless those are intentionally put in the worst possible location!) + +#> + +# Set the number of days to preserve logs from. +$LogAgeDays = 14 + +# Check for the existince of the Exchange logging folder under the install path. +if (Test-Path -Path "$env:ExchangeInstallPath\Logging") { + Set-Location -Path "$env:ExchangeInstallPath\Logging" -ErrorAction Stop + + # Get Exchang Server logs that are older than [nn] days and remove them. Any log files still in use will not be deleted. + Get-ChildItem -Path "$env:ExchangeInstallPath\Logging" -Recurse -Include *.log | ` + Where-Object { $_.LastWriteTime -lt ((Get-Date).AddDays(-$LogAgeDays)) } | ` + Remove-Item -Confirm:$false -ErrorAction SilentlyContinue +}