When writing scheduled tasks or automation scripts for on-premises Exchange Server (2010, 2013, 2016, 2019, and Exchange Server SE), administrators frequently need to load Exchange cmdlets (Get-Mailbox, Get-ExchangeServer, Set-RemoteMailbox) inside a standard Windows PowerShell console (powershell.exe) without manually clicking the Exchange Management Shell shortcut.
While loading the Exchange PowerShell snap-in via Add-PSSnapin is the fastest way to expose Exchange cmdlets locally, Microsoft also enforces strict serialization and RBAC checks on how Exchange PowerShell sessions are initialized. Furthermore, running Add-PSSnapin on the wrong architecture or without Exchange Management Tools triggers the infamous error:
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.
In this guide, we provide the exact Add-PSSnapin commands for every Exchange Server version, explain how to fix the "No snap-ins have been registered" error, and show the Microsoft-supported Remote PowerShell (New-PSSession) method for production automation.
Exchange PowerShell Snap-In Names by Version
Depending on which version of Exchange Server is installed locally (along with the Exchange Management Tools role), use the corresponding snap-in name in 64-bit Windows PowerShell 5.1:
1. Exchange Server 2013, 2016, 2019, and Exchange Server SE (Subscription Edition)
All modern Exchange architectures use the unified Microsoft.Exchange.Management.PowerShell.SnapIn:
# Load Exchange 2013 / 2016 / 2019 / Exchange Server SE Snap-In
if (-not (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.SnapIn -ErrorAction SilentlyContinue)) {
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
}
# Verify Exchange cmdlets are available
Get-ExchangeServer | Select-Object Name, Edition, AdminDisplayVersion
2. Exchange Server 2010 (Legacy)
# Load Exchange Server 2010 Snap-In
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
3. Exchange Server 2007 (Legacy)
# Load Exchange Server 2007 Snap-In
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Troubleshooting: "Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5"
If you run Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn and receive:
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.
At line:1 char:1
+ Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Excha...werShell.SnapIn:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
Here are the four root causes and how to fix each one immediately:
Cause 1: You Launched 32-bit PowerShell (Windows PowerShell (x86)) or Task Scheduler Ran 32-bit cmd.exe
Exchange Server 2013, 2016, 2019, and Exchange SE register their PowerShell snap-in exclusively in the 64-bit registry hive (HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns). If a third-party monitoring agent or scheduled task launches 32-bit PowerShell (C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe), the snap-in does not exist.
Fix: Verify that your session is 64-bit, and always point scheduled tasks to %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe (or C:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe if triggered by a 32-bit orchestrator):
# Check if current PowerShell process is 64-bit
[Environment]::Is64BitProcess
# Must return: True
# List all registered snap-ins on this machine
Get-PSSnapin -Registered
Cause 2: Exchange Management Tools Are Not Installed on This Machine
Add-PSSnapin only works if the Exchange Management Tools (or an Exchange Server role) are installed locally on the machine running the script.
Fix: If you are running the script from an admin workstation or automation server that does not have Exchange Management Tools installed, use Implicit Remoting (New-PSSession) shown in the next section—no local snap-in or installation is required!
Cause 3: You Are Running PowerShell 7 (pwsh.exe)
PowerShell 7 (.NET Core) completely removed support for legacy PSSnapins (Add-PSSnapin is not recognized or fails).
Fix: From PowerShell 7, connect to on-premises Exchange via New-PSSession -ConfigurationName Microsoft.Exchange, which proxies commands over WSMan cleanly.
Best Practice: Use Remote PowerShell (New-PSSession) or RemoteExchange.ps1
Microsoft officially advises against loading Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn directly in production scripts (except on dedicated "Recipient Management Tools-only" boxes for Exchange Hybrid) because direct snap-in loading bypasses Role-Based Access Control (RBAC) and Exchange configuration initialization.
Option A: Connect from Any Machine via New-PSSession (Recommended for Scripts & Scheduled Tasks)
This works from any domain-joined server or workstation without installing Exchange Management Tools:
# Connect to On-Premises Exchange Server (2016 / 2019 / Exchange SE) via Kerberos Remote PowerShell
$ExchangeServerFQDN = "exch-core-01.lab365.local"
$ExchSession = New-PSSession -ConfigurationName Microsoft.Exchange `
-ConnectionUri "http://$ExchangeServerFQDN/PowerShell/" `
-Authentication Kerberos
Import-PSSession $ExchSession -DisableNameChecking -AllowClobber | Out-Null
# Run any Exchange cmdlet with full RBAC support
Get-Mailbox -ResultSize 10 | Select-Object DisplayName, PrimarySmtpAddress, Database
# Clean up the session when finished
Remove-PSSession $ExchSession
Option B: Load the Full Exchange Management Shell Environment Locally (RemoteExchange.ps1)
If your script is running directly on the Exchange Server, dot-source RemoteExchange.ps1 using the $env:ExchangeInstallPath automatic variable so it initializes the exact same environment as the official Exchange Management Shell shortcut:
# Dot-source RemoteExchange.ps1 and connect to the local Exchange server
. "$env:ExchangeInstallPath\bin\RemoteExchange.ps1"
Connect-ExchangeServer -auto -ClientApplication:ManagementShell
# Verify Exchange cmdlets are loaded
Get-MailboxDatabase -Status | Select-Object Name, Server, Mounted