Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Is there any way to add users to an environment that has no Dataverse database, programmatically or via PowerShell script?

(0) ShareShare
ReportReport
Posted on by 1,664

I want to add an E5 license office 365 users into one of our D365 Database from Power platform. I can see, we can add the user from Environment itself by using this link:

https://docs.microsoft.com/en-us/power-platform/admin/add-users-to-environment

But, I need to perform the same operation either using a C# code or PowerShell script as I would like to add the users in bulk. Any help would much appreciated.

  • Suggested answer
    PerezAguiar Profile Picture
    PerezAguiar on at
    RE: Is there any way to add users to an environment that has no Dataverse database, programmatically or via PowerShell script?

    Hey Team!

    You have this command: docs.microsoft.com/.../add-adminpowerappssyncuser.  It allows user synchronization and requires 2 parameters:  The environmentID and the UserObjectID.

    A sample script would be something like this:

    Connect-AzureAD // This will prompt credentials

    $User =Get-AzureADuser // This creates an object with all AzureAD Users.  You can do some tuning to retrieve users form a specific ADGroup

    $Environment = Get-AdminPowerAppEnvironment //This will prompt for credentials

    //Change this either using a For to do this for all environments, or just to select one specific

    $env=$Environment[1]

    foreach($u in $User)

    {

       Add-AdminPowerAppsSyncUser -EnvironmentName env.Name -PrincipalObjectId $u.ObjectId

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans