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

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,098)