Auto reply rules through powershell
Dear all, First of all, I am a newbe. The case is that we have a mailbox (helpdesk@company.com) that is shared by several persons. Each of these persons have their own adderess as well (firstname.lastname@company.com). What I am strugguling to do is an autoreply (Out of office) for ALL mails to helpdesk@company.com. That is, whenever someone sends a mail to helpdesk@company.com it is supposed to reply "We'll com back to you...". Ok, so the problem is that autoreply does this for the first mail. When the same user asks for help again, (s)he will not get a reply at all. This is, I believe, to preven mail-loops. Solutions I've found is to configure an Outlook client to do this. In our case, impossible as the user is not "helpdesk" but "firstname.lastname". I've tried a variety of logical rules here, none of them work. So, another solution is to disable and re-enable autoreply. Then the list of already replied recepients is removed. This would work, but I cannot get the powershell script right. It looks like this right now: --- Script start --- PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxAutoReplyConfiguration helpdesk@company.com AutoReplyState Disabled ExternalMessage $null InternalMessage $null; . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxAutoReplyConfiguration helpdesk@company.com -AutoReplyState Enabled -ExternalMessage "whatever autoreply" -InternalMessage "internal autoreply" " --- Script end --- Any help, suggestion or anything else appreciated. Br, Mats
October 25th, 2012 4:16pm

You need to be careful with that. A blind auto reply can start a mail loop.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
October 25th, 2012 4:38pm

As far as I can see, you are missing -identity Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com AutoReplyState Disabled Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com -AutoReplyState Enabled -ExternalMessage "whatever autoreply" -InternalMessage "internal autoreply" Thank you. Please Vote As Helpful and/or Mark As Answer if this post helped you.
October 25th, 2012 4:41pm

Sorry for being inprecise, my intensions are to make this script run, say, twice a day. Hence, the "mail loop" is restricted to four mails of text per day, which I believe is acceptable and cannot be called a loop anymore. - Mats
Free Windows Admin Tool Kit Click here and download it now
October 26th, 2012 12:58am

I'll try that out, though I believe this is not the solution. My commands (without identity) worked fine as such in the Echange management console. However, I'll come back to that once I've tried it out. Other suggestions...
October 26th, 2012 12:59am

Ok, so this is what I've learned after serious testing: First of all, the whole command MUST be on one line, either command prompt or powershell considers <line change> with some semantical meaning. Second, Poweshell executes <"> and <$> with a semantics -> exchange management console use "OOO message" and mixes this up. Hence, use <'> instead of <"> Third, there is something that still is strange. I have two sets of commands, one switching the autoreply off and the other putting it back on. The probelm appears to be with the one disabling autoreply and ONLY when run in command prompt, i.e. I save these as *.cmd. Is there any other way??? If I paste these to powershell, everything works like charm. All the separate commands work like charm in exchange management console. A valid one-line command would be: ---- start PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com AutoReplyState Disabled ExternalMessage '$null' InternalMessage '$null'; Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com -AutoReplyState Enabled -ExternalMessage 'whatever' -InternalMessage 'whatever';" --- end The same thing in two pieces: --- start piece 1 switching off PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com AutoReplyState Disabled ExternalMessage '$null' InternalMessage '$null'" --- end piece 1 switching off --- start piece 2 switching on PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com -AutoReplyState Enabled -ExternalMessage 'whatever' -InternalMessage 'whatever'" --- end piece 2 switching on And as said, the problem is with disabling. I want to add that my intension are to schedule this command promt scripts (these disable.cmd and enable.cmd) and then run them once or twice a day. Any help highly appreciated. - Mats
Free Windows Admin Tool Kit Click here and download it now
October 27th, 2012 5:15pm

Here is not a solution, but a workaround for my specific problem. Hope someone else can make use of this as well. So the workaround this time was to make a scheduled task, add as the program <powershell.exe> and as arguments the command. In my case, for disabling: -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com AutoReplyState Disabled ExternalMessage $null InternalMessage $null" and for enabling: -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxAutoReplyConfiguration -Identity helpdesk@company.com -AutoReplyState Enabled -ExternalMessage 'Message' -InternalMessage 'Message'" The drawback is that the reply message lack structure, i.e. everything on one line. So, for me case closed. Hope someone else does not need to take the "hard" path. - Mats
October 27th, 2012 6:02pm

Hi For the Script issue, How about asking on Script Forum. At there, you may find some more Technical support. http://social.technet.microsoft.com/Forums/en/ITCG/threads Cheers Zi Feng TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
October 28th, 2012 11:47pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics