web
You’re offline. This is a read only version of the page.
close
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)

(1) ShareShare
ReportReport
Posted on by 22

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?
I have the same question (0)
  • Suggested answer
    PerezAguiar Profile Picture
    Microsoft Employee on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans