In one of my scripts, I have a command to set the Out of Office message for a user. The command works when I type it in to an Exchange Management Shell window, but not within a script run from the EMS. I am using Exchange 2013.
Set-MailboxAutoReplyConfiguration $username -AutoReplyState enabled -ExternalAudience all -InternalMessage “$ooo” -ExternalMessage “$ooo”
It works in the shell. When I run it in the script I get this error:
Set-MailboxAutoReplyConfiguration : Cannot find information about the local server (servername.company.com) in Active Directory.
This may be related to a change in the server name.
Why is this happening?