Fix it now
0x80090322 is SEC_E_WRONG_PRINCIPAL, “The target principal name is incorrect”. Microsoft’s documented cause for it over WinRM is the service principal name: the HTTP/<FQDN> entry PowerShell wants is already registered to another service account in the forest, or to a web service on the computer itself. Find that registration and the rest follows.
setspn -q http/ex01.contoso.com
Test-WSMan ex01.contoso.com
klist purge
- Read the
setspn -qoutput. If the HTTP SPN for that name is on a user or service account rather than on the computer account, you have found it. - If the registration is obsolete, remove it from the account that should not hold it and reconnect after
klist purge. - If the account genuinely needs it, register a port-qualified SPN for WinRM instead:
Setspn -s HTTP/ex01:5985 ex01andSetspn -s HTTP/ex01.contoso.com:5985 ex01. - Then connect with the port in the SPN:
Enter-PSSession -ComputerName ex01.contoso.com -SessionOption (New-PSSessionOption -IncludePortInSPN). - As a third documented option, point the WinRM client at the WSMAN prefix instead of HTTP, then register WSMAN SPNs on the computer account. The commands are in the reference table below.
Connect with the server’s real fully qualified name. Kerberos ties the ticket to the name you typed, so an alias, a CNAME or a load-balanced address fails here even when everything else is correct.
If a fresh shell now opens, you are done. If it does not, the next section separates the three layers that can produce this and tells you which one you are in.
Why it happens
Kerberos works by name. The client asks a domain controller for a ticket to a service principal name derived from the host name it was given, and the domain controller issues a ticket encrypted with the key of whichever account holds that SPN. The service then decrypts it with its own key. If the SPN sits on a different account from the one the service runs as, decryption fails and the client is told the target principal name is incorrect. That is SEC_E_WRONG_PRINCIPAL, 0x80090322, and Microsoft publishes the same wording for it in the Active Directory replication context, where it appears as the signed value -2146893022.
Microsoft’s article on this code over WinRM is specific about how it arises. PowerShell uses an HTTP service principal name in the form HTTP/<FQDN> to reach the remote server. The failure occurs when that SPN is already registered to another service account in the forest, or has been registered by hand against a web service running on the computer. The message the reader sees is “WinRM cannot process the request. The following error with error code 0x80090322 occurred while using Kerberos authentication: An unknown security error occurred”, which names neither the SPN nor the account.
The Exchange Management Shell is remote PowerShell over WinRM into the PowerShell virtual directory in IIS, even when you run it on the server console. That gives three layers that can break: the SPN registration in Active Directory, WinRM and its HTTP listener, and the authentication configuration on the virtual directory. HTTP 401.2 in the IIS log is the third one talking – published as “Logon failed due to server configuration”, which Microsoft describes as a problem in the authentication configuration settings on the server.
Work down that list in order and you will not waste a change window. Test-WSMan against the server’s FQDN separates the first two layers from the third: if it fails, Exchange is a bystander and the problem is WinRM or the SPN. If it succeeds and only the Exchange shell fails, you are looking at the PowerShell virtual directory.
The HTTP service principal name is on the wrong account
You have this one if setspn -q http/<FQDN> returns the SPN registered against a user or service account instead of the computer account.
- Decide whether that registration is still needed. Many are left over from an application that was decommissioned.
- If it is not needed, remove it from the account that holds it, then run
klist purgeon the client and reconnect. - If it is needed, leave it alone and give WinRM its own port-qualified SPN:
Setspn -s HTTP/ex01:5985 ex01andSetspn -s HTTP/ex01.contoso.com:5985 ex01. - Connect with
Enter-PSSession -ComputerName ex01.contoso.com -SessionOption (New-PSSessionOption -IncludePortInSPN)so the client asks for the port-qualified name.
Some deployments deliberately hold HTTP SPNs on a service account so that Kerberos works to a load-balanced namespace. Check whether that is your design before deleting anything.
You want WinRM off the HTTP prefix entirely
You have this one if The HTTP SPN has to stay where it is, and adding a port-qualified SPN is not an option you want to carry.
- On the client, set the WSMAN prefix:
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Client /v spn_prefix /t REG_SZ /d "WSMAN" /f. - Register the matching SPNs on the server’s computer account:
Setspn -s WSMAN/ex01 ex01andSetspn -s WSMAN/ex01.contoso.com ex01. - Run
klist purgeand open a fresh session. - Apply the client-side value everywhere management sessions originate, not only on the server console.
This is Microsoft’s third documented option, not a workaround someone invented. The value is REG_SZ, and it is a client-side setting.
You are connecting with a name Kerberos does not know
You have this one if The shell works against the server’s own FQDN and fails through an alias, a CNAME or a virtual IP.
- Use the server’s real FQDN for management sessions. Administrative connections do not need to travel through the client namespace.
- If an alias genuinely must work, register the matching SPN on the correct account rather than falling back to a weaker authentication scheme.
- Confirm forward and reverse DNS agree for the server, because a mismatch produces this intermittently and looks like flakiness.
- Run
klist purgebetween attempts so you are not reading a cached ticket for the previous name.
WinRM or its IIS extension is missing
You have this one if Test-WSMan fails outright, or the WinRM IIS extension is absent after a rebuild or an image deployment.
- Check for the feature and install it if it is missing:
Install-WindowsFeature WinRM-IIS-Ext. - Re-establish the listener configuration with
winrm quickconfig, then list what exists withwinrm enumerate winrm/config/listener. - Check nothing is intercepting the traffic:
netsh winhttp show proxyshould not be sending local names through a proxy. - Restart the server if the feature installation asks for it, then retest with
Test-WSMan.
The PowerShell virtual directory has lost its authentication configuration
You have this one if Test-WSMan succeeds, the SPN is right, and the IIS log for the PowerShell directory records 401.2 against your attempts.
- Compare the directory’s authentication settings against Microsoft’s published defaults for Exchange virtual directories. The front end and back end copies are configured differently on purpose, so do not set them from memory.
- Recreate rather than repair. From a working shell on another Exchange server, run
Remove-PowerShellVirtualDirectoryand thenNew-PowerShellVirtualDirectoryagainst the broken server. - Run
iisreset /noforceon that server and retest withTest-PowerShellConnectivity. - On a single-server organisation, load the Exchange management snap-in locally to get a shell long enough to run those two cmdlets.
This is the last resort, not the first. Microsoft’s documented cause for 0x80090322 is the SPN, and rebuilding a virtual directory to fix a Kerberos ticket problem simply loses you the directory’s settings as well.
Full reference
Narrowing it to one layer before you change anything
| What you observe | Which layer to work on |
|---|---|
Test-WSMan also fails |
WinRM, its listener or the SPN. Exchange is not involved |
Test-WSMan works, the Exchange shell fails |
The PowerShell virtual directory, or an SPN specific to the name you used |
| Works with the server FQDN, fails with an alias | No SPN registered for the name you typed |
setspn -q http/<FQDN> shows a user account |
The registration Microsoft names as the cause |
| HTTP 401.2 in the IIS log | Authentication configuration on the virtual directory |
| It fails for one administrator only | A stale ticket cache, or that account’s group membership |
The three documented options, side by side
| Option | Commands | When it fits |
|---|---|---|
| Remove the conflicting SPN | setspn -q http/<FQDN> to find it, then remove it from the account that holds it |
The registration is obsolete |
| Give WinRM a port-qualified SPN | Setspn -s HTTP/<server>:5985 <server> and Setspn -s HTTP/<FQDN>:5985 <server>, then connect with -IncludePortInSPN |
The HTTP SPN must stay where it is |
| Move the WinRM client to WSMAN | spn_prefix REG_SZ set to WSMAN under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Client, then Setspn -s WSMAN/<server> <server> |
You want management traffic off the HTTP prefix altogether |
Commands worth knowing
| Command | What it does |
|---|---|
setspn -q http/<FQDN> |
Shows which account holds the HTTP SPN for that name. This is the query Microsoft’s article uses |
setspn -L <computername> |
Lists every SPN on that computer account |
klist purge |
Clears the current user’s Kerberos ticket cache |
Test-WSMan <FQDN> |
Tests the WinRM layer on its own, without Exchange |
winrm enumerate winrm/config/listener |
Shows which listeners exist and on which addresses |
Test-PowerShellConnectivity |
Exchange’s own end-to-end test of the PowerShell virtual directory |
iisreset drops every session the server is holding: browsers, mobile devices and Outlook connections all reconnect. Do it in a change window unless the server is already unusable.
The event that is not the cause
Event ID 15021 turns up in the System log on servers where a certificate has been replaced without rebinding an HTTPS endpoint, and it often appears in the same window as this failure. Microsoft publishes no description for it, so treat it as corroborating evidence rather than a diagnosis: it tells you the plumbing under IIS is worth a look, and it does not explain a Kerberos ticket that could not be decrypted. Do not fix a certificate binding and then assume you have fixed 0x80090322.
Managing Exchange from somewhere sensible
For day-to-day work, run the shell from a management workstation rather than the server console. It keeps you off the box, it means a broken PowerShell virtual directory on one server does not lock you out, and none of the fixes above change. Where it does matter is the SPN: a management workstation connects by the name you type, so register SPNs for the names your team actually uses rather than the one that happened to work first.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
0x80090322 |
SEC_E_WRONG_PRINCIPAL, “The target principal name is incorrect”. Over WinRM, Microsoft’s documented cause is an HTTP/<FQDN> SPN registered to another account | Microsoft Learn |
HTTP 401.2 |
Logon failed due to server configuration: a problem in the authentication configuration settings on the server | Microsoft Learn |
Event ID 15021 |
An HTTP.sys entry about the SSL configuration on an endpoint. Microsoft publishes no description, so read the event’s own text and treat it as context | not published by the vendor |
Confirm the fix worked
setspn -q http/<FQDN>shows the HTTP SPN only where you intend it to be.Test-WSMan <FQDN>returns a normal identity response.- A fresh Exchange Management Shell opens and
Get-ExchangeServerruns without error. Test-PowerShellConnectivity -ClientAccessServer <server>succeeds.- The IIS log for the PowerShell directory shows 200 for your requests rather than 401.
Questions people ask about this
Does fixing this cost anything?
No. It is a naming and configuration problem in Active Directory and IIS on servers you already license. Any advice about a wrong principal error that ends in a purchase should be treated with suspicion.
Why does it fail for one administrator and not another?
Usually a stale ticket cache, which klist purge clears. If it persists for one account, look at its group memberships: a very large Kerberos token can break authentication over HTTP where a smaller one works.
Can I use the admin centre while I fix the shell?
Often yes, and it is worth checking, because the web console uses a different virtual directory. If it also fails, the fault is something shared such as a certificate or a site-wide authentication change, and that widens the search usefully.
Is registering a port-qualified SPN safe?
Yes. It is one of the three options Microsoft documents for this error, and it exists precisely so WinRM can have its own registration without disturbing an HTTP SPN another service depends on. The client has to ask for it with -IncludePortInSPN.
Should I just recreate the PowerShell virtual directory?
Only after the SPN checks come back clean. Recreating it discards the directory’s settings and restarts IIS, and it cannot fix a Kerberos ticket that was issued for the wrong principal.
