To use a managed service account in Active Directory, create a KDS root key once, create the account with New-ADServiceAccount, install it on the host with Install-ADServiceAccount, and set the service or task to log on as DOMAIN\name$ with no password.
This guide covers standalone MSAs, group MSAs (gMSA) and the delegated MSA (dMSA) in Windows Server 2025, plus running services and scheduled tasks under them and fixing the usual errors.
Create a group managed service account (gMSA) in Active Directory
A gMSA is the type to pick for almost any new service: Windows rotates its password, and it works on one server or many. Run these commands in an elevated PowerShell window with the Active Directory module, as a member of Domain Admins or Enterprise Admins.
- Create a security group, for example gMSA-WebHosts, and add the computer accounts of every server that will run the service.
- If the domain has no KDS root key yet, run
Add-KdsRootKey -EffectiveImmediatelyon a domain controller and allow up to 10 hours for replication. - Create the account:
New-ADServiceAccount -Name gmsa-web -DNSHostName gmsa-web.contoso.com -PrincipalsAllowedToRetrieveManagedPassword gMSA-WebHosts. - Restart each member server so it picks up its new group membership.
- On each member server, run
Install-ADServiceAccount -Identity gmsa-web. - Run
Test-ADServiceAccount -Identity gmsa-webon the same server and check it returns True. - Set the service or scheduled task to run as CONTOSO\gmsa-web$ with a blank password.
gMSA names must be unique across the whole forest, not just the domain. Keep the name at 15 characters or fewer so the SAM account name works with older systems; Windows appends the $ itself.
MSA vs gMSA vs dMSA vs virtual accounts
Windows Server offers four managed identities for services. They differ in how many servers can use them and who looks after the password.
| Your situation | Use this account type | Why |
|---|---|---|
| One service on one domain-joined server | Standalone MSA (sMSA) | Linked to a single computer; Windows resets the password and handles SPNs |
| The same service on several servers, a web farm or a load balancer | Group MSA (gMSA) | Domain controllers compute the password and every authorised host retrieves it |
| Replacing an old user account used as a service account on Windows Server 2025 | Delegated MSA (dMSA) | Ties authentication to the device identity and disables the old account's password |
| A local service that only needs the computer's own network identity | Virtual account (NT SERVICE\name) | No password at all; network access uses DOMAIN\computer$ |
| An application that supports none of the managed account types | Ordinary domain user account | Works anywhere, but you set and rotate the password yourself under the domain password policy |
Passwords on ordinary user accounts are only as strong as the Active Directory password policy and the admin who rotates them, which is the main reason to move them to a gMSA or dMSA. Failover clusters themselves do not support gMSAs, but a Windows service, app pool or scheduled task running on top of the Cluster service can use one.
gMSA requirements in Active Directory
| Requirement | Detail |
|---|---|
| Domain and forest functional level | Windows Server 2012 or later for gMSA support on all devices |
| KDS root key | One per forest, created with Add-KdsRootKey; event ID 4004 in the KdsSvc Operational log confirms it |
| Permissions | Domain Admins or Enterprise Admins, or delegated rights to create msDS-GroupManagedServiceAccount objects; Account Operators cannot by default |
| Management tools | Active Directory module for Windows PowerShell (part of RSAT) and a 64-bit PowerShell session |
| Kerberos | Registered SPNs for inbound services, working DNS, synchronised clocks and AES encryption support on the hosts |
| Host operating system | Windows Server 2012 or later; gMSAs do not apply to earlier versions |
If you manage AD from a workstation instead of a domain controller, install Active Directory Users and Computers and the rest of RSAT first, then run Import-Module ActiveDirectory.
Create the KDS root key with Add-KdsRootKey
Domain controllers need a Key Distribution Service root key before they can generate gMSA passwords. Create it once on a domain controller running Windows Server 2012 or later. Standalone MSAs do not need it.
Add-KdsRootKey -EffectiveImmediately
Adds a KDS root key that the local domain controller uses at once. Other domain controllers can use it only after replication, so gMSA creation waits up to 10 hours by design.
You should see: Event ID 4004 appears in the KdsSvc Operational log, and New-ADServiceAccount stops failing with a key error once the key has replicated.
In a lab with a single domain controller, Add-KdsRootKey -EffectiveTime ((get-date).addhours(-10)) backdates the key so you can create a gMSA straight away. Do not use the backdated key in production.
Avoid deleting and re-creating the root key. Domain controllers cache the old key, so restart the KDC on every domain controller if you ever have to re-create it.
How to create a managed service account (MSA) in Active Directory
A standalone MSA is restricted to one computer. It suits a single SQL Server or IIS instance that will never move to a second server.
- Open PowerShell as administrator on a computer with the Active Directory module.
- Run
New-ADServiceAccount -Name svc-sql01 -RestrictToSingleComputerto create the account. - Link it to its host with
Add-ADComputerServiceAccount -Computer SRV01 -ServiceAccount svc-sql01. - Sign in to SRV01 and run
Install-ADServiceAccount -Identity svc-sql01. - Run
Test-ADServiceAccount -Identity svc-sql01and check it returns True.
Without -Path, the account lands in the domain's Managed Service Accounts container. Linking the account to a computer and installing it locally are separate steps; both are needed.
For a server in a site with only read-only domain controllers, create the sMSA with a known password and install it with Install-ADServiceAccount -Identity svc-sql01 -PromptForPassword.
Install managed service account on Windows
Install the account locally on each host that runs the service. Installing checks the computer is allowed to use the account and sets up automatic password retrieval.
- On Windows Server, open Server Manager > Add roles and features, go to Features, expand Remote Server Administration Tools and select the Active Directory module for Windows PowerShell under the AD DS and AD LDS tools.
- On Windows 10 or Windows 11 Pro or Enterprise, open Settings > System > Optional features, select Add a feature, search for Remote and add RSAT: Active Directory Domain Services and Lightweight Directory Services Tools.
- Open PowerShell as administrator and run
Import-Module ActiveDirectory. - Run
Install-ADServiceAccount -Identity gmsa-web. - Run
Test-ADServiceAccount -Identity gmsa-webto confirm the host can retrieve the password.
Install-ADServiceAccount fails for a gMSA unless the account's PrincipalsAllowedToRetrieveManagedPassword list includes this computer or a group it belongs to. It must run in an elevated session and does not work against a read-only domain controller.

