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! š§
SubscribeAdding 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.
āenvironment
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.
ārole
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.
āuser
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.
Example
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 "user@company.com" `
--role "Basic User"
The command above will add the user āuser@company.comā 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ā¦
āenvironment
ārole
But we will also need to supply values for the following parameters.
āgroup
Here we will supply the AAD object id of a group to assign to the target Dataverse environment
āgroup-name
Here we will supply the name of the group/team that we want to create in Dataverse.
āmembership-type
Here we will supply the team membership type with one of the following values.
MembersAndGuests
Members
Owners
Guests
āteam-type
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! š©
SubscribeThanks for reading friends! š