Debugging a "Out of office" script

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! :smiley: Have a nice day :slight_smile:
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