How to run a Windows service as a managed service account
Services set through the Service Control Manager accept an MSA or gMSA directly. The Services console is the quickest place to do it on a single server.
- Press Win + R, type
services.mscand press Enter. - Right-click the service and select Properties.
- Open the Log On tab and select This account.
- Type the account as CONTOSO\gmsa-web$, with the
$at the end. - Clear the Password and Confirm password boxes so both are empty.
- Select OK; Windows grants the account the Log on as a service right if it does not have it.
- Right-click the service and select Restart.
The host fetches the password from a domain controller when the service starts. IIS application pools can use a gMSA the same way through IIS Manager; if Test Settings reports a bad password there, a running pool without 503 errors means the identity is fine.

Run Windows scheduled task with managed service account (gMSA)
Task Scheduler supports gMSAs, but the gMSA principal has to be set, and later changed, with the ScheduledTasks PowerShell cmdlets. You can still open Task Scheduler afterwards to check its history.
- Grant the gMSA the Log on as a batch job right on the server in Local Security Policy > Local Policies > User Rights Assignment, or through Group Policy.
- Create the action:
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\Scripts\cleanup.ps1". - Create the trigger:
$trigger = New-ScheduledTaskTrigger -Daily -At 3am. - Create the principal:
$principal = New-ScheduledTaskPrincipal -UserId "CONTOSO\gmsa-task$" -LogonType Password. - Register the task:
Register-ScheduledTask -TaskName "Nightly cleanup" -Action $action -Trigger $trigger -Principal $principal. - Add the gMSA to any local group the job needs, such as Backup Operators, and nothing more.
-LogonType Password is the literal word Password, not a password. It tells Task Scheduler to retrieve the gMSA password from a domain controller each time the task runs.

