gMSA / scheduled task - no mapping between account names and security ids was done

s0p4L1ne 15 Reputation points
2023-05-24T08:14:43.8433333+00:00

Hello,

I am trying to setup a scheduled task that will run a script, and I want to use gMSA. I have followed this tutorial: https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/windows-server-2012-group-managed-service-accounts/ba-p/255910 and I search on all Microsoft social technet forum and other tech forums without success.

  • The KDS root key is active
  • The gMSA is created
  • My computer is allowed to retrieve gMSA password
  • I can change the default local system user to gMSA account for a random service (in my example I successfully change the service account for glpi-agent)
  • The gMSA is allowed to logon as a batch job and as a service
  • The gMSA is member of the local Administrators group
  • Test-ADServiceAccount gMSAaccount is returning True
  • I correctly use the $ for the gMSA account name
  • I tried registering the Scheduled task as Normal user and Admin user with same result.

My powershell commands:

$TaskAction = New-ScheduledTaskAction -Execute C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -Argument 'powershell_script.ps1' -WorkingDirectory C:\User\username\Desktop 
$TaskPrincipal = New-ScheduledTaskPrincipal -UserID LAB\gMSA_powershell$ -LogonType Password -RunLevel Highest
Register-ScheduledTask gmsaPowerShell -Action $TaskAction -Principal $TaskPrincipal

It result with error: "no mapping between account names and security ids was done"

What am I missing here ?

Thank you for your help !

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Client for IT Pros | User experience | Other
{count} vote

3 answers

Sort by: Most helpful
  1. Neidhart Patrick 10 Reputation points
    2024-01-17T14:43:20.1933333+00:00

    I had the same Problem and i just fixed it. Just add a "$" sign at the End for Example [DOMAIN]\gmsa$

    that did the trick for me

    2 people found this answer helpful.
    0 comments No comments

  2. David 5 Reputation points
    2024-01-01T21:38:35.8666667+00:00

    The only suggestion I can make (as I just ran into something similar myself) is to make sure your domain name is correct and valid when creating the $TaskPrincipal var. I encountered the same error while following a separate set of instructions for sMSA account creation and made the mistake of not changing the word "DOMAIN" in their script that I copy/pasted to my actual domain name. :P

    1 person found this answer helpful.
    0 comments No comments

  3. SD Casati Riccardo 0 Reputation points
    2023-07-25T14:59:02.2233333+00:00

    Hello,

    I tried your scheduled task it worked for me.

    I think that your problem is about the creation of the gMSA. Could you paste here how you configure your gMSA?

    Regards,

    Riccardo


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.