The script marks a user if their Exchange mailbox is configured to send automatic replies (OOF messages). To mark users, the script sets a certain attribute of the user account to a certain predefined value.
Parameters:
- $statusOOFAttribute - specifies the LDAP display name of the attribute that is modified in order to mark users;
- $oOFEnabledText - specifies the value that the attribute is set to in order to mark a user.
PowerShell
$statusOOFAttribute = "extensionAttribute1" # TODO: modify me
$oOFEnabledText = "OOF enabled" # TODO: modify me
# Get mailbox parameters
try
{
$mailboxParams = $Context.TargetObject.GetMailParameters()
}
catch
{
return
}
# Check OOF configuration
$automaticReplies = $mailboxParams.AutoReplyConfiguration
$automaticRepliesStatus = $automaticReplies.AutoReplyState
switch ($automaticRepliesStatus)
{
"ADM_EXCHANGE_OOFSTATETYPE_ENABLED"
{
$status = $oOFEnabledText
}
"ADM_EXCHANGE_OOFSTATETYPE_SCHEDULED"
{
# OOF message is scheduled
# Check whether OOF is enabled right now
# Get current date
$currentDate = Get-Date
# Check OOF schedule
$startDate = $automaticReplies.StartTime
$endDate = $automaticReplies.EndTime
if (($startDate -lt $currentDate) -and ($endDate -gt $currentDate))
{
$status = $oOFEnabledText
}
}
default
{
$status = $NULL
}
}
# Update user
$Context.TargetObject.Put($statusOOFAttribute, $status)
$Context.TargetObject.SetInfo()