Debugging a "Out of office" script

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 9 months ago.

  • Author
    Posts
  • #5799

    by sponsen at 2013-04-12 04:24:49

    Hi,

    I'm currently working on a little OOO script, and everything works, except the scheduling – the OOO is activated immediately. What have i done wrong here? It should be quite straight forward..

    I know the $starttime is quite extreme/not so user friendly, but i had tried everything, so i had to make sure PS got the date in its preferred format.

    Our organization is currently running Office 365 V14

    # Read for SamAccountName
    $username = Read-Host "Identity"

    # Extract the users full name
    $fullname = Get-ADUser -Identity $username -Property GivenName,Surname | Select-Object -Property @{Name='fullname';Expression={$_.GivenName + " " + $_.Surname}} | Select-Object -ExpandProperty fullname

    # Read for the scheduled start time
    $starttime = Get-Date -Date (Read-Host "Date (dd.mm.yyyy)") -Hour (Read-Host "Hour (hh)") -Minute (Read-Host "Minute (mm)")

    # Define the end time
    $endtime = (Get-Date).AddYears(2)

    # Messages
    $internal = "The internal OOO message - $fullname is on a 2 year permission"
    $external = "The external OOO message - $fullname is on a 2 year permission"

    # The script
    Set-MailboxAutoReplyConfiguration -Identity $username -AutoReplyState Enabled -InternalMessage $internal -ExternalMessage $external -StartTime $starttime -EndTime $endtime

    by happysysadm at 2013-04-12 04:37:15

    Hi Sponsen,

    there is an error in your parameter AutoReplyState: it should be 'Scheduled' and not 'Enabled'. Can you check this?

    Carlo

    by sponsen at 2013-04-12 04:43:42

    Now I feel stupid.... ^^ It works, thank you! 😀 Have a nice day 🙂

    by happysysadm at 2013-04-12 04:53:48

    The advantage of external eye neutrality allows a more objective analysis. Glad I could help. That's what the forum is for.
    Nice day to you.
    Carlo

You must be logged in to reply to this topic.