TL;DR: Need to configure a Microsoft Power Apps (Power Platform) Lab environment for a workshop, App in a Day, etc. here is a ready to go script: https://github.com/nicknow/Setup-DataverseLabEnvironment.


In the Microsoft Power App in a Day package there used to be a script to quickly deploy a trial environment. It would setup the users, environments, and databases so attendees could get right to work. Somewhere along the way that script was removed and the directions now include instructions for attendees to setup a trial or demo instance on their own.

When I used to put on a Power Apps Workshop I had users create their own trial. My thought being this was empowering for attendees (and it saved me time.) This was a reasonable tradeoff for a two-day workshop. Recently I conducted a Power App in 60 Minutes workshop. It wasn’t going to be a good use of time to spend the 15-20 minutes it can take a group of new users to setup a trial – not to mention delays because of issues with a text message or what not.

So I went looking for the old script to automate setup. Luckily I found that Jim Novak of Futurez Consulting had put an improved version of that script on GitHub. After pulling it down and making some changes I got it work. But, of course, getting it work just isn’t good enough. So I had to have some fun tweaking it.

I cleared up some error conditions, removed a license check (that blocked me), added support for deploying the Sample Apps, and added support for configuring each environment with a security group (and putting the correct user in each security group.)

The script is now available on GitHub: https://github.com/nicknow/Setup-DataverseLabEnvironment. You can either clone the repository to your Windows client or download the script file from GitHub. The Power Apps cmdlets have a dependency on the .NET Framework so you need to run this in PowerShell 5.1, not PowerShell Core 6.

It will handle installation of the required modules so if they are not already installed make sure to open your PowerShell instance as an administrator.

The parameters are all explained in the README.MD file and in the script header. Here is an example command line:

.\Setup-DataverseLabEnvironment.ps1 -TargetTenant 'mytenant' -UserName 'admin' -Password 'Admin Password' -TenantRegion 'US' -CDSLocation unitedstates -NewUserPassword 'password' -UserCount 2 -useSecurityGroup $true -installSampleApps $true

Users are created as User01, User02, User 03, etc. up to whatever -UserCount you specify. Be aware, you need to have available licenses for all the users (so usually the limit is 24, 25 total licenses minus the initial user.)

It assigns the users based on the licenses in the account. So if you setup only a Power Apps trial they’ll only get those licenses. If you setup a Microsoft 365 E3 trial and a Power Apps Per User trial the users will get assigned all the licensing.

Also, big warning here: this is for a lab environment. It’s going to delete everything except for the user it is connecting to Power Platform as and the default environment. All other users, groups, databases, and environments will be deleted automatically.

Take it for a spin. Please fork it, update it, and submit pull requests. If you have issues post them on GitHub.