Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

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

Posted on by 1,638

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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans