cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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
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?

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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Users online (44,145)