cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ancy
Kudo Kingpin
Kudo Kingpin

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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
v-yangar-msft
Microsoft
Microsoft

Hi @Ancy ,

 

You can add the users in bulk.

First, you need to create a csv file in your local and put the Object ID of users in the CSV.

If you don't create csv manually, you can use the following powershell script to import the CSV:

Install-Module -Name AzureAD
Connect-MsolService -Credential $M365credentials
Get-AzureADUser | Export-Csv c:\AllUsers.csv

 Then use the following script to add users in bulk:

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber
$pass = ConvertTo-SecureString "xxx" -AsPlainText -Force
Add-PowerAppsAccount -Username xxx@xxx.onmicrosoft.com -Password $pass
$Users=Import-Csv c:\AllUsers.csv
$Users | ForEach-Object {Add-AdminPowerAppsSyncUser -EnvironmentName 2cf02459-bda9-4d26-a0c5-10b8df862a43 -PrincipalObjectId $_.ObjectId}

Finally, you can find these users were added successfully:

v-yangar-msft_0-1611815668981.png

Hope it helps!

 

Thanks,
Arrow

View solution in original post

3 REPLIES 3
v-yangar-msft
Microsoft
Microsoft

Hi @Ancy ,

 

Based on official document, you don't have to add users to environments that have no Dataverse database, because all users in the organization are present in these environments by default. 

v-yangar-msft_0-1611715750842.png

 

 

So you can use Add-AdminPowerAppsSyncUser powershell cmdt to add the specified user to the Dynamics 365 database that is linked in the specified environment.

For the details , you can refer to https://docs.microsoft.com/en-us/powershell/module/microsoft.powerapps.administration.powershell/add... .

 

Best Regards,

Arrow

Hello,
Thanks for the answer.
I have used this PowerShell command and yes it is working fine.
But I need to add users in Bulk, so could you please share more details or any C# code that will help us?

v-yangar-msft
Microsoft
Microsoft

Hi @Ancy ,

 

You can add the users in bulk.

First, you need to create a csv file in your local and put the Object ID of users in the CSV.

If you don't create csv manually, you can use the following powershell script to import the CSV:

Install-Module -Name AzureAD
Connect-MsolService -Credential $M365credentials
Get-AzureADUser | Export-Csv c:\AllUsers.csv

 Then use the following script to add users in bulk:

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber
$pass = ConvertTo-SecureString "xxx" -AsPlainText -Force
Add-PowerAppsAccount -Username xxx@xxx.onmicrosoft.com -Password $pass
$Users=Import-Csv c:\AllUsers.csv
$Users | ForEach-Object {Add-AdminPowerAppsSyncUser -EnvironmentName 2cf02459-bda9-4d26-a0c5-10b8df862a43 -PrincipalObjectId $_.ObjectId}

Finally, you can find these users were added successfully:

v-yangar-msft_0-1611815668981.png

Hope it helps!

 

Thanks,
Arrow

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,354)