Up 2 Down 0

Set out-of-office for disabled accounts

# Replace "OU=Disabled Accounts,DC=contoso,DC=com" with the distinguished name of your OU
$ou = "OU=Disabled Accounts,DC=contoso,DC=com"

# Get a list of disabled accounts in the OU
$disabledAccounts = Get-ADUser -Filter {Enabled -eq $False} -SearchBase $ou

# Set the out-of-office message for each disabled account 
foreach ($account in $disabledAccounts) {   Set-MailboxAutoReplyConfiguration -Identity $account.SamAccountName -AutoReplyState Enabled -ExternalMessage "I am currently out of the office and will not be able to respond to your message. I will get back to you as soon as possible." -InternalMessage "I am currently out of the office and will not be able to respond to your message. I will get back to you as soon as possible." }