How to Fix Exchange Online PowerShell Errors Under the SYSTEM Account
Question details
Users need to resolve an issue where certificate-based Exchange Online PowerShell connections succeed for interactive users but fail when executed under the NT AUTHORITY\SYSTEM account.

- Product
- Exchange Online PowerShell
- Device & OS
- Windows
- Scenario
- Running automated scripts or scheduled tasks that connect to Exchange Online using the local SYSTEM account.
- Observed behavior
- The PowerShell script successfully connects to Exchange Online when run interactively by an administrator, but encounters connection or authentication errors when executed as NT AUTHORITY\SYSTEM.
Ensure you have administrator access to the Windows server running the scripts and verify that you possess the correct certificate thumbprint used for Exchange Online app-only authentication.
Configure Certificate, Module, and Proxy for the SYSTEM Account
Align the system-level environment with the user-level environment by ensuring the certificate, proxy settings, and PowerShell modules are accessible to the SYSTEM account.
Because NT AUTHORITY\SYSTEM has its own isolated profile, it does not inherit the proxy settings, user-level certificate store, or user-specific module paths of the logged-in administrator. Fixing this requires manually configuring these elements for the system context.
Import the authentication certificate into the 'Local Machine\Personal' certificate store rather than the 'Current User' store. Ensure the SYSTEM account has read permissions for the private key via the Certificate Manager (certlm.msc).
Open PowerShell as Administrator and run `Get-Module ExchangeOnlineManagement -ListAvailable` to confirm the module is installed in an 'AllUsers' path (e.g., `C:\Program Files\WindowsPowerShell\Modules`).
If your environment uses a proxy, configure the WinHTTP proxy settings for the SYSTEM account using the command prompt: `netsh winhttp set proxy <proxyserver>:<port>`.
Use a tool like PsExec (`psexec -i -s powershell.exe`) to launch PowerShell as NT AUTHORITY\SYSTEM, then manually run your Exchange Online connection script to verify it authenticates successfully.

A Lightweight, Free Alternative for Your Daily Office Tasks
While you troubleshoot advanced Microsoft 365 administrator issues like Exchange PowerShell connections, ensure your end-users have a reliable, lightweight suite for everyday document management. WPS Office is a high-performance alternative to Microsoft Office that is fully compatible with standard document formats.
- 1. Download the installer: Visit the official WPS Office website to download the free installation package.
- 2. Install the software: Run the downloaded executable file and follow the on-screen instructions to complete the installation.
- 3. Start using WPS Office: Launch the application and immediately start creating, editing, and managing your documents.

Frequently Asked Questions
Why does my PowerShell script work for my admin user but fail in Task Scheduler?
Task Scheduler often runs scripts as the SYSTEM account or a service account, which do not share the same certificate store, proxy settings, or environmental variables as your logged-in administrator account.
How do I give the SYSTEM account access to my certificate's private key?
Open the Certificate Manager for the Local Computer (certlm.msc), find your certificate in the Personal store, right-click it, select All Tasks > Manage Private Keys, and grant 'Read' permission to the 'SYSTEM' user.
Can I use Connect-ExchangeOnline with a username and password under the SYSTEM account?
Basic authentication is deprecated for Exchange Online. For automated background tasks running as SYSTEM, you must use app-only authentication (CBA) via an Azure AD App Registration and a certificate.
How can I view the actual PowerShell error that occurs as SYSTEM?
You can capture the error by wrapping your connection command in a Try-Catch block and using Out-File to log the `$_` exception message to a local text file, or run PowerShell interactively as SYSTEM using PsExec for real-time debugging.




