Exchange Health Manager has restarted a server even though a Global Monitor Override was in place.

Scenario:  You have a GlobalMonitoringOverride configured to prevent the reboot of an Exchange Server for a specific Exchange Health Monitor responder, but MSExchangeHMWo still rebooted the server anyways.   In our example below, we have an existing global monitor override that should prevent reboots for the responder “ActiveDirectoryConnectivityConfigDCServerReboot”. 
Cause:   The globalmonitoringoverride had an expiration date for 60 days after it was set.
Resolution: Remove the existing GlobalMonitoringOverride and replace it.
step 1 – View the current globalmonitoringoverride

get-globalmonitoringoverride
  
step 2 – View the log file associated with the reboot for the Repsonder

(Get-WinEvent -LogName Microsoft-Exchange-ActiveMonitoring/responderdefinition | % {[XML]$_.toXml()}).event.userData.eventXml | ?{$_.Name -like “ActiveDirectoryConnectivityConfigDCServerReboot”} | ft name,enabled
 step 3 (only if you have override setup already)

remove-GlobalMonitoringOverride -Identity ExchangeActiveDirectoryConnectivityConfigDCServerReboot -ItemType Responder -PropertyName Enabled  
   
Step 4  – Apply Either of the options below.
Apply based on duration of 60 days
Add-GlobalMonitoringOverride -Identity ExchangeActiveDirectoryConnectivityConfigDCServerReboot  -ItemType Responder -PropertyName Enabled -PropertyValue 0 -Duration 60.00:00:00
Apply based on Exchange version

Add-GlobalMonitoringOverride -Identity ADActiveDirectoryConnectivityConfigDCServerReboot -ItemType Responder -PropertyName Enabled -PropertyValue 0 –ApplyVersion “15.00.0847.32”
  
Step 5 – Restart the “Microsoft Exchange Health Manager” service

Working with Mailbox Rules in Powershell

Working with Mailbox Rules in Powershell
1. Get all forwarding rules in an organization:
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.ForwardTo} | fl MailboxOwnerID,Name,ForwardTo >> C:AllForwardRules.txt }
2. To get inbox rules for a mailbox:
Get-Inboxrule. You can also do get-inboxrule | Fl to see details of the rule
3. Type Get-command *inboxrule* to see list of commands for inbox rules
4. To remove a rule, type get-inboxrule | remove-inboxrule
5. Create inbox rule called Junk for a set of users in a particular OU called Test. this will rule will move messages with subject ‘spam” to a folder called
Junk email
$mailboxes = Get-mailbox -organizationalUnit test
$mailboxes | % { }
$mailboxes | % { New-inboxrule -Name Junk -mailbox $_.alias -subjectcontainswords “[spam]” -movetofolder “$($_.alias):Junk Email” }

Script for converting Bounce Back LegacyExchangeDN to the X500 format

Scenario:  You have to convert the LegacyExchangeDN that is being provided to you in bounce back emails with the special charter formatting into an X500 address.  This may need to be done if mailboxes are disabled and recreated as new mailboxes or when performing migrations.

From the bounce back message, copy and paste the address into the $Addr variable below and then execute this script:

#Edit the $Addr Variable
$Addr = "IMCEAEX-_O=TEST+20ENTERPRISE+20EXCHANGE_OU=EXCHANGE+20ADMINISTRATIVE+20GROUP+20+28FYDIBOHF23SPDLT+29_CN=RECIPIENTS_CN=4bd8a35a90e2441a4587635898d62f9f-s@domain.com"

#Run the following against the variable
$Addr = $Addr -replace "IMCEAEX-",""
$Addr = $Addr -replace "@.*$",""
$Addr = $Addr -replace "_","/"
$Addr = $Addr -replace "+20"," "
$Addr = $Addr -replace "+28","("
$Addr = $Addr -replace "+29",")"
$Addr = $Addr -replace "+2C",","
$Addr = $Addr -replace "+5F","_"
$Addr = $Addr -replace "+40","@"
$Addr = $Addr -replace "+2E","."
$Addr= “X500:$Addr”
Write-Host $Addr

#Add the Email Address to the Mailbox
set-mailbox usera -emailaddresses @{Add=$Addr}

Script to see ActiveSync Device Statistics from a filtered Mailbox List.

Scenario: Customer wants to a list of all users with active mobile devices so they can see lastsuccesssync, devicepolicyapplied, etc of the devices
$Mailboxes = Get-CasMailbox -Filter {HasActiveSyncDevicePartnership -eq $True -and -not displayname -like “CAS_{*” -and -not displayname -like “Extest_*”} –ResultSize Unlimited
$Devices = $Mailboxes | %{Get-ActiveSyncDeviceStatistics –Mailbox $_.Identity}

$Devices | Export-CSV -Path C:scriptstest.csv

Reseed Exchange Database Copy via Exchange Powershell

Below are the steps to reseed a Database Copy via Exchange PowerShell. The database copy that needs to be reseeded is DB01 on the mailbox Server MBX04.  We will use the server MBX03 that has a healthy database copy to perform the reseed.

1. Check to see if the problematic database copy has a failed and/or suspended status:
          get-mailboxdatabasecopystatus DB01

2. If the database copy is already failed and/or suspended, you can skip this step. If the database copy you wish to reseed has a status of healthy, you must suspend the database copy:
          suspend-mailboxdatabasecopy  DB01MBX04

3. To reseed the mailbox database copy, run the following:
          update-mailboxdatabasecopy DB01MBX04 -sourceserver MBX03 -DeleteExistingFiles





Configure Automatic Reply for a mailbox via Powershell

Setting Automatic Reply, or Out of Office Message, via Exchange Powershell. Below shows you how to schedule an Automatic Reply, enable it, and disable it.

Enable it (It stays on until its disabled):
Set-MailboxAutoReplyConfiguration -Identity batman -AutoReplyState Enabled -InternalMessage “Internal auto-reply message.” -ExternalMessage “External auto-reply message.”

Scheduled (must use start and end time parameters) :
Set-MailboxAutoReplyConfiguration -Identity batman -AutoReplyState Scheduled -StartTime “7/10/2012 08:00:00” -EndTime “7/15/2012 17:00:00” -InternalMessage “Internal auto-reply message” -ExternalMessage “External auto-reply message”

Disable it:

Set-MailboxAutoReplyConfiguration -Identity batman -AutoReplyState Disabled

Perform IIS reset on multiple servers at once.

Perform IIS reset on multiple servers at once. Displays status after reset. 
#Specify servers in an array variable, Make sure you change the where statement.
[array]$servers = get-exchangeserver | where {$_.identity -like “esg*” -and $_.AdminDisplayVersion -match “version 15.0*”}

#Step through each server in the array and perform an IISRESET
#Also show IIS service status after the reset has completed

foreach ($server in $servers)
{
    Write-Host “Restarting IIS on server $server…”
    IISRESET $server
    Write-Host “IIS status for server $server”
    IISRESET $server /status
}
Write-Host “IIS has been restarted on all servers”
OR

#Specify servers in an array variable
[array]$servers = “Server1″,”Server2″,”Server3″,”Server4”
#Step through each server in the array and perform an IISRESET
#Also show IIS service status after the reset has completed
foreach ($server in $servers)
{
    Write-Host “Restarting IIS on server $server…”
    IISRESET $server
    Write-Host “IIS status for server $server”
    IISRESET $server /status
}
Write-Host IIS has been restarted on all servers