Auto Reply multiple Users

Sharing a script that I created recently while working on a project where the requirement was to set auto reply for hundereds of users.

We need to notify their future address & also want that sender should know that old address is no longer monitored.

This can be achieved by creating a CSV file with just two columns:

PreviousEmail,FutureEmail

Download & extract the solution from below link(update .ps1)

https://gallery.technet.microsoft.com/scriptcenter/Auto-Reply-multiple-Users-840c2a35

Update Start & End date for OOO reply

$start = “1/3/2017”

$end = “1/3/2018”

Update the message that should be sent:

$ooomessage = @”

Please contact me at my new email address, $femail. Also note my $pemail account is no longer monitored.

“@

Now Just open the Exchange management shell , change directory to script & run the script as

OOO.ps1 .\merger.csv

Note: Script requires Exchnage managemnt Shell & was tested with 2010.

 

<#     
    .NOTES 
    =========================================================================== 
     Created on:       3/29/2017 1:55 PM 
     Created by:       sukhijv 
     Organization:      
     Filename:         OOO.ps1 
    =========================================================================== 
    .DESCRIPTION 
        Setup ooo for Users from CSV File by reading old address & New address 
#> 
########################Functions ################################### 
function Write-Log 
{ 
    [CmdletBinding()] 
    param 
    ( 
        [Parameter(Mandatory = $true)] 
        [array]$Name, 
        [Parameter(Mandatory = $true)] 
        [string]$Ext, 
        [Parameter(Mandatory = $true)] 
        [string]$folder 
    ) 
     
    $log = @() 
    $date1 = get-date -format d 
    $date1 = $date1.ToString().Replace("/""-") 
    $time = get-date -format t 
     
    $time = $time.ToString().Replace(":""-") 
    $time = $time.ToString().Replace(" """) 
     
    foreach ($n in $name) 
    { 
         
        $log += (Get-Location).Path + "\" + $folder + "\" + $n + "_" + $date1 + "_" + $time + "_.$Ext" 
    } 
    return $log 
} 
$log = Write-Log -Name "log1""log2" -Ext log -folder Logs 
Start-Transcript -Path $log[0] 
##########################Import CSv & ADD OOO######################## 
$start = "1/3/2017" 
$end = "1/3/2018" 
$data = Import-Csv $args 
foreach ($i in $data) 
{ 
    $pemail = $i.previousEmail 
    $pemail = $pemail.trim() 
    $femail = $i.futureemail 
    $femail = $femail.trim() 
    $ooomessage = @" 
Please contact me at my new email address, $femail. Also note my $pemail account is no longer monitored. 
"@ 
    Write-Host $ooomessage -ForegroundColor Green 
    if (get-mailbox $pemail -ea silentlycontinue) 
    { 
        Try 
        { 
            Set-MailboxAutoReplyConfiguration -identity $pemail -AutoReplyState Scheduled -StartTime $start -endtime $end -InternalMessage $ooomessage –ExternalMessage $ooomessage -ExternalAudience:All 
            Write-Host "Processing...................... $pemail" -ForegroundColor Green 
        } 
        catch 
        { 
            Write-Host "exception occured Processing $pemail" -ForegroundColor Yellow 
            $_.Exception.Message 
        } 
    } 
    else 
    { 
        Write-Host "$pemail mailbox not found" -ForegroundColor RED 
    } 
} 
Stop-Transcript 
######################################################################
Thanks for reading
Sukhija Vikas

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s