How to check a gMSA with Test-ADServiceAccount
Two commands show whether a managed service account is ready: one on the host, one against Active Directory.
- On the host, run
Test-ADServiceAccount -Identity gmsa-web; True means the computer can retrieve and use the password. - If it returns False, run it again with
-Verboseto see the reason. - On any management machine, run
Get-ADServiceAccount -Identity gmsa-web | Select-Object *and check PrincipalsAllowedToRetrieveManagedPassword, DNSHostName and ServicePrincipalNames. - Check the service's Log On tab or the task's Run as account shows the name ending in
$.
Add a server to an existing gMSA
Scaling a service out to another server means letting that server retrieve the gMSA password. Most properties change with Set-ADServiceAccount, but the password interval does not.
- If the gMSA uses a security group, add the new server's computer account to that group in Active Directory Users and Computers or with
Add-ADGroupMember. - If the gMSA lists computers directly, run
Set-ADServiceAccount -Identity gmsa-web -PrincipalsAllowedToRetrieveManagedPassword SRV01$,SRV02$,SRV03$with the full list. - Restart the new server so its group membership updates.
- Run
Install-ADServiceAccount -Identity gmsa-webon the new server. - Run
Test-ADServiceAccount -Identity gmsa-weband check for True.
The gMSA password changes every 30 days by default. To use a different interval, set -ManagedPasswordIntervalInDays when you create the account; it is read-only afterwards, so a new interval needs a new gMSA.
Uninstall and remove a managed service account
- Switch every service and task on the host to another account first.
- On the host, run
Uninstall-ADServiceAccount -Identity gmsa-webto remove the account from that computer. - Repeat on every other host that has it installed.
- Remove the computer from the gMSA's security group, or from PrincipalsAllowedToRetrieveManagedPassword.
- Delete the account from Active Directory with
Remove-ADServiceAccount -Identity gmsa-web.
Deleting the object from the Managed Service Accounts container in Active Directory Users and Computers also works, but it skips the local clean-up that Uninstall-ADServiceAccount does on each host.
gMSA not working: Test-ADServiceAccount False and other errors
New-ADServiceAccount fails with a "key does not exist" error
There is no KDS root key yet, or it has not reached the effective time and replicated.
- Run
Add-KdsRootKey -EffectiveImmediatelyif no key exists. - Wait up to 10 hours for replication, then run New-ADServiceAccount again.
- Check the KdsSvc Operational log for event ID 4004.
Test-ADServiceAccount returns False
The host is not in PrincipalsAllowedToRetrieveManagedPassword, or it has not restarted since joining the group.
- Run
Get-ADServiceAccount -Identity gmsa-web | Select-Object *and check the allowed principals. - Add the computer or its group if it is missing.
- Restart the host and run
Test-ADServiceAccount -Identity gmsa-web -Verboseagain.
Install-ADServiceAccount fails
PrincipalsAllowedToRetrieveManagedPassword is not set, or the session is not elevated.
- Set the property with
Set-ADServiceAccount -Identity gmsa-web -PrincipalsAllowedToRetrieveManagedPassword gMSA-WebHosts. - Open PowerShell as administrator and run Install-ADServiceAccount again.
A scheduled task running as the gMSA does not start
The account lacks the Log on as a batch job right, or the task was registered without the Password logon type.
- Grant Log on as a batch job to the gMSA on the server.
- Re-register the task with
New-ScheduledTaskPrincipal -UserId "CONTOSO\gmsa-task$" -LogonType Password.
Clients cannot authenticate to the service with Kerberos
The service's SPN is missing from the gMSA, or the hosts do not support the gMSA's encryption types.
- Register the SPN with
Set-ADServiceAccount -Identity gmsa-web -ServicePrincipalNames @{Add="HTTP/web.contoso.com"}. - Configure AES encryption for the account, since hosts that block RC4 fail when no supported type is set.
- Check DNS records and clock sync between clients, hosts and domain controllers.
Creating a gMSA fails even though the name is free in your domain
gMSA names must be unique across the forest, and another domain already uses it.
- Pick a different name and run New-ADServiceAccount again.

Managed service accounts in Active Directory FAQ
What is the difference between an MSA and a gMSA?
A standalone MSA works on one computer only. A gMSA provides the same automatic password and SPN management but can be used by many servers at once, which makes it the choice for web farms, load-balanced services and anything that may move between hosts.
How often does a gMSA password change?
Every 30 days by default. You can choose another interval with -ManagedPasswordIntervalInDays only when you create the gMSA; the value is read-only afterwards, so a different interval needs a new account.
Why does a managed service account name end with a dollar sign?
The SAM account name of a managed service account ends in $, and New-ADServiceAccount appends it if you leave it out. Type the name with the $ when you set a service or task to run as the account, for example CONTOSO\gmsa-web$.
Where are managed service accounts stored in Active Directory?
In the domain's Managed Service Accounts container, unless you choose another OU with the -Path parameter of New-ADServiceAccount. You can see them there in Active Directory Users and Computers.
Can I reset the password of a gMSA?
No. Reset-ADServiceAccountPassword applies only to standalone MSAs and runs on the computer where the sMSA is installed. gMSA passwords are computed by domain controllers and rotate on their own schedule.
Do I need a KDS root key for a standalone MSA?
No. The KDS root key is only needed for group managed service accounts, because domain controllers use it to compute gMSA passwords. Standalone MSAs have their password maintained by the computer they are linked to.
What is a delegated managed service account in Windows Server 2025?
A dMSA is a new account type in Windows Server 2025 that can replace a traditional service account. Authentication is tied to specific machine identities, and once it replaces an old account, that account's password stops working. Create one with New-ADServiceAccount -CreateDelegatedServiceAccount.
Can a gMSA be used for outbound connections only?
Yes. New-ADServiceAccount -RestrictToOutboundAuthenticationOnly creates a gMSA that can authenticate to other services but cannot be the target of inbound connections, so it is created without the DNS host name that inbound authentication needs.

![How to set up and use HP pen on Windows 11/10 laptop [guide, tips & fixes]](https://techdows.com/wp-content/uploads/2026/12/How-to-set-up-and-use-HP-pen-on-Windows-1110-laptop-guide-tips-fixes-1-600x338.jpg)



