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" }
Setup an Out Of Office text reply for disabled AD account
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.
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.
Re: Setup an Out Of Office text reply for disabled AD accoun
You seem to be a little lost with the use of PowerShell syntax.
This might help a bit:
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' }