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

Rebuild-PimEnvInternal

Convert a public PIM Manager environment to private

Part of the PIM Manager release - not a standalone download; it runs via the product's own install command or the updater.

Purpose

Converts a public (external) PIM Manager environment to private (internal-only): it captures the live PIM Manager and jobs, deletes and recreates the Container Apps environment internal-only on the same subnet and workspace, restores the apps from the capture and compares them, repairs what is keyed to the new identities, attaches sign-in and publishes the private DNS zone for the new address. Data is kept. It plans unless -Apply is given.

When to run it

Once, to convert a public environment to private (the 'rebuild' route of the conversion guide), after the registry has a private endpoint and the network is prepared. Plan a maintenance window (the delete of a VNet-integrated environment takes 15-30 minutes). It runs on Windows (the capture protects secret values with Windows DPAPI). It is part of the PIM Manager release package and runs Rebuild-PimEnvExternal.ps1 next to it: run it from the package folder that Install-Invardia or the guided install downloaded (signed), or, for Community, from the public repository at the release tag.

Who may run it

KindRoleScopeWhy
azureRbacOwner, or Contributor + User Access Administratorthe PIM resource group (role re-grants: their original scopes)Deletes and recreates the Container Apps environment, the PIM Manager and the jobs, and grants the new system identities the Azure roles the old ones had. Signed in through the browser or the Invardia Support app session (no Azure CLI, no modules).
entraRoleApplication Administrator (or owner of the PIM Manager's sign-in app)the PIM Manager's sign-in app registrationSign-in (Easy Auth) is attached to the new private address; the reply address is added to the app registration.
otherOptional: an identity in the SQL admin group (grp-pim-sql-admins) with a certificate (-SqlAdminClientId + -SqlAdminCertThumbprint)the environment's SQL databaseRepairs the database users of the recreated apps. Without it the Azure roles are still repaired and the script says the database half is owed.
entraRoleOptional: Privileged Role Administrator (with -HostingAccessTenantId)the tenantRe-grants the new identities' Microsoft Graph application permissions (Initialize-PimHostingAccess.ps1).

What it changes

WhereActionWhatPermission / roleScopeWhyUndo
Local file (temp folder)createthe capture of the live environment, the PIM Manager and every job (secret values DPAPI-protected) in -CaptureDirthis computer, this Windows userThe rebuild restores from it and resumes from it; files holding secret values are shredded when the rebuild completes.Delete the capture folder once the rebuild has completed.
Azure (the PIM resource group)removethe Container Apps jobs, the PIM Manager app and the public Container Apps environment (only with -Apply)the resource group givenThe internal/external setting of a Container Apps environment cannot be changed in place.Re-run with -ResumeFromCapture -CaptureDir <the printed folder>; or rebuild public again with Rebuild-PimEnvExternal.ps1.
Azure (the PIM resource group)createthe internal-only Container Apps environment on the same subnet and workspace, the PIM Manager (ingress internal first) and every job, from the capturethe resource group givenThe conversion itself; the restore is compared with the capture.Rebuild-PimEnvExternal.ps1 -Apply (the same tool in the other direction).
Azure (role assignments)granteach recreated app's and job's new system identity gets the Azure role assignments its old identity hadthe same Azure roles the old identity held (recorded before the delete)the scopes recorded before the deleteA recreated app gets a new identity.Remove the role assignments of the new identities.
Environment SQL databaseupdatethe database users of the recreated apps, created again from the new identities with their recorded roles (only with a SQL admin credential)the environment's SQL databaseWithout the repair the PIM Manager cannot sign in to SQL.None needed; the users match the live identities.
Entra ID and the PIM Managerupdatesign-in (Easy Auth) on the new private address and its reply address on the sign-in app registration; then ingress on for the VNetthe PIM Manager and its sign-in appWithout sign-in the PIM Manager stays on internal ingress.Remove the reply address.
Azure (private DNS)createthe private DNS zone for the new default domain (apex and wildcard to the static IP), linked to the PIM VNet and each -HubVnetIdthe PIM resource group or -PrivateDnsResourceGroupClients in the VNet and the peered networks must resolve the new private address.Delete the zone.
Azure (container registry)updatepublic network access OFF (only with -LockRegistry; refused unless the registry is Premium with a private endpoint)the registry in the resource groupA private environment pulls images and builds over the private endpoint.Turn public network access back on for the registry.

What it only reads

  • the Container Apps environment, the PIM Manager app (with its secrets and sign-in configuration) and every job
  • the data-bearing resources of the resource group -- recorded before and checked after
  • the system identities' Azure role assignments and application ids; the registry and SQL server's private endpoints

Parameters

ParameterRequiredDefaultWhat it does
-TagyesA short label for the capture files (any short name).
-SubscriptionIdyesThe PIM subscription.
-ResourceGroupyesThe PIM resource group.
-EnvNamenocae-pimThe Container Apps environment.
-ManagerAppnoca-pim-managerThe PIM Manager app.
-CaptureDirno<temp>\pim-rebuild-<tag>-<time>Where the capture is written (and read from with -ResumeFromCapture).
-EasyAuthTenantIdnoThe tenant whose Entra ID signs users in to the PIM Manager. Without it (and no sign-in configured) the PIM Manager stays on internal ingress.
-AzureConfigDirnoAccepted for older callers and ignored: the rebuild uses no Azure CLI.
-SkipEasyAuthnofalseAttach no sign-in (the PIM Manager stays on internal ingress).
-ResumeFromCapturenofalseContinue a run that stopped after the delete, from the capture in -CaptureDir.
-DeleteTimeoutSecondsno2700How long to wait for the environment delete.
-SqlServernoThe SQL server (FQDN), for the database-user repair and the Graph re-grant.
-SqlDatabasenoPimPlatformThe database.
-SqlAdminClientIdnoAn identity in the SQL admin group used for the database-user repair (with -SqlAdminCertThumbprint).
-SqlAdminClientSecretnoLegacy only: a client secret for -SqlAdminClientId. Prefer -SqlAdminCertThumbprint.
-SqlAdminCertThumbprintnoThe thumbprint of -SqlAdminClientId's certificate in the local certificate store.
-SkipIdentityRepairnofalseDo not repair the database users or the role assignments of the new identities.
-EasyAuthAllowedPrincipalsno[]Who may sign in to the PIM Manager (users or groups).
-EasyAuthAllowAllTenantUsersnofalseEvery member account of the tenant may sign in (never guests).
-HubVnetIdno[]The hub VNet(s) the new private DNS zone is also linked to. Without it only the PIM VNet resolves the PIM Manager.
-PrivateDnsResourceGroupnoWhere the new private DNS zone goes (same subscription; default the PIM resource group).
-LockRegistrynofalseTurn the registry's public network access off (refused unless Premium with a private endpoint).
-HostingAccessTenantIdnoRe-grant the new identities' Microsoft Graph permissions and the Run-now right in this tenant (Initialize-PimHostingAccess.ps1), in your own session. Needs -SqlServer.
-HostingAccessClientIdnoOptional: a certificate identity for that re-grant instead of your session.
-HostingAccessCertThumbprintnoIts certificate thumbprint in the local certificate store.
-ApplynofalseDo it. Without it (and always with -WhatIf) the script prints the plan.

Preview with -WhatIf

Reads the live environment and prints the plan: 'direction : EXTERNAL -> INTERNAL-ONLY', the captured PIM Manager and jobs, the keep-list, then 'PLAN ONLY -- nothing was changed' with the would DELETE / CREATE ('--internal-only true') / RESTORE lines, the private DNS zone it would create, notes on the registry and SQL, and 'capture NOT written (-WhatIf)'. -WhatIf wins over -Apply. Nothing is deleted or created.

Undo

Rebuild-PimEnvExternal.ps1 -Tag <tag> -SubscriptionId <subscription> -ResourceGroup <rg> -EasyAuthTenantId <tenant> -Apply rebuilds the environment public again. A run that stopped part-way resumes with -ResumeFromCapture -CaptureDir <the printed folder>. Data is never touched.

Network

It connects to: login.microsoftonline.com (sign-in), management.azure.com (Azure Resource Manager), graph.microsoft.com (identities, the sign-in app registration), <server>.database.windows.net:1433 (only for the database-user repair and the Graph re-grant's one setting)

How it runs

Part of the PIM Manager release - not a standalone download; it runs via the product's own install command or the updater.

Release 3.0.70

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