Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Dynamics CRM Online - how the heck do you manage users and roles programatically? (Power Platform)

(0) ShareShare
ReportReport
Posted on by 20

In CRM Online, which runs on this "Power Platform", er, platform, how the heck do you manage roles to user/groups programmatically? (Permissions aren't the issue, I can do it via the Power Platform GUI or within CRM itself.)

Powershell is preferred but the `Microsoft.PowerApps.Administration.PowerShell` doesn't seem to support it. (And so far seems really badly written/incomplete)

I've tried using the 
PowerPlatform CLI, up to and including registering a service principal, (which is added to the CRM environment), but

>pac admin assign-user -env 9912fe79-valid-env-guid-abc123456789 --user "some.email@ourdomain.org" --role "System Administrator"

give the error

Message: Access token validation failure. Invalid audience.

(Even when using valid user credentials)


Am I missing something obvious? How do folks manage users when provisioning/migrating environments?
  • Suggested answer
    PerezAguiar Profile Picture
    PerezAguiar on at
    RE: Dynamics CRM Online - how the heck do you manage users and roles programatically? (Power Platform)

    Hey!

    I have 2 different approaches for this.

    1: Using the Microsoft.PowerApps.Administration.Powershell as you've stated.   The list of available cmdlets is on learn.microsoft.com/.../.  If you want to create a user, the command would be "add-adminpowerappssyncuser".  However, please note that if the environment has a database, you can synchronize the user (which will bring the data from AzureAD into the environment) but there's no command to assign a security role to the user.  On this post, you have a nice powershell example: community.dynamics.com/.../force-sync-users-using-powershell

    2: There's a Github repository from Sean McNellis, https://github.com/seanmcne.  there you have "microsoft.Xrm.Data.Powershell" module that you can deploy, and Microsoft.Xrm.Data.Powershell.Samples.  On the latest, you have a folder with "user operations", that has an interesting "addCrmUsersfromOu.ps1", or "AddCrmUsersfromCSV.ps1"

    Regards,

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans