jblackburnHWGA Posted March 3, 2023 Posted March 3, 2023 I don't think this is possible but is there a way to set all staff say to have an out of office reply with a set bit of text between say 5pm - 5am each day? Lead DSL is asking, she wants to push helpful information for students like child line etc after hours if they e-mail a teacher. I've told her no but if you can, someone on here probably knows how
andy_b Posted March 3, 2023 Posted March 3, 2023 Would probably need to schedule a powershell script to run everyday to set Out of office from a CSV list of people?
jblackburnHWGA Posted March 3, 2023 Author Posted March 3, 2023 sounds complicated lol i think its a good idea but i don't think its achievable
IRL Posted March 3, 2023 Posted March 3, 2023 We had this exact same thing. In the end staff just put 'My working hours are...' in the footer of their emails. 1
bknaggs Posted March 3, 2023 Posted March 3, 2023 It looks like it can be done using Powershell https://learn.microsoft.com/en-us/powershell/module/exchange/set-mailboxautoreplyconfiguration?view=exchange-ps
k-strider Posted March 3, 2023 Posted March 3, 2023 if you automate it with powershell everyday would it not overwrite any out off office the user setup - probably wouldnt be a problem 99% of the time.
andy_b Posted March 3, 2023 Posted March 3, 2023 if you automate it with powershell everyday would it not overwrite any out off office the user setup - probably wouldnt be a problem 99% of the time. I think it is one of those things that seems easy to do and a good thing to do, but the reality is somewhat different.
elsiegee40 Posted March 3, 2023 Posted March 3, 2023 We had this exact same thing. In the end staff just put 'My working hours are...' in the footer of their emails. This seems the most practical solution!
ThomL Posted March 3, 2023 Posted March 3, 2023 (edited) This seems doable - the following needs the beginning tweaked to load creds from file (that you save ahead of time [should be a one-time thing]). But it should work - setup an Office 365 group, make the people you want to receive the automated out of office message members, put the group name in the script and the message you want sent, then schedule to run each day from a server on-site: # Connect to Exchange Online $UserCredential = Get-Credential # Prompt for creds Connect-ExchangeOnline -Credential $UserCredential # Connect to Exchange online # Set variables $GroupName = "365TestGroup" # Office 365 Group Name $Members = Get-UnifiedGroupLinks -Identity $GroupName -LinkType Members # Get member of group $OOFStartTime = (Get-Date).Date.AddHours(17) # Set Start time to today at 17:00 PM hours $OOFFinishTime = (Get-Date).Date.AddDays(1).AddHours(5) # Set Finish time to tomorrow at 05:00 AM $OOFMessage = "This is a test - I think you could use HTML here...." # OOF Message to be sent # Loop through each member of the group and set OOF (if OOF not already set) foreach ($Member in $Members) { $OOFStatus = Get-MailboxAutoReplyConfiguration -Identity $Member.PrimarySmtpAddress # Get current OOF settings if ($OOFStatus.AutoReplyState -eq "Scheduled") { # OOF is already set... Write-Host "OOF is already set for $Member" -ForegroundColor Yellow # Alert OOF already set } else { # OOF is not set... Set-MailboxAutoReplyConfiguration -Identity $Member.PrimarySmtpAddress -AutoReplyState Scheduled -StartTime $OOFStartTime -EndTime $OOFFinishTime -ExternalMessage $OOFMessage -InternalMessage $OOFMessage # Set OOF Write-Host "OOF is set for $Member" -ForegroundColor Green # Alert OOF has been set } } # Disconnect from Exchange Online Disconnect-ExchangeOnline It skips people that already have an out of office set too. ***EDIT*** Found the code for creds, I haven't tested this part - but this looks how I remember handling credentials from file in PowerShell scripts previously. Save creds to file (should be able to run this just once to create the file):$credential = Get-Credential # Prompt for creds $credential | Export-CliXml -Path 'C:\My\Path\cred.xml' # Save creds to file Then change line 2 of the PowerShell Script from:[color=#222222]$UserCredential = Get-Credential # Prompt for creds[/color]To:$UserCredential = Import-CliXml -Path 'C:\My\Path\cred.xml' # Get creds from file Edited March 3, 2023 by ThomL 2
jblackburnHWGA Posted March 3, 2023 Author Posted March 3, 2023 This seems doable - the following needs the beginning tweaked to load creds from file (that you save ahead of time [should be a one-time thing]). But it should work - setup an Office 365 group, make the people you want to receive the automated out of office message members, put the group name in the script and the message you want sent, then schedule to run each day from a server on-site: # Connect to Exchange Online $UserCredential = Get-Credential # Prompt for creds Connect-ExchangeOnline -Credential $UserCredential # Connect to Exchange online # Set variables $GroupName = "365TestGroup" # Office 365 Group Name $Members = Get-UnifiedGroupLinks -Identity $GroupName -LinkType Members # Get member of group $OOFStartTime = (Get-Date).Date.AddHours(17) # Set Start time to today at 17:00 PM hours $OOFFinishTime = (Get-Date).Date.AddDays(1).AddHours(5) # Set Finish time to tomorrow at 05:00 AM $OOFMessage = "This is a test - I think you could use HTML here...." # OOF Message to be sent # Loop through each member of the group and set OOF (if OOF not already set) foreach ($Member in $Members) { $OOFStatus = Get-MailboxAutoReplyConfiguration -Identity $Member.PrimarySmtpAddress # Get current OOF settings if ($OOFStatus.AutoReplyState -eq "Scheduled") { # OOF is already set... Write-Host "OOF is already set for $Member" -ForegroundColor Yellow # Alert OOF already set } else { # OOF is not set... Set-MailboxAutoReplyConfiguration -Identity $Member.PrimarySmtpAddress -AutoReplyState Scheduled -StartTime $OOFStartTime -EndTime $OOFFinishTime -ExternalMessage $OOFMessage -InternalMessage $OOFMessage # Set OOF Write-Host "OOF is set for $Member" -ForegroundColor Green # Alert OOF has been set } } # Disconnect from Exchange Online Disconnect-ExchangeOnline It skips people that already have an out of office set too. ***EDIT*** Found the code for creds, I haven't tested this part - but this looks how I remember handling credentials from file in PowerShell scripts previously. Save creds to file (should be able to run this just once to create the file):$credential = Get-Credential # Prompt for creds $credential | Export-CliXml -Path 'C:\My\Path\cred.xml' # Save creds to file Then change line 2 of the PowerShell Script from:[color=#222222]$UserCredential = Get-Credential # Prompt for creds[/color]To:$UserCredential = Import-CliXml -Path 'C:\My\Path\cred.xml' # Get creds from file Fantastic! i'll give it a good test but from a read through it looks like it will do what i'm after
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now