msDS-SupportedEncryptionTypes¶
The Active Directory attribute that drives encryption type selection for Kerberos service tickets.
What an unset value means today. On a domain controller with the April 2026 update or
later, an account whose attribute is blank or 0 is treated as 0x18 (AES128 + AES256),
unless the DC has an explicit DefaultDomainSupportedEncTypes. On an older DC the same
account is treated as 0x27 and gets RC4 tickets (KB5021131; lab-verified on Server 2022
only). A nonzero value is still worth setting: it makes the result identical on every DC
whatever its patch level, and it is where Microsoft recommends enabling RC4 for a service
that genuinely needs it (KB5073381).
SPN-Bearing Account Types¶
Five AD object types can have servicePrincipalName registered. Each type gets its
msDS-SupportedEncryptionTypes value a different way, has a different password
management model, and a different remediation path.
| Type | AD objectClass | SPNs | Password | Who writes msDS-SET | Value you usually find | Target |
|---|---|---|---|---|---|---|
| User service account | user (objectCategory=person) |
Manual | Human-set | Nobody, until an admin does | Unset (0) |
0x18 |
| Computer account | computer |
Auto at domain join | Auto-rotated | The machine itself, from its local Kerberos etype policy | 0x1C on Windows with no etype policy1; unset on non-Windows or pre-staged objects |
0x18 (via GPO) |
| gMSA | msDS-GroupManagedServiceAccount |
Explicit | Auto-rotated, random | Set at creation; nothing maintains it afterwards | 0x1C1 |
0x18 |
| MSA | msDS-ManagedServiceAccount |
Explicit | Auto-rotated, random | Set at creation; nothing maintains it afterwards | 0x1C or unset1 |
0x18 |
| dMSA | msDS-DelegatedManagedServiceAccount |
Explicit | Auto-rotated, random (Server 2025+) | Set at creation; nothing maintains it afterwards | Unset or 0x1C1 |
0x18 |
Vocabulary used throughout this site:
- SPN-bearing accounts - umbrella term for all five types when discussing msDS-SET, etype management, or any context where all types apply.
- User service accounts -
userobjects (objectCategory=person) with manually registered SPNs; the primary Kerberoasting target. - Managed service accounts - collective for gMSA, MSA, and dMSA when discussing auto-rotating passwords.
- Computer accounts - objectCategory=computer; a Windows machine keeps its own msDS-SET in step with its Kerberos etype policy.
Self-managed vs manually-managed:
- Self-managed: Windows computer accounts. The machine rewrites its own AD
attribute from the etypes its Kerberos policy allows, so you change the policy (GPO),
not the attribute. Microsoft's
New-ADServiceAccountreference puts clustering in the same group: "Domain-joined Windows systems and services such as clustering manage their own msDS-SupportedEncryptionTypes attribute", and a change made by hand is overwritten. - Manually-managed: user service accounts, gMSA, MSA, dMSA, and computer objects that
are not Windows machines (NAS filers, Linux hosts). Set
msDS-SupportedEncryptionTypesexplicitly on each one.
Why managed service accounts are still worth setting to 0x18
gMSA, MSA, and dMSA passwords are long and random, so Kerberoasting them is not a
practical threat, and an account at 0x1C that has AES keys already receives
AES256 tickets - the KDC picks the strongest etype in the set. Setting 0x18
removes what 0x1C still leaves open: an RC4 session key for a client that offers only
RC4, an RC4 ticket if KdcUseRequestedEtypesForTickets is ever set to 1, and an RC4
ticket if the account ever ends up without AES keys. An account left unset is a
different case: on a DC without the April 2026 update it does get RC4 tickets.
Accounts Without SPNs: msDS-SET Does Not Matter¶
The KDC only reads msDS-SupportedEncryptionTypes on the target account of a
TGS-REQ - the account that owns the SPN the client is requesting a service ticket for.
Regular user accounts without SPNs are never the target of a TGS-REQ, so their
msDS-SupportedEncryptionTypes value is never consulted during normal Kerberos
operation.
What does affect a non-SPN user's Kerberos experience:
| Kerberos component | What controls it | msDS-SET involved? |
|---|---|---|
| Pre-authentication etype | User's stored keys + client etype list | No |
| TGT ticket encryption | krbtgt's keys (AES256 where krbtgt has AES keys) |
No |
| TGT session key | Client etype list + KDC config | No |
| Service tickets to this user | Never issued (no SPN = no service ticket) | N/A |
Setting msDS-SupportedEncryptionTypes on a user account without an SPN has no effect
on Kerberos behavior. If you find accounts configured this way, the attribute was likely
set by mistake (bulk script that didn't filter by SPN, or leftover config from a removed
SPN). It is safe to clear.
Microsoft's guidance agrees: "You don't need to set a value for msDS-SupportedEncryptionTypes for user accounts without a service principal name." (This site has not run a dedicated lab test for it.)
Find Non-SPN User Accounts with msDS-SET Configured¶
Get-ADUser -Filter 'msDS-SupportedEncryptionTypes -like "*"' `
-Properties msDS-SupportedEncryptionTypes, servicePrincipalName |
Where-Object { -not $_.servicePrincipalName } |
Select-Object sAMAccountName,
@{N = 'msDS-SET (dec)'; E = { [int]$_.'msDS-SupportedEncryptionTypes' } },
@{N = 'msDS-SET (hex)'; E = { '0x{0:X}' -f [int]$_.'msDS-SupportedEncryptionTypes' } },
Enabled |
Sort-Object 'msDS-SET (dec)' -Descending |
Format-Table -AutoSize
If the list is non-empty, you can clear the unnecessary attribute. The script below saves
the old values first and only reports what it would do until you set $DryRun = $false.
$DryRun = $true
$BackupCsv = ".\msds-set-nonspn-$(Get-Date -Format yyyyMMdd-HHmmss).csv"
$targets = Get-ADUser -Filter 'msDS-SupportedEncryptionTypes -like "*"' `
-Properties 'msDS-SupportedEncryptionTypes', servicePrincipalName |
Where-Object {
-not $_.servicePrincipalName -and # krbtgt has an SPN, so it is skipped here...
$_.sAMAccountName -notlike 'krbtgt*' # ...and excluded by name as well
}
# Record the current values so the change can be reversed
$targets |
Select-Object DistinguishedName, sAMAccountName,
@{N = 'OldValue'; E = { [int]$_.'msDS-SupportedEncryptionTypes' } } |
Export-Csv -Path $BackupCsv -NoTypeInformation
foreach ($u in $targets) {
try {
Set-ADUser -Identity $u -Clear 'msDS-SupportedEncryptionTypes' `
-WhatIf:$DryRun -ErrorAction Stop
if (-not $DryRun) { Write-Information "Cleared msDS-SET on: $($u.sAMAccountName)" -InformationAction Continue }
}
catch {
Write-Warning "Failed on $($u.sAMAccountName): $($_.Exception.Message)"
}
}
Write-Information "Old values saved to $BackupCsv" -InformationAction Continue
To put a value back, read the CSV and run
Set-ADUser -Identity <DistinguishedName> -Replace @{'msDS-SupportedEncryptionTypes' = <OldValue>}
for each row.
What It Is¶
msDS-SupportedEncryptionTypes is a 32-bit integer attribute on user, computer, Group
Managed Service Account (gMSA), and trust account objects in Active Directory. It declares
which Kerberos encryption types the account supports.
When the KDC processes a TGS-REQ for a service, it reads this attribute on the target
account to determine which etype to use for the service ticket. If the attribute
is not set (value 0 or absent), the KDC uses the DC's DefaultDomainSupportedEncTypes
registry value, or a built-in default if that is absent too:
What the KDC assumes for a target account whose msDS-SupportedEncryptionTypes is unset or 0. The switch is the installed cumulative update, not the calendar date, so a mixed fleet behaves differently per DC.
| DC state | Assumed etypes | Ticket for an unset account that has AES keys | Evidence |
|---|---|---|---|
DefaultDomainSupportedEncTypes set explicitly |
The registry value | Strongest etype in that value | Lab: Server 2022 only, the pre-April build of 6-7 April 2026 and 20348.5020 (June 2026). Microsoft: KB5073381 says an explicit value is honored. |
| No DDSET, update older than April 2026 | 0x27 (DES + RC4 + AES-SK) on Server 2022 and the earlier versions KB5021131 covers |
RC4 ticket; AES256 session key for a client that lists AES256 first (an RC4-first client received RC4) | Lab: Server 2022 only. Ticket and split: 20348.4893 (March 2026 update). Session key by client order: the pre-April build of 6-7 April 2026. Microsoft: KB5021131, which does not list Server 2025. The pre-April default on Server 2025 was not lab-verified. |
| No DDSET, April 2026 update or later (Server 2022: build 20348.5020 / KB5082142; Server 2025: build 26100.32690 / KB5082063) | 0x18 (AES128 + AES256) |
AES256 ticket and session key | Lab: 20348.5020 only. Microsoft: KB5073381 and the April 2026 release notes. Server 2025 not lab-verified. |
No DDSET, April-June 2026 update, RC4DefaultDisablementPhase = 0 or 1 |
0x27 |
RC4 ticket (rollback) | Lab: 20348.5020, April and June 2026. |
| No DDSET, July 2026 update or later | 0x18; Microsoft's published timeline says RC4DefaultDisablementPhase is no longer read |
AES256 | Not lab-verified. KB5073381 (last revised 14 April 2026). |
This attribute controls ticket encryption, not key generation
Setting msDS-SupportedEncryptionTypes tells the KDC which etypes to use. It does
not control which keys are generated when the password is set. AD generates keys
for all supported etypes on every password set, regardless of this attribute's value
(lab: every test account held DES, RC4, AES128 and AES256 keys whatever its attribute).
Bit Flag Reference¶
The attribute is a 32-bit bitmask. Bits 0-7 select encryption types and bits 16-19 are protocol feature flags.
The same bit layout is used by msDS-SupportedEncryptionTypes, DefaultDomainSupportedEncTypes and SupportedEncryptionTypes. Flag letters are from MS-KILE section 2.2.7 (checked against revision 49.0, 28 September 2026).
| Bit | Hex | Decimal | Name | Notes | Source |
|---|---|---|---|---|---|
| 0 | 0x1 |
1 | DES-CBC-CRC | Disabled by default since Windows 7 / Server 2008 R2; removed from Server 2025 and Windows 11 24H2 | MS-KILE flag A; Microsoft removed-features list |
| 1 | 0x2 |
2 | DES-CBC-MD5 | Same as bit 0 | MS-KILE flag B |
| 2 | 0x4 |
4 | RC4-HMAC | No longer assumed for unset accounts on DCs with the April 2026 update; still usable when set explicitly | MS-KILE flag C; KB5073381 |
| 3 | 0x8 |
8 | AES128-CTS-HMAC-SHA1-96 | MS-KILE flag D | |
| 4 | 0x10 |
16 | AES256-CTS-HMAC-SHA1-96 | Recommended | MS-KILE flag E |
| 5 | 0x20 |
32 | AES256-CTS-HMAC-SHA1-96-SK | Not a cipher. "Enforce AES session keys when legacy ciphers are in use." Honored in DDSET and in a per-account value. | MS-KILE flag J; lab (Server 2022, pre-enforcement build) |
| 6 | 0x40 |
64 | AES128-CTS-HMAC-SHA256-128 | Etype 19 (RFC 8009). Supported in Server 2025 / Windows 11 24H2 and later, disabled by default. Not lab-verified. | MS-KILE flag K, note 14 |
| 7 | 0x80 |
128 | AES256-CTS-HMAC-SHA384-192 | Etype 20 (RFC 8009). Same status as bit 6. Not lab-verified. | MS-KILE flag L, note 15 |
| 8-15 | Reserved | Must be zero. A DDSET of 0x100 produced KDC_ERR_ETYPE_NOSUPP on Server 2022. |
MS-KILE; lab (20348.5020) | ||
| 16 | 0x10000 |
65536 | FAST-supported | Feature flag, not an etype. Meaningful only on the AD attribute. | MS-KILE flag F |
| 17 | 0x20000 |
131072 | Compound-identity-supported | Feature flag | MS-KILE flag G |
| 18 | 0x40000 |
262144 | Claims-supported | Feature flag | MS-KILE flag H |
| 19 | 0x80000 |
524288 | Resource-SID-compression-disabled | Feature flag | MS-KILE flag I |
| 20-30 | Reserved | Set by the GPO "Future encryption types" checkbox, which writes bits 5-30 (0x7FFFFFE0) to the registry. They never reach the AD attribute. |
Lab (GPO value read back as 0x7FFFFFE0) |
||
| 31 | 0x80000000 |
2147483648 | Reserved | Not set by the "Future encryption types" checkbox. MS-KILE says bits it does not define "MUST be ignored when they are received". | Lab (GPO value read back as 0x7FFFFFE0); MS-KILE section 2.2.7 |
Bits 16-19 are not encryption types
Bits 16-19 are protocol feature flags, not encryption types. They are only meaningful
on the msDS-SupportedEncryptionTypes AD attribute. They have no effect in
DefaultDomainSupportedEncTypes or SupportedEncryptionTypes (GPO). Use the
Etype Calculator to decode composite values that include these flags.
Common Composite Values¶
Results are for a target account that has AES keys, requested by a client that advertises AES and lists it ahead of RC4, unless a row says otherwise. The session key follows the client's order of preference: in the lab a client that listed RC4 first received an RC4 session key wherever the account's set and the KDC filter allowed RC4. "Lab" means the Server 2022 lab DCs listed in the build table on the Registry Audit Results page.
| Decimal | Hex | Bits set | Service ticket | Session key | Notes |
|---|---|---|---|---|---|
| 0 | 0x0 |
none (unset) | Depends on the DC: see the default-by-build table | Same | Treated identically to an absent attribute (lab). |
| 4 | 0x4 |
RC4 | RC4 | RC4 | Explicit RC4 keeps working on enforcing builds (lab, 20348.5020). A client that offers only AES gets KDC_ERR_ETYPE_NOSUPP. |
| 8 | 0x8 |
AES128 | AES128 | AES128 | The client must offer AES128; an AES256-only request fails (lab). |
| 16 | 0x10 |
AES256 | AES256 | AES256 | |
| 24 | 0x18 |
AES128 + AES256 | AES256 | AES256 | Recommended. An RC4-only client is refused on enforcing builds (Kdcsvc 208, lab); on the pre-April build it received an AES256 ticket with an RC4 session key. |
| 28 | 0x1C |
RC4 + AES128 + AES256 | AES256 | AES256 (RC4 for a client that offers only RC4 or lists RC4 first) | The KDC picks the strongest etype, so the ticket is AES256, not RC4 (lab, every Server 2022 build tested). The ticket is RC4 only if the account has no AES keys, or if KdcUseRequestedEtypesForTickets = 1. |
| 31 | 0x1F |
DES + RC4 + AES128 + AES256 | AES256 | AES256 | No AES-SK bit. What a computer account writes for itself when all five cipher boxes are allowed. |
| 36 | 0x24 |
RC4 + AES-SK | RC4 | AES256 | Microsoft's suggested explicit value for a service that cannot accept AES tickets (KB5073381). Split etype observed in the lab on the pre-April build (Windows klist, and a client offering only AES256). With DDSET at 0x24, a client that listed RC4 first received an RC4 session key on the pre-April build and on 20348.5020; the split has not been reproduced on an enforcing build. |
| 39 | 0x27 |
DES + RC4 + AES-SK | RC4 | AES256 | The built-in default before the April 2026 update (KB5021131). Do not set it. |
| 56 | 0x38 |
AES128 + AES256 + AES-SK | AES256 | AES256 | Microsoft's suggested DDSET for AES-only domains (KB5021131). No observed difference from 0x18 in the lab. |
| 60 | 0x3C |
RC4 + AES128 + AES256 + AES-SK | AES256 | AES256 | Microsoft's suggested transitional DDSET (KB5021131). Lab-tested only with clients whose list includes AES256; behavior with an RC4-only client is not lab-verified. |
| 2147483640 | 0x7FFFFFF8 |
AES128 + AES256 + bits 5-30 | - | - | Registry value written by the GPO with AES128, AES256 and "Future encryption types" ticked. The computer account's AD attribute becomes 0x18. |
| 2147483647 | 0x7FFFFFFF |
every checkbox | - | - | Registry value with all GPO boxes ticked. The computer account's AD attribute becomes 0x1F (lab). |
Which to use:
0x18for every SPN-bearing account whose service can accept AES tickets. This is the target state.0x1Cwhile an account is waiting for a password reset to gain AES keys, or while RC4-only clients still need a session key for it. The ticket is already AES256 if the account has AES keys.0x24only for a service that cannot decrypt AES tickets (typically a non-Windows device with an RC4-only keytab). This is Microsoft's recommendation in KB5073381; it keeps the ticket RC4 and so keeps the account Kerberoastable.- Earlier versions of this site recommended
0x3Cas the transitional value for RC4-only clients. Microsoft suggests0x3Cfor the DC-wide default (KB5021131), but its effect with a client that offers only RC4 was never lab-tested here, and MS-KILE describes the0x20bit as replacing RC4 session keys with AES, which such a client cannot use. Treat0x3Cfor that purpose as unverified and test it before relying on it.
Default Values¶
User Accounts¶
User accounts have msDS-SupportedEncryptionTypes not set unless an administrator
sets it (Microsoft's KB5021131: user accounts and gMSAs "do not have the
msds-SupportedEncryptionTypes value set automatically"). The KDC therefore applies the
default for unset accounts.
Until the April 2026 update that default included RC4, which is why every user account
with an SPN was an RC4 Kerberoasting target: RC4 tickets crack roughly 800 times faster
than AES256 ones. On a patched DC an unset account now gets AES256. Setting 0x18
explicitly still matters, because it removes the dependence on each DC's patch level and on
any DefaultDomainSupportedEncTypes override. An AES256 ticket for a weak human-chosen
password is still crackable, only more slowly.
Computer Accounts¶
A supported Windows machine writes its own msDS-SupportedEncryptionTypes, based on the
encryption types its Kerberos policy allows (KB5021131). With no etype policy configured
the value is typically 0x1C (28) = RC4 + AES128 + AES256; Microsoft's own RC4 guidance
shows a computer account at 28. In the lab, a DC with every cipher allowed held 0x1F.
The "typical 0x1C" figure itself was not lab-verified here.
Computer objects that are not Windows machines (NAS filers, Linux hosts joined with a
keytab, pre-staged accounts) do not maintain the attribute. They hold whatever the joining
tool wrote, often nothing. Cluster name objects are a different case: Microsoft's
New-ADServiceAccount reference warns that "Domain-joined Windows systems and services such
as clustering manage their own msDS-SupportedEncryptionTypes attribute", so a value written
there by hand is overwritten.
gMSA, MSA and dMSA Accounts¶
Managed service accounts are not self-maintaining: the value is whatever was written
when the account was created, and nothing updates it afterwards (KB5021131 lists gMSAs
among the accounts not set automatically). In practice New-ADServiceAccount creates
gMSAs and standalone MSAs at 0x1C (28); dMSAs (Server 2025) are reported as either unset
or 0x1C depending on how they were provisioned. None of these defaults was lab-verified
on this site, so query your own domain.
At 0x1C with AES keys present, these accounts already receive AES256 tickets, and
their random passwords make cracking impractical either way. Set 0x18 to remove the
RC4 option entirely.
Accounts Whose Passwords Predate AES¶
An account whose password was last set before the domain generated AES keys has no AES keys at all, whatever its attribute says. Reset the password once and verify the keys - see Password resets and AES keys.
How to View the Attribute¶
Single Account¶
# User account
Get-ADUser -Identity svc_sql -Properties msDS-SupportedEncryptionTypes |
Select-Object Name, msDS-SupportedEncryptionTypes
# Computer account
Get-ADComputer -Identity DC1 -Properties msDS-SupportedEncryptionTypes |
Select-Object Name, msDS-SupportedEncryptionTypes
# gMSA
Get-ADServiceAccount -Identity gMSA_SQL -Properties msDS-SupportedEncryptionTypes |
Select-Object Name, msDS-SupportedEncryptionTypes
All SPN-Bearing Accounts - Overview (All 5 Types)¶
The following query covers all five AD object types that can hold a servicePrincipalName
and groups the results by type and current msDS-SupportedEncryptionTypes value:
Get-ADObject -LDAPFilter '(servicePrincipalName=*)' `
-Properties sAMAccountName, objectClass, objectCategory, 'msDS-SupportedEncryptionTypes' |
Where-Object { $_.sAMAccountName -notlike 'krbtgt*' } |
ForEach-Object {
$oc = $_.objectClass
$type = if ($oc -contains 'msDS-DelegatedManagedServiceAccount') { 'dMSA' }
elseif ($oc -contains 'msDS-GroupManagedServiceAccount') { 'gMSA' }
elseif ($oc -contains 'msDS-ManagedServiceAccount') { 'MSA' }
elseif ($oc -contains 'computer') { 'Computer' }
elseif ($_.objectCategory -like '*Person*') { 'User service account' }
else { 'Other' }
[PSCustomObject]@{ Type = $type; SetDec = [int]$_.'msDS-SupportedEncryptionTypes' }
} |
Group-Object Type, SetDec |
Sort-Object { ($_.Group[0]).Type }, { ($_.Group[0]).SetDec } |
Select-Object Count,
@{N = 'Type'; E = { ($_.Group[0]).Type } },
@{N = 'msDS-SET (dec)'; E = { ($_.Group[0]).SetDec } },
@{N = 'msDS-SET (hex)'; E = { '0x{0:X}' -f ($_.Group[0]).SetDec } } |
Format-Table -AutoSize
krbtgt and the krbtgt_* accounts are left out: they carry an SPN, stay unset on
purpose, and would otherwise sit in the "User service account" row at 0 for ever.
All SPN-Bearing Accounts - Detail List¶
One row per account with type classification, name, current msDS-SET value, and the first two SPNs registered on the account:
Get-ADObject -LDAPFilter '(servicePrincipalName=*)' `
-Properties objectClass, objectCategory, 'msDS-SupportedEncryptionTypes',
servicePrincipalName |
ForEach-Object {
$oc = $_.objectClass
$type = if ($oc -contains 'msDS-DelegatedManagedServiceAccount') { 'dMSA' }
elseif ($oc -contains 'msDS-GroupManagedServiceAccount') { 'gMSA' }
elseif ($oc -contains 'msDS-ManagedServiceAccount') { 'MSA' }
elseif ($oc -contains 'computer') { 'Computer' }
elseif ($_.objectCategory -like '*Person*') { 'User service account' }
else { 'Other' }
$set = [int]$_.'msDS-SupportedEncryptionTypes'
[PSCustomObject]@{
Type = $type
Name = $_.Name
'msDS-SET (dec)' = $set
'msDS-SET (hex)' = '0x{0:X}' -f $set
SPNs = ($_.servicePrincipalName | Select-Object -First 2) -join '; '
}
} |
Sort-Object Type, Name |
Format-Table -AutoSize
How to Set the Attribute¶
Single Account (PowerShell)¶
# Set to AES-only (recommended)
Set-ADUser -Identity svc_sql -Replace @{
'msDS-SupportedEncryptionTypes' = 24
}
# Verify
Get-ADUser -Identity svc_sql -Properties msDS-SupportedEncryptionTypes |
Select-Object Name, msDS-SupportedEncryptionTypes
Single Account (GUI)¶
In Active Directory Users and Computers (ADUC), open the account properties and go to the Account tab. Under Account options, check:
- "This account supports Kerberos AES 128 bit encryption"
- "This account supports Kerberos AES 256 bit encryption"
These two boxes set the AES128 and AES256 bits of msDS-SupportedEncryptionTypes. ADUC has
no RC4 checkbox, so it cannot clear an RC4 bit that is already set: check the resulting
value in the Attribute Editor tab, or use PowerShell, to confirm it is 0x18 (24). Leave
"Use only Kerberos DES encryption types for this account" unchecked; that box is the
UF_USE_DES_KEY_ONLY account flag, not part of this attribute.
Bulk Update: All SPN-Bearing User Accounts¶
# ---- Operator settings -------------------------------------------------------
$AccountType = 'User' # 'User' (SPN-bearing user accounts), 'gMSA', 'MSA' or 'dMSA'
$Target = 24 # etype bits to write: 24 = 0x18 = AES128 + AES256
$OnlyFrom = @(0) # current values this run may replace; 0 = unset.
# Widen deliberately, e.g. @(0, 28) -- never "everything".
$SearchBase = $null # $null = whole domain; set an OU DN to pilot on one OU first
$Exceptions = @() # sAMAccountNames to leave alone, e.g. @('svc_legacy')
$ExceptionGroup = $null # or a group whose (nested) members are left alone
$BackupCsv = ".\msds-set-$AccountType-$(Get-Date -Format yyyyMMdd-HHmmss).csv"
$DryRun = $true # $true = -WhatIf only. Set $false after reviewing the plan.
# ---- Logic: no edits needed below this line ----------------------------------
# One block on purpose: paste the whole script, or save it as a .ps1 and run that.
# Every check below throws when it fails, and nothing after a throw runs.
& {
$ErrorActionPreference = 'Stop'
$attr = 'msDS-SupportedEncryptionTypes'
#
# ---- Checks on the settings ----------------------------------------------
if ($DryRun -isnot [bool]) {
throw '$DryRun must be $true or $false: run the settings header first.'
}
if ($Target -isnot [int] -or ($Target -band (-bnot 0x3F))) {
throw '$Target must be a number that contains only etype bits 0-5 (0x3F).'
}
if (-not ($Target -band 0x18)) {
throw '$Target has no AES bit (0x8, 0x10): this script only writes AES-capable values.'
}
if ($null -eq $OnlyFrom -or @($OnlyFrom).Count -eq 0) {
throw '$OnlyFrom is empty: list the current values this run may replace.'
}
if (-not $DryRun -and -not $BackupCsv) {
throw '$BackupCsv is empty: a real run needs a file for the old values.'
}
$ldap = switch ($AccountType) {
'User' { '(&(objectCategory=person)(objectClass=user)(servicePrincipalName=*))' }
'gMSA' { '(objectClass=msDS-GroupManagedServiceAccount)' }
'MSA' { '(objectClass=msDS-ManagedServiceAccount)' }
'dMSA' { '(objectClass=msDS-DelegatedManagedServiceAccount)' }
'Computer' { '(&(objectCategory=computer)(objectClass=computer))' }
default { throw "Unknown `$AccountType '$AccountType'" }
}
$domain = Get-ADDomain
if (-not $SearchBase) { $SearchBase = $domain.DistinguishedName }
if ($AccountType -eq 'Computer' -and $SearchBase -eq $domain.DistinguishedName) {
throw 'Computer accounts must be scoped: set $SearchBase to an OU, not the domain root.'
}
if ($AccountType -eq 'Computer' -and -not $OperatingSystemLike) {
throw '$OperatingSystemLike is empty: set it to the operatingSystem pattern to include.'
}
#
# AES keys can only exist for passwords set after this date (RID 521 heuristic).
# A newer password is NOT proof that AES keys exist: only a key audit shows that.
$aesDate = (Get-ADGroup "$($domain.DomainSID)-521" -Properties whenCreated).whenCreated
if ($aesDate -isnot [datetime]) {
throw 'Could not read when the RID 521 group was created: the password-age check cannot run.'
}
$aesDate = $aesDate.ToUniversalTime()
#
$skipNames = @($Exceptions)
if ($ExceptionGroup) {
$skipNames += @(Get-ADGroupMember -Identity $ExceptionGroup -Recursive).SamAccountName
}
#
# ---- Plan: read everything, decide per account, write nothing ------------
$props = 'sAMAccountName', $attr, 'pwdLastSet', 'primaryGroupID', 'operatingSystem', 'servicePrincipalName'
$found = Get-ADObject -LDAPFilter $ldap -SearchBase $SearchBase -SearchScope Subtree `
-Properties $props
$plan = foreach ($o in $found) {
$old = [int]$o.$attr # unset reads as 0
$pwdSet = if ($o.pwdLastSet -gt 0) { [datetime]::FromFileTimeUtc($o.pwdLastSet) }
$isComp = $AccountType -eq 'Computer'
$skip =
if ($o.sAMAccountName -like 'krbtgt*') { 'krbtgt account: never changed here' }
elseif ($skipNames -contains $o.sAMAccountName) { 'listed exception' }
elseif ($isComp -and $o.primaryGroupID -in 516, 521) { 'domain controller or RODC' }
elseif ($isComp -and $o.Name -in 'AZUREADSSOACC', 'AzureADKerberos') {
'Entra ID Kerberos object'
}
elseif ($isComp -and @($o.servicePrincipalName) -like 'MSClusterVirtualServer/*') {
'failover-cluster CNO/VCO'
}
elseif ($isComp -and $o.operatingSystem -notlike $OperatingSystemLike) {
"operatingSystem '$($o.operatingSystem)' does not match '$OperatingSystemLike'"
}
elseif ($old -notin $OnlyFrom) { 'current value {0} (0x{0:X}) is not in $OnlyFrom' -f $old }
elseif (-not $pwdSet) { 'password never set: no keys to rely on' }
elseif ($pwdSet -lt $aesDate) { 'password predates AES keys: reset it first' }
[PSCustomObject]@{
Account = $o.sAMAccountName
OldValue = if ($null -ne $o.$attr) { $old } # empty = attribute was absent
NewValue = ($old -band (-bnot 0x3F)) -bor $Target # keeps feature bits 16-19
PasswordLastSet = $pwdSet
SkipReason = $skip
ObjectGuid = [string]$o.ObjectGUID # survives a rename or a move
DistinguishedName = $o.DistinguishedName
}
}
$todo = @($plan | Where-Object { -not $_.SkipReason })
$skipped = @($plan | Where-Object SkipReason)
Write-Information "Skipped: $($skipped.Count) account(s)" -InformationAction Continue
$skipped | Sort-Object SkipReason, Account |
Format-Table Account, OldValue, SkipReason -AutoSize | Out-Host
Write-Information "Planned changes: $($todo.Count) account(s) under $SearchBase" -InformationAction Continue
$todo | Sort-Object Account |
Format-Table Account, @{N = 'OldValue'; E = { if ($null -eq $_.OldValue) { '(unset)' } else { $_.OldValue } } },
NewValue, PasswordLastSet -AutoSize | Out-Host
if ($todo.Count -eq 0) { return }
#
# ---- Write: only when $DryRun is $false ----------------------------------
if (-not $DryRun) {
# Old values are saved BEFORE anything is written. An existing file is never
# overwritten, and if the file cannot be written the run stops here.
$todo | Select-Object Account, ObjectGuid, OldValue, NewValue, PasswordLastSet, DistinguishedName |
Export-Csv -LiteralPath $BackupCsv -NoTypeInformation -Encoding UTF8 -NoClobber
$saved = (Resolve-Path -LiteralPath $BackupCsv).Path
Write-Information "Old values saved to $saved" -InformationAction Continue
}
$failed = 0
foreach ($row in $todo) {
try {
Set-ADObject -Identity $row.ObjectGuid -Replace @{ $attr = $row.NewValue } -WhatIf:$DryRun
if (-not $DryRun) {
Write-Information "Updated $($row.Account): $([int]$row.OldValue) -> $($row.NewValue)" -InformationAction Continue
}
}
catch {
$failed++
Write-Warning "NOT updated $($row.Account): $($_.Exception.Message)"
}
}
if ($DryRun) {
Write-Information 'Dry run: nothing was written and no backup file was created.' -InformationAction Continue
}
else {
Write-Information "Done: $($todo.Count - $failed) updated, $failed failed. To undo, run the restore script with $saved" -InformationAction Continue
}
}
What the script will and will not do:
- Never touches
krbtgtor anykrbtgt_*account (RODC and Entra ID Kerberos keys).krbtgtcarries the SPNkadmin/changepw, so a plain "every user with an SPN" filter matches it. - Only replaces values listed in
$OnlyFrom(default: unset). Accounts that already carry a deliberate value - an RC4 exception at4,28or60, for example - are listed as skipped, not flattened. - Skips accounts whose password predates AES key generation. Setting an AES-only
value on an account without AES keys makes every ticket request for it fail with
KDC_ERR_ETYPE_NOSUPP. The date check is the same approximation used elsewhere on this site, and it is not a key check: an account that passes it can still have no AES keys (see why it is only approximate). Confirm the accounts in the planned-changes table with a real key audit before you set$DryRun = $false. - Prints two tables before anything else: the accounts it skips, with the reason, and the changes it plans, with the old and the new value.
- Stops on a failed check. The logic is one block; a wrong setting, a failed lookup or
a mistyped exception group throws, and nothing after it runs. It refuses a
$Targetthat has no AES bit. - Preserves bits 16-19 (FAST, compound identity, claims, resource-SID compression) and replaces only etype bits 0-5.
- Saves the old values to a CSV before writing (real runs only; UTF-8, keyed on
objectGUID, never overwriting an existing file), and printsUpdatedonly for writes that succeeded. Undo a bulk run restores from that CSV.
Confirm AES keys exist first
If an account has no AES keys, setting msDS-SupportedEncryptionTypes = 0x18 makes
ticket requests for it fail with KDC_ERR_ETYPE_NOSUPP; the KDC does not fall back
to RC4. Find those accounts with Auditing Kerberos Keys and
reset their passwords before changing the attribute
(one reset, then verify).
Bulk Update: All gMSA Accounts¶
Group managed service accounts use the same bulk script as user service accounts - shown in full under
Bulk update - with one setting changed: set $AccountType = 'gMSA' in the settings header and
leave everything else as it is.
The script selects every gMSA object in $SearchBase (with or without an SPN) and applies
the same safeguards: allow-list of current values, exception list, CSV backup, dry run
by default.
Bulk Update: All MSA Accounts¶
Standalone managed service accounts use the same bulk script as user service accounts - shown in full under
Bulk update - with one setting changed: set $AccountType = 'MSA' in the settings header and
leave everything else as it is.
The script selects every MSA object in $SearchBase (with or without an SPN) and applies
the same safeguards: allow-list of current values, exception list, CSV backup, dry run
by default.
Bulk Update: All dMSA Accounts¶
Delegated managed service accounts (Windows Server 2025) use the same bulk script as user service accounts - shown in full under
Bulk update - with one setting changed: set $AccountType = 'dMSA' in the settings header and
leave everything else as it is.
The script selects every dMSA object in $SearchBase (with or without an SPN) and applies
the same safeguards: allow-list of current values, exception list, CSV backup, dry run
by default.
Setting Computer Accounts¶
Windows machines: do not write the attribute directly. The machine rewrites it from its own Kerberos etype policy, so set the policy instead - see Group Policy.
Non-Windows computer objects (filers, Linux hosts, appliances) do not maintain the attribute, so it has to be set by hand, one OU at a time, after confirming the device has AES keys in its keytab. Never run this against the whole domain: it would also hit domain controllers, cluster objects and Entra-related objects.
$DryRun = $true
Get-ADComputer -Filter 'OperatingSystem -notlike "Windows*"' `
-SearchBase "OU=Appliances,DC=corp,DC=local" `
-Properties 'msDS-SupportedEncryptionTypes', OperatingSystem |
ForEach-Object {
$old = [int]$_.'msDS-SupportedEncryptionTypes'
# Keep any feature-flag bits (16-19); replace only the cipher bits
$new = ($old -band (-bnot 0xFF)) -bor 0x18
Write-Information ("{0}: 0x{1:X} -> 0x{2:X}" -f $_.Name, $old, $new) -InformationAction Continue
Set-ADComputer -Identity $_ -Replace @{ 'msDS-SupportedEncryptionTypes' = $new } `
-WhatIf:$DryRun
}
Auditing: Find RC4-Dependent Accounts¶
Accounts with RC4 Enabled¶
# User accounts where RC4 bit (0x4) is set
Get-ADUser -Filter 'msDS-SupportedEncryptionTypes -band 4' `
-Properties msDS-SupportedEncryptionTypes, servicePrincipalName |
Select-Object sAMAccountName, msDS-SupportedEncryptionTypes, servicePrincipalName
The query above covers user accounts only. For a cross-type view of every SPN-bearing account with the RC4 bit set, use the LDAP bitwise filter below - it works against all five account types simultaneously.
All SPN-Bearing Accounts with RC4 Enabled (All Types)¶
The LDAP extensible match rule 1.2.840.113556.1.4.803 performs a bitwise AND, so
this filter matches any account where bit 2 (RC4, value 4) is set and an SPN is registered:
Get-ADObject `
-LDAPFilter '(&(servicePrincipalName=*)(msDS-SupportedEncryptionTypes:1.2.840.113556.1.4.803:=4))' `
-Properties objectClass, objectCategory, 'msDS-SupportedEncryptionTypes',
servicePrincipalName |
ForEach-Object {
$oc = $_.objectClass
$type = if ($oc -contains 'msDS-DelegatedManagedServiceAccount') { 'dMSA' }
elseif ($oc -contains 'msDS-GroupManagedServiceAccount') { 'gMSA' }
elseif ($oc -contains 'msDS-ManagedServiceAccount') { 'MSA' }
elseif ($oc -contains 'computer') { 'Computer' }
elseif ($_.objectCategory -like '*Person*') { 'User service account' }
else { 'Other' }
[PSCustomObject]@{
Type = $type
Name = $_.Name
'msDS-SET (dec)' = [int]$_.'msDS-SupportedEncryptionTypes'
'msDS-SET (hex)' = '0x{0:X}' -f [int]$_.'msDS-SupportedEncryptionTypes'
}
} |
Sort-Object Type, Name |
Format-Table -AutoSize
Accounts with No Value Set (Using Domain Default)¶
# User accounts with an SPN whose attribute is absent or 0
Get-ADUser `
-LDAPFilter '(&(servicePrincipalName=*)(|(!(msDS-SupportedEncryptionTypes=*))(msDS-SupportedEncryptionTypes=0)))' `
-Properties 'msDS-SupportedEncryptionTypes', servicePrincipalName |
Where-Object { $_.sAMAccountName -notlike 'krbtgt*' } |
Select-Object sAMAccountName,
@{N = 'msDS-SET'; E = { [int]$_.'msDS-SupportedEncryptionTypes' } },
@{N = 'SPNs'; E = { ($_.servicePrincipalName | Select-Object -First 2) -join '; ' } }
The krbtgt account also has an SPN and an unset attribute. That is its normal state;
leave it alone.
Accounts with Old Passwords (Likely Missing AES Keys)¶
The Read-only Domain Controllers group (RID 521) is created when the domain is prepared
for Windows Server 2008 domain controllers - the earliest point at which a password change
can generate AES keys. An account whose passwordLastSet predates that timestamp has no
AES keys. One set after it may still have none: Microsoft's condition is a domain
functional level of 2008 or higher and a password change since
(Event 4769),
and the group can be older than the functional-level raise. A password written from a
hash instead of being set normally also leaves no AES keys (seen in the lab on build
20348.5020).
$AESdate = (Get-ADGroup "$((Get-ADDomain).DomainSID)-521" -Properties whenCreated `
-ErrorAction Stop).whenCreated
Write-Information "AES keys can exist for passwords set after: $AESdate" -InformationAction Continue
$oldPasswords = Get-ADUser -Filter 'Enabled -eq $true' `
-Properties passwordLastSet, servicePrincipalName, 'msDS-SupportedEncryptionTypes' |
Where-Object { -not $_.passwordLastSet -or $_.passwordLastSet -lt $AESdate } |
Select-Object sAMAccountName,
@{N='PasswordLastSet'; E= { if ($_.passwordLastSet) { $_.passwordLastSet }
else { '(never set / must change)' } }
},
@{N = 'HasSPN'; E = { [bool]$_.servicePrincipalName } },
@{N = 'msDS-SET'; E = { [int]$_.'msDS-SupportedEncryptionTypes' } }
# SPN-bearing accounts first: those are the ones the KDC issues service tickets for.
$oldPasswords | Sort-Object @{E = 'HasSPN'; Descending = $true }, PasswordLastSet |
Format-Table -AutoSize
This is an approximation - it infers key presence from password age instead of reading
the stored keys, so an empty result is not proof that every account has AES keys. It
reads user objects only: computer objects (non-Windows hosts, appliances) and managed
service accounts are not checked. Accounts that have never had a password set are shown as
(never set / must change) rather than silently counted as "old". For definitive results (event-based and
replication-based methods, including offline ntds.dit analysis), see
Auditing Kerberos Keys.
Edge Cases¶
Setting AES Without AES Keys¶
Setting msDS-SupportedEncryptionTypes = 0x18 on an account that only has RC4 keys causes
the KDC to fail the ticket request. On a DC with the April 2026 update the same happens to
an unset account without AES keys, because it is now treated as 0x18. The DC logs
Event ID 16 (TGS) or Event ID 14 (AS) with text like:
The requested etypes were 18 17. The accounts available etypes were 23.
Measured on the enforcing build (20348.5020) for an account holding only an RC4 key:
| Attribute | Result |
|---|---|
0x18 |
KDC_ERR_ETYPE_NOSUPP - no fallback to RC4 |
| unset | KDC_ERR_ETYPE_NOSUPP |
0x1C |
RC4 ticket |
0x04 |
RC4 ticket |
Fix: Reset the account password to generate AES keys. 0x1C keeps the service working
until then.
Computer Accounts Update Themselves¶
Windows computers write their own msDS-SupportedEncryptionTypes from their local
Kerberos etype configuration (Group Policy or registry); Microsoft's guidance is that the
machine updates the attribute when it restarts. A value you set by hand on a Windows
computer account should therefore be expected to be overwritten. Use Group Policy to manage
Windows computer account etypes rather than setting the attribute directly. (How quickly a
manual value is overwritten was not lab-tested.)
The RC4 Compatibility Quirk¶
Before the November 2022 updates, the KDC did not treat the attribute as exact. Microsoft's KB5021131 describes environments that "might have previously been functional due to automatically adding RC4 or by the addition of AES", and says that since those updates the KDC "will now strictly follow what is set in the registry keys, msds-SupportedEncryptionTypes and DefaultDomainSupportedEncTypes." So on any DC patched since November 2022, an AES-only attribute yields an AES ticket.
One loosening remained until 2026, and it concerns the session key, not the ticket. On
the pre-April 2026 lab build, an AES-only account requested by an RC4-only client still got
its AES256 ticket, with an RC4 session key. On the enforcing build the same request is
refused (Kdcsvc 208). Also on pre-enforcement builds, KdcUseRequestedEtypesForTickets = 1
could force an RC4 ticket for an AES-only account; on the enforcing build it could not.
The USE_DES_KEY_ONLY Override¶
The UF_USE_DES_KEY_ONLY flag (0x200000 / 2097152) in UserAccountControl restricts the
account to DES keys only. This is a legacy flag from the Windows 2000 / Server 2003
era that predates the msDS-SupportedEncryptionTypes attribute entirely
(MS-ADTS ยง2.2.16).
How the flag ranks against msDS-SupportedEncryptionTypes is not settled. MS-KILE
section 3.3.5.7 has the KDC look at the flag only when the account's supported encryption
types are not populated ("If not, the KDC SHOULD check the server or service account's
UseDESOnly flag"); with the flag set it then reports the account's supported etypes as
0x3. The same section says "DES MUST NOT be used to protect the service ticket" and "If DES is
the only configured etype, the KDC MUST return KDC_ERR_ETYPE_NOTSUPP". The lab results do
not agree with each other, and only the earlier one matches that text. On Server 2022
build 20348.5020 a
flagged account was issued a DES service ticket (Event 4769 ticket etype 0x3,
supported etypes 0x3); the notes for that run say the flag overrode
msDS-SupportedEncryptionTypes but do not record the attribute's value. An earlier run on
the pre-April build, on an unset account, recorded a failure instead. Treat the outcome as
unpredictable and clear the flag wherever you find it. Microsoft has removed DES from
Server 2025, so such accounts should be expected to fail against Server 2025 DCs; this site
has not tested that.
# UF_USE_DES_KEY_ONLY = 0x200000 = 2097152
Get-ADUser -Filter 'UserAccountControl -band 2097152' `
-Properties UserAccountControl, msDS-SupportedEncryptionTypes, servicePrincipalName |
Select-Object sAMAccountName,
@{N = 'UAC (hex)'; E = { '0x{0:X}' -f $_.UserAccountControl } },
@{N = 'msDS-SET'; E = { $_.'msDS-SupportedEncryptionTypes' } },
@{N = 'HasSPN'; E = { [bool]$_.servicePrincipalName } },
Enabled |
Format-Table -AutoSize
Remediation: clear the flag on every account found:
# Replace svc_legacy with the account name
Set-ADAccountControl -Identity 'svc_legacy' -UseDESKeyOnly $false
After clearing the flag, reset the account password to generate fresh AES keys, then set
msDS-SupportedEncryptionTypes = 0x18.
-
Typical values, not lab-verified on this site. Microsoft's KB5021131 confirms the mechanism for computers ("A computer that is running a supported version of the Windows operating system automatically sets the msds-SupportedEncryptionTypes for that machines account in Active Directory.") and that user accounts and gMSAs are not set automatically. Query your own domain rather than relying on this column. ↩↩↩↩