{"id":1052,"date":"2026-11-07T07:46:59","date_gmt":"2026-11-07T07:46:59","guid":{"rendered":"https:\/\/windows-vps.org\/blog\/?p=1052"},"modified":"2026-11-07T07:46:59","modified_gmt":"2026-11-07T07:46:59","slug":"windows-server-scheduled-task-gmsa-service-account","status":"publish","type":"post","link":"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/","title":{"rendered":"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><code>Get-ScheduledTask -TaskName 'Nightly ETL' | Select-Object -ExpandProperty Principal<\/code> returns <code>UserId: CORP\\svc-etl<\/code> with no password anywhere on disk \u2014 and that is the point. A stored password in a scheduled task or service is a credential that has to be rotated, backed up and eventually leaks through a GPO preference or a copied XML export. A group Managed Service Account (gMSA) removes the password from the equation entirely: Active Directory generates and rotates a 240-character key every 30 days, and the host retrieves it at runtime. If you need a domain-joined host to try this on, compare <a href=\"https:\/\/windows-vps.org\/\">Windows VPS plans with RDP included<\/a> \u2014 gMSA requires domain membership, so a workgroup-only VPS cannot use this pattern.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Know the four account types before choosing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A local virtual account (<code>NT SERVICE\\svcname<\/code>) needs no configuration and is enough for a single-member server. A standalone MSA (<code>Add-ADServiceAccount<\/code>) is tied to one computer and cannot run across a farm. A gMSA works on any host in the permitted group, which is what makes it right for scheduled tasks that may fail over and for services running on more than one node.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check what you currently have before migrating anything: <code>Get-ScheduledTask | Where-Object { $_.Principal.UserId -notlike 'SYSTEM*' -and $_.Principal.UserId -notlike 'NT AUTHORITY*' } | Select-Object TaskPath,TaskName,@{n='User';e={$_.Principal.UserId}}<\/code>. Every row is a stored password or a service account that will expire during a holiday weekend.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites that fail silently if missing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">gMSA requires a KDS root key in the domain, and the key must be at least 10 hours old before any gMSA will work. Create it with <code>Add-KdsRootKey -EffectiveTime ((Get-Date).AddHours(-10))<\/code> in a lab, or plan a one-day gap in production. Verify with <code>Get-KdsRootKey<\/code>. On older functional levels you also need the KDS service reachable from every host that will use the account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The host also needs the gMSA principal to be able to read its own managed password \u2014 in a modern domain that is the host&#8217;s computer account, handled automatically. In domains where <code>PrincipalsAllowedToRetrieveManagedPassword<\/code> was set to a group, the computer must be a member. Confirm on the host with <code>Test-ADServiceAccount -Identity gmsa-etl<\/code>; a <code>False<\/code> result is the single most common reason a gMSA task fails with logon failure 0x8007052E.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create the gMSA and grant it the right to log on<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create the account with an explicit retrieval group: <code>New-ADServiceAccount -Name gmsa-etl -DNSHostName gmsa-etl.corp.example.com -PrincipalsAllowedToRetrieveManagedPassword 'GRP-ETL-Hosts'<\/code>. Then install it on the host: <code>Install-ADServiceAccount gmsa-etl<\/code> followed by <code>Test-ADServiceAccount gmsa-etl<\/code>. The account must appear in <code>Get-ADServiceAccount -Filter *<\/code> with the correct host group.<\/p>\n\n\n<p>A gMSA cannot be granted rights like a user in the GUI. Add it with <code>icacls D:\\ETL \/grant \"CORP\\gmsa-etl$:(OI)(CI)M\"<\/code> \u2014 note the trailing dollar sign, which is part of the account name and the most-often-omitted character in this whole procedure. For file shares, grant at the share level with <code>Grant-SmbShareAccess<\/code> as well, or the account will authenticate and still fail to write.<\/p>\n<!-- \/wp:post-content -->\n\n<!-- wp:heading {\"level\":2} -->\n<h2>Convert a scheduled task without breaking the XML<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Change the principal in place: <code>$p = New-ScheduledTaskPrincipal -UserId 'CORP\\gmsa-etl$' -LogonType Password -RunLevel Highest<\/code>, then <code>Set-ScheduledTask -TaskName 'Nightly ETL' -Principal $p<\/code>. The <code>LogonType Password<\/code> value looks wrong for a passwordless account but is what Task Scheduler requires for a gMSA; <code>S4U<\/code> will not work here.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Watch for tasks authored in the GUI that carry <code>&lt;Password&gt;<\/code> in their XML. <code>Export-ScheduledTask -TaskName 'Nightly ETL'<\/code> shows the raw definition; strip any stored credential element before re-registering, or the task keeps the old secret alongside the new principal. Confirm afterwards with <code>(Get-ScheduledTask -TaskName 'Nightly ETL').Principal.LogonType<\/code> returning <code>Password<\/code> and the UserId ending in <code>$<\/code>.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":2} -->\n<h2>Convert a Windows service<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Set the service account with <code>sc.exe config \"MyAgent\" obj= \"CORP\\gmsa-etl$\" password= \"\"<\/code>. The empty password is correct for gMSA and must be present as an empty quoted string, otherwise <code>sc<\/code> complains about an invalid parameter. Then grant the account the log-on-as-service right; it is usually inherited through <code>SeServiceLogonRight<\/code> on the host group policy, but verify with <code>whoami \/priv<\/code> from a process running under the account.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Restart the service and check the System log for 7034 or 7000. If the service starts and then cannot reach a SQL instance or a UNC path, the failure is in the target&#8217;s permissions, not in the logon \u2014 the account authenticated successfully or you would have seen 7000 instead. Adding the gMSA to a database is done with <code>CREATE LOGIN [CORP\\gmsa-etl$] FROM WINDOWS<\/code>, with the same trailing dollar sign.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":2} -->\n<h2>Test the rotation before you trust it<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>The managed password changes every 30 days without any action, so the thing to test is resilience: reboot the host, confirm the task and service start without a manual logon, then check for 4625 failures in the Security log. A gMSA that works until the first reboot is a gMSA whose host is not in the retrieval group, and the failure appears hours after the change was declared done.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Also verify the account is not accidentally a member of a privileged group. gMSA accounts can be added to groups like Domain Admins, and that is a serious escalation path because any permitted host can impersonate them. Run <code>Get-ADPrincipalGroupMembership 'gmsa-etl$'<\/code> and keep the result to the minimum set.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":2} -->\n<h2>When gMSA is the wrong answer<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>If the host is not domain-joined \u2014 common on small VPS instances \u2014 gMSA is unavailable, and a local virtual account or a tightly scoped local account is the practical choice. If the task must reach a resource in another forest without a trust, a certificate-based credential or a delegated service account is often simpler than extending gMSA across the boundary.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>For everything else, gMSA is the lowest-maintenance option available: no stored secret, no rotation ticket, no credential in a GPO preference file. Review <a href=\"https:\/\/windows-vps.org\/\">the full Windows Server specs and pricing<\/a> to size a host that will run these services and keep it domain-joined, then audit the remaining stored-password principals and move them one at a time.<\/p>\n<!-- \/wp:paragraph -->\n","protected":false},"excerpt":{"rendered":"<p>Create a gMSA, grant it logon and file rights with the trailing dollar sign intact, and convert scheduled tasks and services without leaving stored credentials behind.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1052","post","type-post","status-publish","format-standard","hentry","category-tutorials-guides"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords - Windows VPS Blog<\/title>\n<meta name=\"description\" content=\"Create a gMSA, grant it logon and file rights with the trailing dollar sign intact, and convert scheduled tasks and services without leaving stored credentials behind.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords\" \/>\n<meta property=\"og:description\" content=\"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords\" \/>\n<meta property=\"og:url\" content=\"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/\" \/>\n<meta property=\"og:site_name\" content=\"Windows VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-07T07:46:59+00:00\" \/>\n<meta name=\"author\" content=\"windows-vps\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@myxiechengxuan\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"windows-vps\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/\",\"url\":\"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/\",\"name\":\"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords - Windows VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\"},\"datePublished\":\"2026-11-07T07:46:59+00:00\",\"author\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\"},\"description\":\"Create a gMSA, grant it logon and file rights with the trailing dollar sign intact, and convert scheduled tasks and services without leaving stored credentials behind.\",\"breadcrumb\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/windows-vps.org\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\",\"url\":\"https:\/\/windows-vps.org\/blog\/\",\"name\":\"Windows VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/windows-vps.org\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\",\"name\":\"windows-vps\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"caption\":\"windows-vps\"},\"sameAs\":[\"https:\/\/windows-vps.org\/blog\",\"https:\/\/x.com\/myxiechengxuan\"],\"url\":\"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords - Windows VPS Blog","description":"Create a gMSA, grant it logon and file rights with the trailing dollar sign intact, and convert scheduled tasks and services without leaving stored credentials behind.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/","og_locale":"en_US","og_type":"article","og_title":"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords","og_description":"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords","og_url":"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/","og_site_name":"Windows VPS Blog","article_published_time":"2026-11-07T07:46:59+00:00","author":"windows-vps","twitter_card":"summary_large_image","twitter_creator":"@myxiechengxuan","twitter_misc":{"Written by":"windows-vps","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/","url":"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/","name":"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords - Windows VPS Blog","isPartOf":{"@id":"https:\/\/windows-vps.org\/blog\/#website"},"datePublished":"2026-11-07T07:46:59+00:00","author":{"@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58"},"description":"Create a gMSA, grant it logon and file rights with the trailing dollar sign intact, and convert scheduled tasks and services without leaving stored credentials behind.","breadcrumb":{"@id":"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/windows-vps.org\/blog\/windows-server-scheduled-task-gmsa-service-account\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/windows-vps.org\/blog\/"},{"@type":"ListItem","position":2,"name":"Scheduled Tasks and Services Under a gMSA Instead of Stored Passwords"}]},{"@type":"WebSite","@id":"https:\/\/windows-vps.org\/blog\/#website","url":"https:\/\/windows-vps.org\/blog\/","name":"Windows VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/windows-vps.org\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58","name":"windows-vps","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","caption":"windows-vps"},"sameAs":["https:\/\/windows-vps.org\/blog","https:\/\/x.com\/myxiechengxuan"],"url":"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/"}]}},"_links":{"self":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/comments?post=1052"}],"version-history":[{"count":1,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1052\/revisions"}],"predecessor-version":[{"id":1059,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1052\/revisions\/1059"}],"wp:attachment":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/media?parent=1052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/categories?post=1052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/tags?post=1052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}