Prepare the server, then create a group managed service account (gMSA) for the agent. Windows changes its password for you, so there is nothing to store.
Turn on TLS 1.2 for .NET
CON-SYNC-01
foreach ($p in 'HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319') {
New-Item $p -Force | Out-Null
Set-ItemProperty $p -Name 'SystemDefaultTlsVersions' -Value 1 -Type DWord
Set-ItemProperty $p -Name 'SchUseStrongCrypto' -Value 1 -Type DWord
}
Test-NetConnection login.microsoftonline.com -Port 443 -InformationLevel Quiet # TrueCreate the KDS key (once per forest)
A domain controller
Add-KdsRootKey -EffectiveImmediately # wait 10 hours before step 3
Test labs only
Add-KdsRootKey -EffectiveTime ((Get-Date).AddHours(-10)) skips the wait. In a school, wait the 10 hours so every DC has the key.
Create the gMSA and its host group
A domain controller
$top = "OU=Contoso School,DC=ad,DC=contoso,DC=com" New-ADGroup -Name "SG-CON-Sync-Hosts" -GroupScope Global -GroupCategory Security -Path "OU=CON-Groups,$top" Add-ADGroupMember -Identity "SG-CON-Sync-Hosts" -Members "CON-SYNC-01$" New-ADServiceAccount -Name "svc-entra-gmsa" ` -DNSHostName "svc-entra-gmsa.ad.contoso.com" ` -PrincipalsAllowedToRetrieveManagedPassword "SG-CON-Sync-Hosts" ` -Path "OU=CON-Service-Accounts,$top"
Restart the server and test
The server picks up its new group at restart. Sign back in as CONTOSO\Administrator, not the local Administrator.
CON-SYNC-01
Add-WindowsFeature RSAT-AD-PowerShell Test-ADServiceAccount -Identity "svc-entra-gmsa" # must be True
Done when
Check
Test-ADServiceAccount returns True on CON-SYNC-01.


