Forum Discussion
coxygt
Feb 05, 2026Brass Contributor
Running Un-attended Scripts via Task Scheduler
I am trying to get some of my PS Scripts that are required regularly to run un-attended on a server using Task Scheduler. I am aware that App Registrations seem to be the recommended way, but I am s...
Charlie34000
Mar 22, 2026MCT
Hi,
Bart is correct — unattended Exchange Online automation cannot use Delegated permissions. If you want the minimum required permissions for Get-MessageTraceV2 in a scheduled task, here is the short version:
✔️ 1. Use an App Registration with Application permissions
The minimum effective permission is:
- Exchange.ManageAsApp
This is the lowest level that allows Message Trace in an unattended context.
✔️ 2. Authenticate using Client Credentials
Example:
Connect-ExchangeOnline -AppId $AppId -CertificateThumbprint $Thumb -Organization $Tenant
✔️ 3. Task Scheduler does not provide identity
The scheduled task can run under any local/domain account — the App Registration handles authentication, not the task’s user.
✔️ 4. Sending the CSV or Teams notification
Once connected with App permissions, you can:
- send the CSV via Graph (Send-MgUserMail)
- or post to Teams via Graph chat message
Both work fine in unattended mode.