Script repository
The script checks whether the automatic replies (OOF messages) feature is enabled. To execute the script, use the If PowerShell script returns true condition in a business rule, custom command or scheduled task configured for the required object type. The script returns $true if the automatic replies (OOF messages) feature is enabled.
# Get mailbox parameters.
$Context.ConditionIsMet = $False
try
{
$mailboxParams = $Context.TargetObject.GetMailParameters()
}
catch
{
return
}
# Check OOF configuration.
$automaticReplies = $mailboxParams.AutoReplyConfiguration
$automaticRepliesStatus = $automaticReplies.AutoReplyState
switch ($automaticRepliesStatus)
{
"ADM_EXCHANGE_OOFSTATETYPE_DISABLED"
{
return
}
"ADM_EXCHANGE_OOFSTATETYPE_ENABLED"
{
$Context.ConditionIsMet = $True
}
"ADM_EXCHANGE_OOFSTATETYPE_SCHEDULED"
{
# OOF message is scheduled
# Check whether OOF is enabled right now
$currentDate = Get-Date
# Check OOF schedule
$startDate = $automaticReplies.StartTime
$endDate = $automaticReplies.EndTime
if (($startDate -lt $currentDate) -and ($endDate -gt $currentDate))
{
$Context.ConditionIsMet = $True
}
}
}
Comments 0
You must be signed in to comment.