Exchange Connection Problems

How to Fix Exchange Online PowerShell Errors Under the SYSTEM Account

Muhammad TalhaMuhammad Talha Nov 2, 2026 869 views

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.

How to Fix Exchange Online PowerShell Errors Under the 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.
Before you start

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.

Solution 1Recommended

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.

1
Install the Certificate in the Local Machine Store

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).

2
Check ExchangeOnlineManagement Module Availability

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`).

3
Configure System-Level Proxy Settings

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>`.

4
Test Under SYSTEM Context

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.

Configure Certificate, Module, and Proxy for the SYSTEM Account
Check Microsoft 365 Endpoints: Ensure the system account's outbound traffic is not blocked by a local firewall and can reach all required Microsoft 365 and Exchange Online endpoints.
Free Microsoft Office alternative

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. 1. Download the installer: Visit the official WPS Office website to download the free installation package.
  2. 2. Install the software: Run the downloaded executable file and follow the on-screen instructions to complete the installation.
  3. 3. Start using WPS Office: Launch the application and immediately start creating, editing, and managing your documents.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Lightweight installation that uses significantly fewer system resources.Familiar user interface requiring zero learning curve for users migrating from Microsoft Office.Built-in PDF editing capabilities without requiring additional software.
microsoft office alternative - wps office

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.