Skip to content
InvardiaInvardia
Why InvardiaProductsFeaturesPricingCommunity
Docs
All documentation
Product documentationPIM ManagerSecurityInsight
SettingsPIM Manager settingsSecurityInsight settingsEntra Policy Suite settings
ScriptsPIM Manager scriptsSecurityInsight scriptsEntra Policy Suite scriptsInvardia scripts
Error codesPIM Manager error codesSecurityInsight error codes
API and MCPPIM Manager APIPIM Manager MCP toolsSecurityInsight APISecurityInsight MCP tools
SecurityPIM Manager security packSecurityInsight security packEntra Policy Suite security pack
Network and designPIM Manager network guidesPIM Manager command wizardNetwork egressDesign your installationCalculate your cost
SupportSetup scriptsRemote support access
Search the docs
SupportAboutContactBook a demoCustomer portalDesign your installationFree Pro trial

PIM Manager scripts

Initialize-PimHybridWorkerAd

PIM for Active Directory: prepare Active Directory for the hybrid worker

Purpose

Prepares Active Directory for the PIM for Active Directory hybrid worker: its group managed service accounts, their least-privilege rights, the servers GPO and, for an Azure VM, the offline domain-join blob.

When to run it

Once per worker, by the AD administrator on a domain controller (or a domain-joined admin host with dsacls.exe and the Group Policy Management tools), after the infrastructure step. Re-run safely after changing OUs or adding server onboarding.

Who may run it

KindRoleScopeWhy
otherDomain Adminsthe domaincreates gMSAs, groups and the servers GPO, and delegates OU rights (dsacls)
otherEnterprise Admins (only with -CreateKdsRootKey)the forestcreates the forest's KDS root key

What it changes

WhereActionWhatPermission / roleScopeWhyUndo
Active Directory (-GmsaOu)createper identity: the gMSA (AES256), <name>-PermissionGroup (the gMSA its only member) and <name>-PrincipalsAllowedAccess (the worker computer)AD is written only by gMSAs, one per privilege tier; every right goes to the PermissionGroupdelete the gMSAs and their two groups
Active Directory OUsupdateACEs for <GmsaName>-PermissionGroup: -GroupsOu read + create groups + write member/displayName/description (+ delete groups only with -AllowGroupCleanup); each -AdminAccountsOu create users + full control below; AdminSDHolder write member only with -GrantProtectedGroupMembership (Tier 0)least privilege per OUdsacls <dn> /R <DOMAIN>\<GmsaName>-PermissionGroup
Group Policy (only with -ServerGmsaName + -ServerOu)createa GPO (Restricted Groups: <ServerGmsaName>-PermissionGroup member of BUILTIN\Administrators, adds only) linked to each -ServerOuserver onboarding by the Tier-1 identityunlink and delete the GPO
Active Directory (-ProvisionOdj, Azure VM)createthe worker's computer account in -ComputerOu and the offline domain-join blob (printed)joins the Azure VM without line of sight; an Azure Arc server is already joineddelete the computer account
the forest (-CreateKdsRootKey)createa KDS root key (Add-KdsRootKey), usable about 10 hours laterno gMSA exists without onenone (forest-wide; leave it)

What it only reads

  • the domain (RootDSE, partitions), the OUs, existing gMSAs / groups / computer, the KDS root keys and their age, the AD Privileged Access Management feature (detected, never enabled), the GPO and its links

Parameters

ParameterRequiredDefaultWhat it does
-WorkerComputerNameyesThe worker's computer name (Azure VM name or the Arc server's name).
-ComputerOuyesThe OU of the worker's computer account.
-GmsaNamenogMSA-PIM-L1-T0The Tier-0 worker identity.
-GmsaOuyesWhere the gMSAs and their groups are created.
-GroupsOuyesWhere PIM creates and maintains AD groups.
-AdminAccountsOunoOU(s) of the AD admin accounts PIM creates.
-GrantProtectedGroupMembershipnofalseWrite member on AdminSDHolder (protected groups) -- the worker becomes Tier 0.
-AllowGroupCleanupnofalseAlso grant 'Delete Group objects' on -GroupsOu, for the reviewed clean-up of old PIM groups (a SuperAdmin approves the exact list in PIM Manager).
-ServerGmsaNamenoThe Tier-1 server onboarding identity; needs -ServerOu.
-ServerOunoThe servers OU(s) for the GPO. Keep the worker out of them (the script warns).
-ServerAdminGpoNamenoPIM for AD: <ServerGmsaName>-PermissionGroup is local administrator (servers)The GPO name.
-UsedBynoPIM Manager hybrid workerText written into the gMSA descriptions.
-ProvisionOdjnofalseAzure VM: create the computer account and print the offline domain-join blob.
-ReuseComputernofalseWith -ProvisionOdj: re-provision an existing computer account (resets its password).
-CreateKdsRootKeynofalseCreate the forest's KDS root key when there is none (usable ~10 hours later; the script prints when).
-TriggerSdPropnofalseApply AdminSDHolder on the PDC emulator now instead of within the hour.

Preview with -WhatIf

Prints every object, right, GPO setting and link it would create; creates nothing.

Undo

Unlink and delete the servers GPO, remove the ACEs (dsacls <dn> /R <DOMAIN>\<GmsaName>-PermissionGroup) on -GroupsOu, each -AdminAccountsOu and AdminSDHolder, then delete the gMSAs, their groups and (for an Azure VM) the computer account.

Network

It connects to: the domain controllers only (LDAP through .NET System.DirectoryServices, dsacls.exe, djoin.exe, SYSVOL); no internet. Modules: only the owner-approved Windows GroupPolicy module (to create the GPO) and Add-KdsRootKey (with -CreateKdsRootKey), framework 12.17

Download and run

Run these lines in PowerShell: the first downloads the script into the current folder, the second runs it.

Invoke-WebRequest https://invardia.com/support/pim/Initialize-PimHybridWorkerAd.ps1 -OutFile Initialize-PimHybridWorkerAd.ps1
.\Initialize-PimHybridWorkerAd.ps1 -WorkerComputerName <WorkerComputerName> -ComputerOu <ComputerOu> -GmsaOu <GmsaOu> -GroupsOu <GroupsOu>

To check the download first, compare its SHA-256 with the published one:

SHA-256 bf9d009f1fcf1d22c60dd6c0ee38cc2663f3b8d5f48a736c31d6f355d341e525

Checksums: SHA256SUMS.txt · Version 3.0.70

Before you run it, compare the file's SHA-256 with its line in SHA256SUMS.txt.

Every parameter: Get-Help .\Initialize-PimHybridWorkerAd.ps1 -Full · Source: Initialize-PimHybridWorkerAd.ps1

Every script, identity and permission for your security review: PIM Manager

InvardiaInvardia

See the risk. Control the access.

Products

PIM ManagerSecurityInsightEntra Policy SuiteAll featuresPricingFree 60-day Pro trialBook a demoWhy Invardia

Docs

DocumentationSearch the docsPIM Manager settingsSecurityInsight settingsPIM network guidesCommand wizardNetwork egressPIM Manager design configuratorSecurityInsight design configuratorDesign your installationCalculate your cost

Company

AboutContactCustomer portalSupportHow support worksHow updates reach youSupport in numbersSetup scriptsRemote support accessContact: info@invardia.com

Legal

Terms of saleLicence termsData processingPrivacyCookiesCompany information
© 2026 Invardia – a brand of 2LINKIT, founded and owned by Morten Knudsen · Strandvejen 21A, 6000 Kolding, Denmark · VAT DK39208032 · Contact: info@invardia.com