Setup an Out Of Office text reply for disabled AD account

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
bareedaa
Posts: 5
Last visit: Sun Jun 09, 2013 10:24 am

Setup an Out Of Office text reply for disabled AD account

Post by bareedaa »

I would like to Setup auto an Out Of Office text reply for disabled active directory account(whenever the employee is terminated)using powershell. I need to have auto reply whenever the user account/mailbox user with in active directory is disabled.
I have the following script to automate but it is not working. Please help:

foreach($_ in (Get-ADUser -SearchBase "$_.recipienttypedetails -eq "usermailbox" -Filter {Enabled -eq $false})){
Set-MailboxAutoReplyConfiguration -Identity $_.DistinguishedName -AutoReplyState Enabled
-ExternalAudience All -InternalMessage "Your message to internal users" -ExternalMessage "Your message to external users" }
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Setup an Out Of Office text reply for disabled AD accoun

Post by jvierra »

You seem to be a little lost with the use of PowerShell syntax.

This might help a bit:
PowerShell Code
Double-click the code block to select all.
Get-ADUser  -Filter {Enabled -eq $false}  -Searchbase 'OU=MyOU,Dc-domain,DC=com' |
     ForEach{
          Set-MailboxAutoReplyConfiguration -Identity $_ `
                                            -AutoReplyState Enabled `
                                            -ExternalAudience All `
                                            -InternalMessage 'Your message to internal users' `
                                            -ExternalMessage 'Your message to external users'
     }
This topic is 10 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked