Chuyển tới nội dung chính

Troubleshooting

Exchange Management Shell Issues

EMS Not Working - Use PowerShell Directly

Import Exchange modules manually (version-specific):

# Exchange 2007
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

# Exchange 2010
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

# Exchange 2013 & 2016
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

Remove Disabled Mailboxes

List Disabled Mailboxes in Database

Get-MailboxStatistics -Database Manager |
Where-Object {$_.DisconnectReason -eq "Disabled"} |
Format-List

Remove Disabled Mailbox by GUID

# Get mailbox GUID from previous command
Remove-StoreMailbox -Database Manager `
-Identity "d719c6ff-4e66-46f9-b297-300bea5d5951" `
-MailboxState Disabled

Remove-StoreMailbox -Database Manager `
-Identity "06e0eb65-c51d-45a0-a368-812fd79416e2" `
-MailboxState Disabled

Reference: Remove-StoreMailbox Documentation

Virtual Directory Issues

Rebuild OWA Virtual Directory

# Remove old directory
Remove-OwaVirtualDirectory "server\owa (Default Web Site)"

# Create new directory
New-OwaVirtualDirectory `
-InternalUrl "https://mail.contoso.com/owa" `
-ExternalUrl "https://mail.contoso.com/owa"

Rebuild ECP Virtual Directory

# Remove old directory
Remove-EcpVirtualDirectory -Identity "server\ecp (Default Web Site)"

# Create new directory
New-EcpVirtualDirectory `
-InternalUrl "https://mail.contoso.com/ecp" `
-ExternalUrl "https://mail.contoso.com/ecp"

Rebuild Backend Web Applications

# Remove backend applications
Remove-WebApplication -Site "Exchange Back End" -Name owa
Remove-WebApplication -Site "Exchange Back End" -Name ecp

# Recreate OWA backend
New-WebApplication -Site "Exchange Back End" -Name owa `
-PhysicalPath "C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess\owa" `
-ApplicationPool MSExchangeOWAAppPool

# Recreate ECP backend
New-WebApplication -Site "Exchange Back End" -Name ecp `
-PhysicalPath "C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess\ecp" `
-ApplicationPool MSExchangeECPAppPool

Configure Backend Authentication

For OWA:

Set-OwaVirtualDirectory -Identity "server\owa (Exchange Back End)" `
-WindowsAuthentication $True `
-BasicAuthentication $False `
-FormsAuthentication $False

# Restart IIS
iisreset /noforce

For ECP:

# Start PowerShell
Add-PSSnapin *exchange*

Set-EcpVirtualDirectory -Identity "server\ecp (Exchange Back End)" `
-WindowsAuthentication $True `
-FormsAuthentication $False

# Restart IIS
iisreset /noforce

Exchange Management Console Issues

EMC Cannot Open Properly

  1. Close all Exchange Management Console instances
  2. Delete registry key:
    HKCU\Software\Microsoft\ExchangeServer\v14\AdminTools\NodeStructureSettings
  3. Reopen Exchange Management Console

Transport & Anti-Spam

Install Anti-Spam Agents

& $env:ExchangeInstallPath\Scripts\Install-AntiSpamAgents.ps1
Restart-Service MSExchangeTransport

Configure Internal SMTP Servers

# Add internal SMTP servers
Set-TransportConfig -InternalSMTPServers @{Add="10.0.1.10","10.0.1.11"}

# Verify
Get-TransportConfig | Format-List InternalSMTPServers

Check Transport Agents

Get-TransportAgent

Get-ContentFilterConfig | Format-Table Name, Enabled
Get-SenderFilterConfig | Format-Table Name, Enabled
Get-SenderIDConfig | Format-Table Name, Enabled
Get-SenderReputationConfig | Format-Table Name, Enabled

Configure Content Filter

# Block blank senders
Set-SenderFilterConfig -BlankSenderBlockingEnabled $true

# Bypass specific senders
Set-ContentFilterConfig -BypassedSenders itsys@contoso.com,admin@contoso.com

# Add trusted domains to all mailboxes
Get-Mailbox -RecipientTypeDetails UserMailbox |
Set-MailboxJunkEmailConfiguration `
-TrustedSendersAndDomains @{Add="contoso.com","partner.com"}

# Disable content filter
Set-ContentFilterConfig -Enabled $False

Uninstall Anti-Spam Agents

Uninstall-TransportAgent -Identity "Content Filter Agent"
Uninstall-TransportAgent -Identity "Sender Id Agent"
Uninstall-TransportAgent -Identity "Protocol Analysis Agent"

Disable Anti-Malware Scanning

# Check current status
Get-TransportAgent "Malware Agent"

# Disable malware scanning
& $env:ExchangeInstallPath\Scripts\Disable-AntimalwareScanning.ps1

# Restart transport service
Restart-Service MSExchangeTransport

# Verify
Get-TransportAgent "Malware Agent"

Uninstall Anti-Spam Agents Completely

# Navigate to scripts folder
cd "$env:ExchangeInstallPath\Scripts"

# Run uninstall script
.\Uninstall-AntispamAgents.ps1

# Restart transport service
Restart-Service MSExchangeTransport

Organization Config

Meeting Request Sender Display

Configure the sender address for meeting requests and system messages:

# Check current setting
Get-OrganizationConfig | Format-List MicrosoftExchangeRecipientPrimarySmtpAddress

# Disable email address policy
Set-OrganizationConfig -MicrosoftExchangeRecipientEmailAddressPolicyEnabled $False

# Set custom address
Set-OrganizationConfig -MicrosoftExchangeRecipientPrimarySmtpAddress admin@contoso.com

# Check postmaster address
Get-TransportService | Format-List Identity, ExternalPostMasterAddress

# Set postmaster address
Set-TransportConfig -ExternalPostMasterAddress postmaster@contoso.com

Note: If MicrosoftExchangeRecipientEmailAddressPolicyEnabled is set to $false, you must manually add new email addresses to the Microsoft Exchange recipient when email address policies are added or modified.

Message Tracking

Track Messages by Recipient and Time

Get-MessageTrackingLog -ResultSize Unlimited `
-Start "3/4/2023 00:00AM" `
-End "3/5/2023 23:59PM" `
-Recipients effie.chen@contoso.com > C:\effielog.txt

IIS Log Cleanup

Clear IIS logs to free up disk space (command not shown in original document - add your preferred method).