Share via

Office 365 Powershell command with condition checking for Automatic Reply

Jax TEE 21 Reputation points
2020-10-29T08:33:31.963+00:00

I had below powershell scripts is working fine. I need further help for below

How to add one more condition check ==> if the user already turn on Automatic reply, skip the action and proceed to next users.

$csv = Import-Csv "C:\drive\EnablingUsers.csv"

Foreach ($line in $csv) {
Set-MailboxAutoReplyConfiguration $line.user –AutoReplyState Scheduled –StartTime $line.startdate –EndTime $line.enddate –ExternalMessage $line.externalmessage –InternalMessage $line.internalmessage
}

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

Rich Matheisen 48,116 Reputation points
2020-10-29T14:24:15.627+00:00

Does this work?

If ( (Get-MailboxAutoReplyConfiguration).AutoReplyState -eq "Disabled"){
    Set-MailboxAutoReplyConfiguration . . . 
}

PowerShell cmdlets are usually orthogonal . . . if there's a "Set-" there's usually a "Get-".

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.