Set automatic reply on mailbox using Powershell set-mailboxautoreplyconfiguration cmdlet

Hello,

I’m trying to set and out of office reply on a mailbox using the following powershell script in UiPath:

import module exchange online
try {
Import-Module ExchangeOnlineManagement
$Message = “ExchangeOnline module imported successfully.”
Write-Host $Message
} catch {
$ErrorMessage = “Error importing ExchangeOnline module: $($_.Exception.Message)”
Add-Content $LogPath “$logtime : $ErrorMessage”
}

try {
Connect-ExchangeOnline -AppId “myappid” -CertificateThumbprint “thumbprint” -Organization “example.onmicrosoft.com” -ErrorAction Stop
$Message = “Connect to Exchange Online”
Write-Host $Message
} catch {
$ErrorMessage = “Error: $($_.Exception.Message)”
Write-Host $ErrorMessage
}

Set-MailboxAutoReplyConfiguration -Identity “test@email.com” -AutoReplyState Scheduled -StartTime “2023-07-19” -EndTime “2023-07-20” -InternalMessage “I’m currently out of the office. Please expect a delay in my response.” -ExternalMessage “I’m currently out of the office”

I’m using the same method from This article in step 3 (read script to text file and invoke powershell) but get this error:

Error: A parameter cannot be found that matches parameter name ‘AppId’.

I have tested and confirmed that if I run the above script directly in powershell on my machine it will work and enable the automatic reply but so far no luck in UiPath.

Any help would be appreciated!
Thanks