Adding users and groups with security roles assigned to Power Platform environments using CLI

9th July 2023

Do you ever find the task of adding users to a Power Platform environment and then having to assign security roles tedious and time consuming? Well, in this post, I’ll show you how to speed this up majorly using the Power Platform CLI (command line interface).

Does the idea of speeding up tedious actions typically executed in the admin center sound good to you? 🤔 Well, lucky for you, this post is the third as part of a quickly growing series on the Power Platform Developer Tools, just starting with the Power Platform CLI, but quickly moving onto all sorts like ALM developer tools, Dataverse developer tools and much more!

Want to make sure you get this content directly in your inbox on a daily basis during my 2023 challenge of #365PostsIn365Days? Subscribe now to ensure you don’t miss any of the upcoming content around these awesome topics! Let me know in the comments of these posts, how you get on with using these tools yourself too! 📧

Adding a user and assigning a security role

So the first thing we’ll look at is adding a user to an environment. Let’s take a look at the command and parameters we can supply, both required and optional.

So the command we’ll need to work with is…

pac admin assign-user

Now this command won’t do anything by itself, and that’s because we need to supply a bit more information if we want to add a user to an environment and assign a security role. If we wanted to do this in the Power Platform Admin Center, we’d need to select the environment, specify the user, and select the security role we want to assign. So, when using a different interface to carry out the same operation, we still need to supply this information! We do this using a number of parameters.


The first thing we need to specify is the environment ID or URL that we want to add the user to and then assign a security role for.


Now we need to use the role parameter to supply either the name or the ID of the role that we want to assign the user once they’ve been added to the environment.


Finally we need to supply the object ID or the UPN of the user from AAD that we want to add to the environment and assign the security role to.


So now lets take a look at an example of a command with parameters populated that we can use to add a user to an environment and assign a security role to them with.

pac admin assign-user `
  --environment 00000000-0000-0000-0000-000000000000 `
  --user "" `
  --role "Basic User"

The command above will add the user ‘” to my environment and it will assign the basic user security role.

Adding a group and assigning a security role

Now we aren’t just able to use the CLI to add users to environments with a security role. We can also use it to add groups to an environment and assign a security role.

To work with groups we’ll need to use the following command.

pac admin assign-group

We will use the same following parameters as above…



But we will also need to supply values for the following parameters.


Here we will supply the AAD object id of a group to assign to the target Dataverse environment


Here we will supply the name of the group/team that we want to create in Dataverse.


Here we will supply the team membership type with one of the following values.

  • MembersAndGuests
  • Members
  • Owners
  • Guests


Finally we need to supply the type of team to be created.

Using these parameters we’re able to add a group to a dataverse environment now as well and once again, assign a security role.

Upcoming content

So! We’re still just a few posts in to this latest new series on the Power Platform Developer Tools! If you’re enjoying this content so far, make sure you subscribe to get all the latest posts from me directly in your inbox on a daily basis! 📩

Thanks for reading friends! 💖

Posted in Power Platform Dev Tools, Dataverse

Leave a Reply

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

This will close in 0 seconds