What are the steps and procedure to use gMSA as the Windows Server Service Account?

EnterpriseArchitect 5,851 Reputation points
2024-10-15T11:16:18.71+00:00

After creating the gMSA using the below PowerShell, how can I successfully replace the services in all of my Windows Server Application servers?

New-ADServiceAccount -Name New-gMSA -DNSHostName Mydomain.com -PrincipalsAllowedToRetrieveManagedPassword "AppServer-AD-SecGrpName"

Thank you for your help and suggestions.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,726 questions
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,956 questions
Windows Server Security
Windows Server Security
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
1,902 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,937 questions
0 comments No comments
{count} votes

Accepted answer
  1. Marcin Policht 45,800 Reputation points MVP Moderator
    2024-10-15T11:47:07.3233333+00:00
    1. Ensure the gMSA is Active on All Target Servers:
      • On each application server, install the AD PowerShell module and run:
             
             Test-ADServiceAccount -Identity "New-gMSA"
        
      • If the result is True, the server can retrieve and use the gMSA.
    2. Grant Permissions to Use the gMSA:
      • Ensure the service has the correct permissions. On the server, run:
             
             Add-ADComputerServiceAccount -Identity <AppServerName> -ServiceAccount "New-gMSA"
        
    3. Stop the Service to Update Credentials:
      • On each server, stop the service that needs to use the gMSA:
             
             Stop-Service -Name "<ServiceName>"
        
    4. Update the Service to Use the gMSA:
      • Use the following command to update the service credentials:
             
             $serviceName = "<ServiceName>"
        

    $gMSA = "New-gMSA$" # Add $ to indicate gMSA Set-Service -Name $serviceName -StartupType Automatic sc.exe config $serviceName obj= $gMSA password= "" ```

    1. Grant Logon as a Service Right:
      • Use Group Policy or manually grant the gMSA "Log on as a Service" permission. You can set this locally:
             
             ntrights -u "New-gMSA" +r SeServiceLogonRight
        
    2. Start the Service with gMSA:
      • Start the service with the new credentials:
             
             Start-Service -Name "<ServiceName>"
        
    3. Verify the Service is Running Properly:
      • Check that the service is running without issues:
             
             Get-Service -Name "<ServiceName>"
        

    Automating for Multiple Servers and Services

    You can automate the steps using PowerShell remoting across multiple servers. Here’s a sample script for multiple servers:

    $servers = @("AppServer1", "AppServer2", "AppServer3")
    $serviceName = "<ServiceName>"
    
    foreach ($server in $servers) {
        Invoke-Command -ComputerName $server -ScriptBlock {
            Stop-Service -Name $using:serviceName
            sc.exe config $using:serviceName obj= "New-gMSA$" password= ""
            Start-Service -Name $using:serviceName
        }
    }
    

    Important Considerations

    • Restart Servers: Some services may require a server reboot to correctly apply the gMSA.
    • Firewall & Policy Configs: Ensure no group policies or firewalls block the new service account from accessing necessary resources.
    • Testing: Always test in a staging environment before rolling out changes in production.

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

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.