[Scenario]
An user asks to set up mailbox automatic reply as below
mailbox: USOrders@rotork.com
start time: 4/6/2023 17:00:00
end time: 4/9/2023 12:20:00
message: Rotork USA offices will be closed Friday, 4/7/2023 for national holiday and will re-open the morning of Monday, 4/10/2023.
[Objectives]
Set mailbox automatic reply for USOrders@rotork.com as requested.
[Steps]
For starter, connect to ExchangeOnline.
#Connecting ExchangeOnline
Connect-ExchangeOnline
Before setting mailbox autoreply, it should be checked whether the mailbox exists. Let's manipulate "Get-MailBox" command
Get-Mailbox (ExchangePowerShell) | Microsoft Learn
Get-Mailbox (ExchangePowerShell)
When you use the Get-Mailbox cmdlet in on-premises Exchange environments to view the quota settings for a mailbox, you first need to check the value of the UseDatabaseQuotaDefaults property. The value True means per-mailbox quota settings are ignored, and
learn.microsoft.com
Get-mailbox -identity USOrders@rotork.com
Name Alias Database ProhibitSendQuota ExternalDirectoryObjectId
---- ----- -------- ----------------- -------------------------
US - Contracts US.Contracts EURPR04DG089-db108 49.5 GB (53,150,2... f5a4592c-adcb-42f4-bbbf-54cee7b05f14
After ensuring the mailbox address is correct, set mailbox auto reply by using "Set-MailboxAutoReplyConfiguration"
Set-MailboxAutoReplyConfiguration (ExchangePowerShell) | Microsoft Learn
Set-MailboxAutoReplyConfiguration (ExchangePowerShell)
You can disable Automatic Replies for a specified mailbox or organization. You need to be assigned permissions before you can run this cmdlet. Although this topic lists all parameters for the cmdlet, you may not have access to some parameters if they're no
learn.microsoft.com
Set-MailboxAutoReplyConfiguration -Identity $mb -AutoReplyState Scheduled -StartTime $sTime -EndTime $eTime -InternalMessage $iMessage -ExternalMessage $eMessage
[Parameter Explanation - Set-MailboxAutoReplyConfiguration]
- Identity: specifying mailbox address
- AutoreplyState:
- Enabled: Automatic Replies are sent for the mailbox.
- Disabled: Automatic Replies aren't sent for the mailbox. This is the default value.
- Scheduled: Automatic Replies are sent for the mailbox during the time period that's specified by the StartTime and EndTime parameters.
- StartTime: Autoreply start time in the format of MM/dd/yyyy hh:mm:ss
- EndTime: Autoreply end time in the format of MM/dd/yyyy hh:mm:ss
- InternalMessage: Autoreply messages for internal users of the domain
- ExternalMessage: Autoreply messages for external users of the domain
After setting up the autoreply message, let's get the autoreply status to check whether it is set correctly by using "Get-MailboxAutoReplyConfiguration"
Get-MailboxAutoReplyConfiguration (ExchangePowerShell) | Microsoft Learn
Get-MailboxAutoReplyConfiguration (ExchangePowerShell)
You can use the Get-MailboxAutoReplyConfiguration cmdlet to retrieve all the mailboxes enabled for Automatic Replies. When run, the cmdlet returns Automatic Replies settings for the specified mailbox that include the following: Mailbox identity value Wheth
learn.microsoft.com
Get-MailboxAutoReplyConfiguration -Identity $mb | select-object AutoReplyState, StartTime, EndTime, InternalMessage, ExternalMessage
To avoid reduntant code writing, I have wrote a function called "setMailboxAutoReply"
function setMailboxAutoReply{
param(
[string]$mb,
[string]$sTime,
[string]$eTime,
[string]$iMessage,
[string]$eMessage
)
#Checking whether mailbox exists
try{
Get-Mailbox -Identity $mb -ErrorAction Stop
}
catch{
Write-Host "Cannot find mailbox" $mb":"
Write-Host $_
return
}
#Setting mailbox auto reply
Set-MailboxAutoReplyConfiguration -Identity $mb -AutoReplyState Scheduled -StartTime $sTime -EndTime $eTime -InternalMessage $iMessage -ExternalMessage $eMessage
#Checking mailbox auto reply status
Get-MailBoxAutoReplyConfiguration -Identity $mb | select-object AutoReplyState, StartTime, EndTime, InternalMessage, ExternalMessage
}
Working well.
setMailboxAutoReply "USOrders@rotork.com" "4/6/2023 17:00:00" "4/9/2023 12:20:00" "Rotork USA offices will be closed Friday, 4/7/2023 for national holiday and will re-open the morning of Monday, 4/10/2023." "Rotork USA offices will be closed Friday, 4/7/2023 for national holiday and will re-open the morning of Monday, 4/10/2023."
Name Alias Database ProhibitSendQuota ExternalDirectoryObjectId
---- ----- -------- ----------------- -------------------------
US - Contracts US.Contracts EURPR04DG089-db108 49.5 GB (53,150,2... f5a4592c-adcb-42f4-bbbf-54cee7b05f14
AutoReplyState : Scheduled
StartTime : 2023-04-06 오후 5:00:00
EndTime : 2023-04-09 오후 12:20:00
InternalMessage : <html>
<body>
Rotork USA offices will be closed Friday, 4/7/2023 for national holiday and will re-open the morning of Monday, 4/10/2023.
</body>
</html>
ExternalMessage : <html>
<body>
Rotork USA offices will be closed Friday, 4/7/2023 for national holiday and will re-open the morning of Monday, 4/10/2023.
</body>
</html>
'ICT' 카테고리의 다른 글
[PowerShell]Resetting User Password (0) | 2023.04.12 |
---|---|
[PowerShell]Creating Room Mailbox As Resource (0) | 2023.04.07 |
[PowerShell]Creating Email Distribution Group (0) | 2023.04.04 |
[PowerShell]7. Functions (0) | 2023.04.03 |
[PowerShell]6. Loops (0) | 2023.03.30 |
댓글