Single-Command Power Platform Hands-on-Lab Configuration

Published 04-11-2021 05:00 PM 2,642 Views
Microsoft

Suppose you are a community leader or an instructor who will run a hands-on lab session for Power Platform. You got content for it. Now it's time for setting up the lab environment. There are roughly three approaches for the preparation.

 

  1. Ask the participants to bring their existing Power Platform environment,
  2. Ask the participants to set up their environment by themselves, or
  3. The session leader is preparing the environment for the participants to use.

 

Each effort has its pros and cons like:

 

  1. The first approach would be the easiest and the most convenient for the instructor because it's based on the assumption that everyone is ready for the exercise. However, you never know if every participant has the same configurations as you expect. It really depends on their organisation's policy. After all, you, as the session leader, will probably suffer from a lot of unexpected circumstances.
  2. The second one can be convenient for you as the session leader. It might be as tricky as the first approach. Delegating the environment set-up efforts to the participants may make you free, but at the same time, you should provide an instructional document very thoroughly and carefully. Even if you do so, it entirely depends on the participants' capability. After all, you should start the lab session by confirming the environment set-up anyway.
  3. The last option goes to you as the session leader. You prepare everything for the participants. They just come, sit and practice. If you do this set-up by hand, it would be awful. You will not want to do that.

 

Therefore, as a hands-on lab session leader, I'm going to discuss how to automate all the provisioning process and minimise human intervention by running one PowerShell script.

 

The PowerShell script used in this post is downloadable from this GitHub repository.

 

One-Liner Script

 

Let's say you use the following information for the admin account.

 

  • Tenant Name: powerplatformhandsonlab
  • Tenant URL: powerplatformhandsonlab.onmicrosoft.com
  • Admin E-mail: admin@powerplatformhandsonlab.onmicrosoft.com
  • Admin Password: Pa$$W0rd!@#$

 

With this information, how can you set up the lab environment in just one go? Here's the entire script and you just run the command below.

 

    ./Set-Environment.ps1 `
        -AdminUsername "admin" `
        -AdminPassword "Pa`$`$W0rd!@#`$" `
        -TenantName "powerplatformhandsonlab"

 

Wait, what? What's going on? Here's the magic. Let's find them together.

 

Create Microsoft 365 Tenant

 

The first step to do as the session leader is to create a Microsoft 365 tenant. Microsoft 365 offers a free trial for 30 days. It includes 25 seats, including the admin account, which is suitable for the lab. Click this link, http://aka.ms/Office365E5Trial, and create the Microsoft 365 E5 plan's trial tenant.

 

Microsoft 365 E5 Trial Landing Page

 

After filling out the form below, you get the trial tenant!

 

Microsoft 365 E5 Trial Sign-up Page

 

As you've got a new tenant, let's configure the lab environment in PowerShell. Please note that you HAVE TO use the PowerShell console with the admin privilege.

 

Provisioning Order

 

There is no particular order for the environment provisioning. However, I would recommend following this order because there's incompatibility found between PowerShell modules especially between Power Apps and AzureAD:

 

  1. Activate Microsoft Dataverse for Power Platform Default Environment
  2. Add User Accounts
  3. Assign Microsoft 365 Roles to Accounts
  4. Assign Microsoft 365 Licenses to Accounts
  5. Assign Azure Roles to Accounts

 

If you do the Microsoft Dataverse initialisation later than Azure AD, you will get an error. I'll discuss it later how to avoid it.

 

NOTE: To use any of the PowerShell module mentioned in this post, you need PowerShell v5.1 running on Windows. PowerShell Core (v6 and later) doesn't support this scenario. For more details about this, refer to this page, Connect to Microsoft 365 with PowerShell.

 

Install AzureAD Module

 

You can add a new user account to a Microsoft 365 tenant through the AzureAD module. As of this writing, the latest version of the module is 2.0.2.130. Use the Install-Module cmdlet to install the module. If you append these two parameters, -Force -AllowClobber (line #3), it always installs the newest version regardless it's already installed or not.

 

    Install-Module -Name AzureAD `
        -Scope AllUsers -Repository PSGallery `
        -Force -AllowClobber

 

Log-in to AzureAD as Admin

 

After installing the module, log into the Azure AD as the tenant admin. For automation, you should stay within the console. Therefore, the following command is more efficient for sign-in.

 

    $tenantName = "powerplatformhandsonlab"
    $adminUpn = "admin@$tenantName.onmicrosoft.com"
    $adminPW = ConvertTo-SecureString "Pa`$`$W0rd!@#`$" -AsPlainText -Force
    $adminCredential = New-Object `
        -TypeName System.Management.Automation.PSCredential `
        -ArgumentList ($adminUpn, $adminPW)
    
    $connected = Connect-AzureAD -Credential $adminCredential

 

Add User Accounts

 

It's time to add user accounts. As the trial tenant includes 25 licenses, you can add up to 24 accounts. For more details to add a new user account, refer to this document, Create Microsoft 365 User Accounts with PowerShell. But you just run the following commands. Here are some assumptions:

 

  • Each user has the same password of UserPa$$W0rd!@#$ for convenience, and it's not allowed change (line #2-4).
  • Each user has the same location where the tenant resides. For now, it's KR (line #6).
  • You need to create up to 24 accounts, so ForEach-Object is the go (line #9).
  • All user accounts created are added to the $users array object (line #18).

 

    $userPWProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
    $userPWProfile.Password = "UserPa`$`$W0rd!@#`$"
    $userPWProfile.EnforceChangePasswordPolicy = $false
    $userPWProfile.ForceChangePasswordNextLogin = $false
    
    $usageLocation = "KR"
    
    $users = @()
    (1..24) | ForEach-Object {
        $user = New-AzureADUser `
            -DisplayName $("PPUser" + $_.ToString("00")) -GivenName $("User" + $_.ToString("00")) -SurName "PP" `
            -UserPrincipalName $("ppuser" + $_.ToString("00") + "@$tenantName.onmicrosoft.com") `
            -UsageLocation $usageLocation `
            -MailNickName $("ppuser" + $_.ToString("00")) `
            -PasswordProfile $userPWProfile `
            -AccountEnabled $true
    
        $users += $user
    }

 

Assign Microsoft 365 Roles to User Accounts

 

The user accounts need to have appropriate Microsoft 365 roles. As it's the hands-on lab configuration, you can assign the Power Platform admin role to each user account. For more details of the Microsoft roles assignment, refer to this Assign Admin Roles to Microsoft 365 User Accounts with PowerShell page. Run the following command to activate the Power Platform admin role.

 

    $roleName="Power Platform Administrator"

    $role = Get-AzureADDirectoryRole | Where-Object { $_.DisplayName -eq $roleName }
    if ($role -eq $null) {
        $roleTemplate = Get-AzureADDirectoryRoleTemplate | Where-Object { $_.DisplayName -eq $roleName }
        $enabled = Enable-AzureADDirectoryRole -RoleTemplateId $roleTemplate.ObjectId
    
        $role = Get-AzureADDirectoryRole | Where-Object { $_.DisplayName -eq $roleName }
    }

 

The admin role has now been stored in the $role object. Now, iterate the $users array to assign the role.

 

    $users | ForEach-Object {
        $assigned = Add-AzureADDirectoryRoleMember `
            -ObjectId $role.ObjectId `
            -RefObjectId $_.ObjectId
    }

 

Assign License to User Accounts

 

To use Power Platform within the tenant, each user MUST have a license for it. You can assign the license through the PowerShell command. For more details, visit this Assign Microsoft 365 licenses to user accounts with PowerShell page.

 

First of all, let's find out the licenses. As soon as you create the trial tenant, there SHOULD be only one license, whose name is ENTERPRISEPREMIUM.

 

    Get-AzureADSubscribedSku

 

Then, run the following command to assign the license to all users by iterating the $users array.

 

    $sku = Get-AzureADSubscribedSku

    $license = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
    $license.SkuId = $sku.SkuId
    
    $licensesToAssign = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
    $licensesToAssign.AddLicenses = $license
    
    $users | ForEach-Object {
        $assigned = Set-AzureADUserLicense -ObjectId $_.ObjectId -AssignedLicenses $licensesToAssign
    }

 

So far, you've completed automating processes to create a trial tenant, create user accounts, and assign roles and licenses.

 

Activate Microsoft Dataverse for Power Platform Default Environment

 

Power Platform internally uses Microsoft Dataverse as its database. Microsoft Dataverse is fundamentally essential for other Microsoft 365 services to use. You can also initialise it through PowerShell commands. For more details, visit the Power Apps Cmdlets for Administrators page.

 

First, you need to install both PowerShell modules, Microsoft.PowerApps.Administration.PowerShell and Microsoft.PowerApps.PowerShell. Like the previous installation process, use the -Force -AllowClobber option to install the modules or reinstall both if they already exist (line #3, 7).

 

    Install-Module -Name Microsoft.PowerApps.Administration.PowerShell `
        -Scope AllUsers -Repository PSGallery `
        -Force -AllowClobber

    Install-Module -Name Microsoft.PowerApps.PowerShell `
        -Scope AllUsers -Repository PSGallery `
        -Force -AllowClobber

 

Log into the Power Apps admin environment, using $adminUpn and $adminPW values.

 

    $connected = Add-PowerAppsAccount -Username $adminUpn -Password $adminPW

 

NOTE: You might not be able to log into the Power Apps admin environment with the following error.

 

Unable to Login to Power Apps Environment

 

It's because the internal log-in process for both Microsoft 365 tenant and Power Apps environment are different from each other. If it happens to you, don't panic. Just open a new PowerShell console with an admin privilege and attempt to log in.

 

Here are some assumptions for the Microsoft Dataverse initialisation:

 

  • Initialise Microsoft Dataverse on the default environment (line #1),
  • Follow the currency settings of the default environment (line #5), and
  • Follow the language settings of the default environment (line #10).

 

    $paenv = Get-AdminPowerAppEnvironment -Default
    if ($paenv.CommonDataServiceDatabaseProvisioningState -ne "Succeeded") {
        $currency = Get-AdminPowerAppCdsDatabaseCurrencies `
            -LocationName $paenv.Location | Where-Object {
                $_.IsTenantDefaultCurrency -eq $true
            }
    
        $language = Get-AdminPowerAppCdsDatabaseLanguages `
            -LocationName $paenv.Location | Where-Object {
                $_.IsTenantDefaultLanguage -eq $true
            }
    
        $activated = New-AdminPowerAppCdsDatabase `
            -EnvironmentName $paenv.EnvironmentName `
            -CurrencyName $currency.CurrencyName `
            -LanguageName $language.LanguageName
    }

 

Assign Azure Subscription

 

Building custom connectors is inevitable while using Power Platform. In this case, you might need to handle resources on Azure, which requires an Azure subscription. If you create the trial tenant for Microsoft 365, you can also activate the trial Azure subscription. As it requires credit card verification, it MUST be done within Azure Portal. If you log into Azure Portal with your admin account, you can see the following screen.

 

Azure Subscription Trial Page

 

Click the Start button to sign-up for the trial subscription.

 

Azure Subscription Trial Sign-up Page

 

Once completing the trial subscription, log in to Azure using the PowerShell command below. The $adminCredential object is the same one used for Azure AD log-in.

 

    $connected = Connect-AzAccount -Credential $adminCredential

 

NOTE: You SHOULD install the Az module beforehand.

 

    Install-Module -Name Az -Scope AllUsers -Repository PSGallery -Force -AllowClobber

 

Only a limited number of resources are available in the trial subscription. For custom connectors, mainly Azure Logic Apps, Asture Storage Account, Azure Virtual Network, Azure API Management and Azure Cosmos DB are supposed to use. Therefore, to use those resources, run the following command to register those resource providers.

 

    $namespaces = @(
        "Microsoft.Logic",
        "Microsoft.Storage",
        "Microsoft.Network",
        "Microsoft.ApiManagement",
        "Microsoft.DocumentDB"
    )
    
    $namespaces | ForEach-Object {
        $provider = Get-AzResourceProvider `
            -ProviderNamespace $_ | Where-Object { $_.RegistrationState -eq "Registered" }
        if (($provider -eq $null) -or ($provider.Count -eq 0)) {
            $registered = Register-AzResourceProvider -ProviderNamespace $_
        }
    }

 

Then, assign the subscription to each user account. For Azure Roles, visit this Assign Azure Roles Using Azure PowerShell page for more details.

 

NOTE: Instead of scoping the entire subscription to each user account, it's better to create a resource group for each user, scope to the resource group and assign it to each account. For the resource group, you need a location. In this example, koreacentral is used.

 

    $role = Get-AzRoleDefinition | Where-Object { $_.Name -eq "Contributor" }
    $location = "koreacentral"
    
    $users | ForEach-Object {
        $rg = Get-AzResourceGroup | Where-Object {
            $_.ResourceGroupName -eq $("rg-" + $_.MailNickName)
        }
        if ($rg -eq $null) {
            $rg = New-AzResourceGroup `
                -Name $("rg-" + $_.MailNickName) `
                -Location $location
        }
    
        $assigned = New-AzRoleAssignment `
            -ObjectId $_.ObjectId `
            -RoleDefinitionId $role.Id `
            -Scope $rg.ResourceId
    }

 

All users are now able to access to Azure resources for the exercise.

 


 

So far, we've walked through how to automatically provision a Power Platform environment for hands-on labs, using PowerShell. Now, if you are going to run a hands-on lab session and need a new environment, simply run the code above. Then, it's all good to go!

 

This article was originally published on Dev Kimchi.

1 Comment
Occasional Contributor

This used to be easier when Learn On Demand managed labs.

%3CLINGO-SUB%20id%3D%22lingo-sub-2263130%22%20slang%3D%22en-US%22%3ESingle-Command%20Power%20Platform%20Hands-on-Lab%20Configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263130%22%20slang%3D%22en-US%22%3E%3CP%3ESuppose%20you%20are%20a%20community%20leader%20or%20an%20instructor%20who%20will%20run%20a%20hands-on%20lab%20session%20for%20%3CA%20href%3D%22https%3A%2F%2Fpowerplatform.microsoft.com%2F%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPower%20Platform%3C%2FA%3E.%20You%20got%20content%20for%20it.%20Now%20it's%20time%20for%20setting%20up%20the%20lab%20environment.%20There%20are%20roughly%20three%20approaches%20for%20the%20preparation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EAsk%20the%20participants%20to%20bring%20their%20existing%20Power%20Platform%20environment%2C%3C%2FLI%3E%0A%3CLI%3EAsk%20the%20participants%20to%20set%20up%20their%20environment%20by%20themselves%2C%20or%3C%2FLI%3E%0A%3CLI%3EThe%20session%20leader%20is%20preparing%20the%20environment%20for%20the%20participants%20to%20use.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEach%20effort%20has%20its%20pros%20and%20cons%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3EThe%20first%20approach%3C%2FSTRONG%3E%20would%20be%20the%20easiest%20and%20the%20most%20convenient%20for%20the%20instructor%20because%20it's%20based%20on%20the%20assumption%20that%20everyone%20is%20ready%20for%20the%20exercise.%20However%2C%20you%20never%20know%20if%20every%20participant%20has%20the%20same%20configurations%20as%20you%20expect.%20It%20really%20depends%20on%20their%20organisation's%20policy.%20After%20all%2C%20you%2C%20as%20the%20session%20leader%2C%20will%20probably%20suffer%20from%20a%20lot%20of%20unexpected%20circumstances.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EThe%20second%20one%3C%2FSTRONG%3E%20can%20be%20convenient%20for%20you%20as%20the%20session%20leader.%20It%20might%20be%20as%20tricky%20as%20the%20first%20approach.%20Delegating%20the%20environment%20set-up%20efforts%20to%20the%20participants%20may%20make%20you%20free%2C%20but%20at%20the%20same%20time%2C%20you%20should%20provide%20an%20instructional%20document%20very%20thoroughly%20and%20carefully.%20Even%20if%20you%20do%20so%2C%20it%20entirely%20depends%20on%20the%20participants'%20capability.%20After%20all%2C%20you%20should%20start%20the%20lab%20session%20by%20confirming%20the%20environment%20set-up%20anyway.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EThe%20last%20option%3C%2FSTRONG%3E%20goes%20to%20you%20as%20the%20session%20leader.%20You%20prepare%20everything%20for%20the%20participants.%20They%20just%20come%2C%20sit%20and%20practice.%20If%20you%20do%20this%20set-up%20by%20hand%2C%20it%20would%20be%20awful.%20You%20will%20not%20want%20to%20do%20that.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETherefore%2C%20as%20a%20hands-on%20lab%20session%20leader%2C%20I'm%20going%20to%20discuss%20how%20to%20automate%20all%20the%20provisioning%20process%20and%20minimise%20human%20intervention%20by%20running%20one%20PowerShell%20script.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3EThe%20PowerShell%20script%20used%20in%20this%20post%20is%20downloadable%20from%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdevkimchi%2FPowerPlatform-Hands-on-Lab-Environment-Automatic-Provsioning%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethis%20GitHub%20repository%3C%2FA%3E.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--494701999%22%20id%3D%22toc-hId--494580970%22%20id%3D%22toc-hId--494701999%22%3EOne-Liner%20Script%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet's%20say%20you%20use%20the%20following%20information%20for%20the%20admin%20account.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ETenant%20Name%3A%3CCODE%3Epowerplatformhandsonlab%3C%2FCODE%3E%3C%2FLI%3E%0A%3CLI%3ETenant%20URL%3A%3CCODE%3Epowerplatformhandsonlab.onmicrosoft.com%3C%2FCODE%3E%3C%2FLI%3E%0A%3CLI%3EAdmin%20E-mail%3A%3CCODE%3Eadmin%40powerplatformhandsonlab.onmicrosoft.com%3C%2FCODE%3E%3C%2FLI%3E%0A%3CLI%3EAdmin%20Password%3A%3CCODE%3EPa%24%24W0rd!%40%23%24%3C%2FCODE%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20this%20information%2C%20how%20can%20you%20set%20up%20the%20lab%20environment%20in%20just%20one%20go%3F%20Here's%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdevkimchi%2FPowerPlatform-Hands-on-Lab-Environment-Automatic-Provsioning%2Fblob%2Fmain%2FAzureAD%2FSet-Environment.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eentire%20script%3C%2FA%3E%20and%20you%20just%20run%20the%20command%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20.%2FSet-Environment.ps1%20%60%0A%20%20%20%20%20%20%20%20-AdminUsername%20%22admin%22%20%60%0A%20%20%20%20%20%20%20%20-AdminPassword%20%22Pa%60%24%60%24W0rd!%40%23%60%24%22%20%60%0A%20%20%20%20%20%20%20%20-TenantName%20%22powerplatformhandsonlab%22%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWait%2C%20what%3F%20What's%20going%20on%3F%20Here's%20the%20magic.%20Let's%20find%20them%20together.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1992810834%22%20id%3D%22toc-hId-1992931863%22%20id%3D%22toc-hId-1992810834%22%3ECreate%20Microsoft%20365%20Tenant%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20step%20to%20do%20as%20the%20session%20leader%20is%20to%20create%20a%20%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fmicrosoft-365%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20365%3C%2FA%3E%20tenant.%20Microsoft%20365%20offers%20a%20free%20trial%20for%2030%20days.%20It%20includes%2025%20seats%2C%20including%20the%20admin%20account%2C%20which%20is%20suitable%20for%20the%20lab.%20Click%20this%20link%2C%20%3CA%20href%3D%22http%3A%2F%2Faka.ms%2FOffice365E5Trial%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Faka.ms%2FOffice365E5Trial%3C%2FA%3E%2C%20and%20create%20the%20Microsoft%20365%20E5%20plan's%20trial%20tenant.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F04%2Fautomatic-provisioning-power-platform-hands-on-labs-environment-01-en.png%22%20border%3D%220%22%20alt%3D%22Microsoft%20365%20E5%20Trial%20Landing%20Page%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20filling%20out%20the%20form%20below%2C%20you%20get%20the%20trial%20tenant!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F04%2Fautomatic-provisioning-power-platform-hands-on-labs-environment-02-en.png%22%20border%3D%220%22%20alt%3D%22Microsoft%20365%20E5%20Trial%20Sign-up%20Page%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you've%20got%20a%20new%20tenant%2C%20let's%20configure%20the%20lab%20environment%20in%20PowerShell.%20%3CSTRONG%3EPlease%20note%20that%20you%20HAVE%20TO%20use%20the%20PowerShell%20console%20with%20the%20admin%20privilege%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-185356371%22%20id%3D%22toc-hId-185477400%22%20id%3D%22toc-hId-185356371%22%3EProvisioning%20Order%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20no%20particular%20order%20for%20the%20environment%20provisioning.%20However%2C%20I%20would%20recommend%20following%20this%20order%20because%20there's%20incompatibility%20found%20between%20PowerShell%20modules%20especially%20between%20Power%20Apps%20and%20AzureAD%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EActivate%20Microsoft%20Dataverse%20for%20Power%20Platform%20Default%20Environment%3C%2FLI%3E%0A%3CLI%3EAdd%20User%20Accounts%3C%2FLI%3E%0A%3CLI%3EAssign%20Microsoft%20365%20Roles%20to%20Accounts%3C%2FLI%3E%0A%3CLI%3EAssign%20Microsoft%20365%20Licenses%20to%20Accounts%3C%2FLI%3E%0A%3CLI%3EAssign%20Azure%20Roles%20to%20Accounts%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20do%20the%20Microsoft%20Dataverse%20initialisation%20later%20than%20Azure%20AD%2C%20you%20will%20get%20an%20error.%20I'll%20discuss%20it%20later%20how%20to%20avoid%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20To%20use%20any%20of%20the%20PowerShell%20module%20mentioned%20in%20this%20post%2C%20you%20need%20PowerShell%20v5.1%20running%20on%20Windows.%20PowerShell%20Core%20(v6%20and%20later)%20doesn't%20support%20this%20scenario.%20For%20more%20details%20about%20this%2C%20refer%20to%20this%20page%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fmicrosoft-365%2Fenterprise%2Fconnect-to-microsoft-365-powershell%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EConnect%20to%20Microsoft%20365%20with%20PowerShell%3C%2FA%3E.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1622098092%22%20id%3D%22toc-hId--1621977063%22%20id%3D%22toc-hId--1622098092%22%3EInstall%20AzureAD%20Module%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20add%20a%20new%20user%20account%20to%20a%20Microsoft%20365%20tenant%20through%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FAzureAD%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CCODE%3EAzureAD%3C%2FCODE%3Emodule%3C%2FA%3E.%20As%20of%20this%20writing%2C%20the%20latest%20version%20of%20the%20module%20is%3CCODE%3E2.0.2.130%3C%2FCODE%3E.%20Use%20the%3CCODE%3EInstall-Module%3C%2FCODE%3Ecmdlet%20to%20install%20the%20module.%20If%20you%20append%20these%20two%20parameters%2C%3CCODE%3E-Force%20-AllowClobber%3C%2FCODE%3E(line%20%233)%2C%20it%20always%20installs%20the%20newest%20version%20regardless%20it's%20already%20installed%20or%20not.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20Install-Module%20-Name%20AzureAD%20%60%0A%20%20%20%20%20%20%20%20-Scope%20AllUsers%20-Repository%20PSGallery%20%60%0A%20%20%20%20%20%20%20%20-Force%20-AllowClobber%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-865414741%22%20id%3D%22toc-hId-865535770%22%20id%3D%22toc-hId-865414741%22%3ELog-in%20to%20AzureAD%20as%20Admin%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20installing%20the%20module%2C%20log%20into%20the%20Azure%20AD%20as%20the%20tenant%20admin.%20For%20automation%2C%20you%20should%20stay%20within%20the%20console.%20Therefore%2C%20the%20following%20command%20is%20more%20efficient%20for%20sign-in.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24tenantName%20%3D%20%22powerplatformhandsonlab%22%0A%20%20%20%20%24adminUpn%20%3D%20%22admin%40%24tenantName.onmicrosoft.com%22%0A%20%20%20%20%24adminPW%20%3D%20ConvertTo-SecureString%20%22Pa%60%24%60%24W0rd!%40%23%60%24%22%20-AsPlainText%20-Force%0A%20%20%20%20%24adminCredential%20%3D%20New-Object%20%60%0A%20%20%20%20%20%20%20%20-TypeName%20System.Management.Automation.PSCredential%20%60%0A%20%20%20%20%20%20%20%20-ArgumentList%20(%24adminUpn%2C%20%24adminPW)%0A%20%20%20%20%0A%20%20%20%20%24connected%20%3D%20Connect-AzureAD%20-Credential%20%24adminCredential%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--942039722%22%20id%3D%22toc-hId--941918693%22%20id%3D%22toc-hId--942039722%22%3EAdd%20User%20Accounts%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt's%20time%20to%20add%20user%20accounts.%20As%20the%20trial%20tenant%20includes%2025%20licenses%2C%20you%20can%20add%20up%20to%2024%20accounts.%20For%20more%20details%20to%20add%20a%20new%20user%20account%2C%20refer%20to%20this%20document%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fmicrosoft-365%2Fenterprise%2Fcreate-user-accounts-with-microsoft-365-powershell%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECreate%20Microsoft%20365%20User%20Accounts%20with%20PowerShell%3C%2FA%3E.%20But%20you%20just%20run%20the%20following%20commands.%20Here%20are%20some%20assumptions%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EEach%20user%20has%20the%20same%20password%20of%3CCODE%3EUserPa%24%24W0rd!%40%23%24%3C%2FCODE%3Efor%20convenience%2C%20and%20it's%20not%20allowed%20change%20(line%20%232-4).%3C%2FLI%3E%0A%3CLI%3EEach%20user%20has%20the%20same%20location%20where%20the%20tenant%20resides.%20For%20now%2C%20it's%3CCODE%3EKR%3C%2FCODE%3E(line%20%236).%3C%2FLI%3E%0A%3CLI%3EYou%20need%20to%20create%20up%20to%2024%20accounts%2C%20so%3CCODE%3EForEach-Object%3C%2FCODE%3Eis%20the%20go%20(line%20%239).%3C%2FLI%3E%0A%3CLI%3EAll%20user%20accounts%20created%20are%20added%20to%20the%3CCODE%3E%24users%3C%2FCODE%3Earray%20object%20(line%20%2318).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24userPWProfile%20%3D%20New-Object%20-TypeName%20Microsoft.Open.AzureAD.Model.PasswordProfile%0A%20%20%20%20%24userPWProfile.Password%20%3D%20%22UserPa%60%24%60%24W0rd!%40%23%60%24%22%0A%20%20%20%20%24userPWProfile.EnforceChangePasswordPolicy%20%3D%20%24false%0A%20%20%20%20%24userPWProfile.ForceChangePasswordNextLogin%20%3D%20%24false%0A%20%20%20%20%0A%20%20%20%20%24usageLocation%20%3D%20%22KR%22%0A%20%20%20%20%0A%20%20%20%20%24users%20%3D%20%40()%0A%20%20%20%20(1..24)%20%7C%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20%24user%20%3D%20New-AzureADUser%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-DisplayName%20%24(%22PPUser%22%20%2B%20%24_.ToString(%2200%22))%20-GivenName%20%24(%22User%22%20%2B%20%24_.ToString(%2200%22))%20-SurName%20%22PP%22%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-UserPrincipalName%20%24(%22ppuser%22%20%2B%20%24_.ToString(%2200%22)%20%2B%20%22%40%24tenantName.onmicrosoft.com%22)%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-UsageLocation%20%24usageLocation%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-MailNickName%20%24(%22ppuser%22%20%2B%20%24_.ToString(%2200%22))%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-PasswordProfile%20%24userPWProfile%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-AccountEnabled%20%24true%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%24users%20%2B%3D%20%24user%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1545473111%22%20id%3D%22toc-hId-1545594140%22%20id%3D%22toc-hId-1545473111%22%3EAssign%20Microsoft%20365%20Roles%20to%20User%20Accounts%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20user%20accounts%20need%20to%20have%20appropriate%20Microsoft%20365%20roles.%20As%20it's%20the%20hands-on%20lab%20configuration%2C%20you%20can%20assign%20the%20Power%20Platform%20admin%20role%20to%20each%20user%20account.%20For%20more%20details%20of%20the%20Microsoft%20roles%20assignment%2C%20refer%20to%20this%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fmicrosoft-365%2Fenterprise%2Fassign-roles-to-user-accounts-with-microsoft-365-powershell%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAssign%20Admin%20Roles%20to%20Microsoft%20365%20User%20Accounts%20with%20PowerShell%3C%2FA%3E%20page.%20Run%20the%20following%20command%20to%20activate%20the%20Power%20Platform%20admin%20role.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24roleName%3D%22Power%20Platform%20Administrator%22%0A%0A%20%20%20%20%24role%20%3D%20Get-AzureADDirectoryRole%20%7C%20Where-Object%20%7B%20%24_.DisplayName%20-eq%20%24roleName%20%7D%0A%20%20%20%20if%20(%24role%20-eq%20%24null)%20%7B%0A%20%20%20%20%20%20%20%20%24roleTemplate%20%3D%20Get-AzureADDirectoryRoleTemplate%20%7C%20Where-Object%20%7B%20%24_.DisplayName%20-eq%20%24roleName%20%7D%0A%20%20%20%20%20%20%20%20%24enabled%20%3D%20Enable-AzureADDirectoryRole%20-RoleTemplateId%20%24roleTemplate.ObjectId%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%24role%20%3D%20Get-AzureADDirectoryRole%20%7C%20Where-Object%20%7B%20%24_.DisplayName%20-eq%20%24roleName%20%7D%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20admin%20role%20has%20now%20been%20stored%20in%20the%3CCODE%3E%24role%3C%2FCODE%3Eobject.%20Now%2C%20iterate%20the%3CCODE%3E%24users%3C%2FCODE%3Earray%20to%20assign%20the%20role.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24users%20%7C%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20%24assigned%20%3D%20Add-AzureADDirectoryRoleMember%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-ObjectId%20%24role.ObjectId%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-RefObjectId%20%24_.ObjectId%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--261981352%22%20id%3D%22toc-hId--261860323%22%20id%3D%22toc-hId--261981352%22%3EAssign%20License%20to%20User%20Accounts%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20use%20Power%20Platform%20within%20the%20tenant%2C%20each%20user%20MUST%20have%20a%20license%20for%20it.%20You%20can%20assign%20the%20license%20through%20the%20PowerShell%20command.%20For%20more%20details%2C%20visit%20this%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fmicrosoft-365%2Fenterprise%2Fassign-licenses-to-user-accounts-with-microsoft-365-powershell%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAssign%20Microsoft%20365%20licenses%20to%20user%20accounts%20with%20PowerShell%3C%2FA%3E%20page.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%20of%20all%2C%20let's%20find%20out%20the%20licenses.%20As%20soon%20as%20you%20create%20the%20trial%20tenant%2C%20there%20SHOULD%20be%20only%20one%20license%2C%20whose%20name%20is%3CCODE%3EENTERPRISEPREMIUM%3C%2FCODE%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20Get-AzureADSubscribedSku%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%2C%20run%20the%20following%20command%20to%20assign%20the%20license%20to%20all%20users%20by%20iterating%20the%3CCODE%3E%24users%3C%2FCODE%3Earray.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24sku%20%3D%20Get-AzureADSubscribedSku%0A%0A%20%20%20%20%24license%20%3D%20New-Object%20-TypeName%20Microsoft.Open.AzureAD.Model.AssignedLicense%0A%20%20%20%20%24license.SkuId%20%3D%20%24sku.SkuId%0A%20%20%20%20%0A%20%20%20%20%24licensesToAssign%20%3D%20New-Object%20-TypeName%20Microsoft.Open.AzureAD.Model.AssignedLicenses%0A%20%20%20%20%24licensesToAssign.AddLicenses%20%3D%20%24license%0A%20%20%20%20%0A%20%20%20%20%24users%20%7C%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20%24assigned%20%3D%20Set-AzureADUserLicense%20-ObjectId%20%24_.ObjectId%20-AssignedLicenses%20%24licensesToAssign%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20far%2C%20you've%20completed%20automating%20processes%20to%20create%20a%20trial%20tenant%2C%20create%20user%20accounts%2C%20and%20assign%20roles%20and%20licenses.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--2069435815%22%20id%3D%22toc-hId--2069314786%22%20id%3D%22toc-hId--2069435815%22%3EActivate%20Microsoft%20Dataverse%20for%20Power%20Platform%20Default%20Environment%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPower%20Platform%20internally%20uses%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpowerapps%2Fmaker%2Fdata-platform%2Fdata-platform-intro%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Dataverse%3C%2FA%3E%20as%20its%20database.%20Microsoft%20Dataverse%20is%20fundamentally%20essential%20for%20other%20Microsoft%20365%20services%20to%20use.%20You%20can%20also%20initialise%20it%20through%20PowerShell%20commands.%20For%20more%20details%2C%20visit%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpower-platform%2Fadmin%2Fpowerapps-powershell%3FWT.mc_id%3Dpower-23654-juyoo%23power-apps-cmdlets-for-administrators%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPower%20Apps%20Cmdlets%20for%20Administrators%3C%2FA%3E%20page.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20you%20need%20to%20install%20both%20PowerShell%20modules%2C%20%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoft.PowerApps.Administration.PowerShell%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EMicrosoft.PowerApps.Administration.PowerShell%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FMicrosoft.PowerApps.PowerShell%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EMicrosoft.PowerApps.PowerShell%3C%2FA%3E.%20Like%20the%20previous%20installation%20process%2C%20use%20the%3CCODE%3E-Force%20-AllowClobber%3C%2FCODE%3Eoption%20to%20install%20the%20modules%20or%20reinstall%20both%20if%20they%20already%20exist%20(line%20%233%2C%207).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20Install-Module%20-Name%20Microsoft.PowerApps.Administration.PowerShell%20%60%0A%20%20%20%20%20%20%20%20-Scope%20AllUsers%20-Repository%20PSGallery%20%60%0A%20%20%20%20%20%20%20%20-Force%20-AllowClobber%0A%0A%20%20%20%20Install-Module%20-Name%20Microsoft.PowerApps.PowerShell%20%60%0A%20%20%20%20%20%20%20%20-Scope%20AllUsers%20-Repository%20PSGallery%20%60%0A%20%20%20%20%20%20%20%20-Force%20-AllowClobber%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELog%20into%20the%20Power%20Apps%20admin%20environment%2C%20using%3CCODE%3E%24adminUpn%3C%2FCODE%3Eand%3CCODE%3E%24adminPW%3C%2FCODE%3Evalues.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24connected%20%3D%20Add-PowerAppsAccount%20-Username%20%24adminUpn%20-Password%20%24adminPW%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20You%20might%20not%20be%20able%20to%20log%20into%20the%20Power%20Apps%20admin%20environment%20with%20the%20following%20error.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F04%2Fautomatic-provisioning-power-platform-hands-on-labs-environment-03-en.png%22%20border%3D%220%22%20alt%3D%22Unable%20to%20Login%20to%20Power%20Apps%20Environment%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt's%20because%20the%20internal%20log-in%20process%20for%20both%20Microsoft%20365%20tenant%20and%20Power%20Apps%20environment%20are%20different%20from%20each%20other.%20If%20it%20happens%20to%20you%2C%20don't%20panic.%20Just%20open%20a%20new%20PowerShell%20console%20with%20an%20admin%20privilege%20and%20attempt%20to%20log%20in.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20are%20some%20assumptions%20for%20the%20Microsoft%20Dataverse%20initialisation%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EInitialise%20Microsoft%20Dataverse%20on%20the%20default%20environment%20(line%20%231)%2C%3C%2FLI%3E%0A%3CLI%3EFollow%20the%20currency%20settings%20of%20the%20default%20environment%20(line%20%235)%2C%20and%3C%2FLI%3E%0A%3CLI%3EFollow%20the%20language%20settings%20of%20the%20default%20environment%20(line%20%2310).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24paenv%20%3D%20Get-AdminPowerAppEnvironment%20-Default%0A%20%20%20%20if%20(%24paenv.CommonDataServiceDatabaseProvisioningState%20-ne%20%22Succeeded%22)%20%7B%0A%20%20%20%20%20%20%20%20%24currency%20%3D%20Get-AdminPowerAppCdsDatabaseCurrencies%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-LocationName%20%24paenv.Location%20%7C%20Where-Object%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24_.IsTenantDefaultCurrency%20-eq%20%24true%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%24language%20%3D%20Get-AdminPowerAppCdsDatabaseLanguages%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-LocationName%20%24paenv.Location%20%7C%20Where-Object%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24_.IsTenantDefaultLanguage%20-eq%20%24true%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%24activated%20%3D%20New-AdminPowerAppCdsDatabase%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-EnvironmentName%20%24paenv.EnvironmentName%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-CurrencyName%20%24currency.CurrencyName%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-LanguageName%20%24language.LanguageName%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-418077018%22%20id%3D%22toc-hId-418198047%22%20id%3D%22toc-hId-418077018%22%3EAssign%20Azure%20Subscription%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBuilding%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fconnectors%2Fcustom-connectors%2F%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecustom%20connectors%3C%2FA%3E%20is%20inevitable%20while%20using%20Power%20Platform.%20In%20this%20case%2C%20you%20might%20need%20to%20handle%20resources%20on%20Azure%2C%20which%20requires%20an%20Azure%20subscription.%20If%20you%20create%20the%20trial%20tenant%20for%20Microsoft%20365%2C%20you%20can%20also%20activate%20the%20trial%20Azure%20subscription.%20As%20it%20requires%20credit%20card%20verification%2C%20it%20MUST%20be%20done%20within%20Azure%20Portal.%20If%20you%20log%20into%20Azure%20Portal%20with%20your%20admin%20account%2C%20you%20can%20see%20the%20following%20screen.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F04%2Fautomatic-provisioning-power-platform-hands-on-labs-environment-04-en.png%22%20border%3D%220%22%20alt%3D%22Azure%20Subscription%20Trial%20Page%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EClick%20the%20%3CSTRONG%3EStart%3C%2FSTRONG%3E%20button%20to%20sign-up%20for%20the%20trial%20subscription.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F04%2Fautomatic-provisioning-power-platform-hands-on-labs-environment-05-en.png%22%20border%3D%220%22%20alt%3D%22Azure%20Subscription%20Trial%20Sign-up%20Page%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20completing%20the%20trial%20subscription%2C%20log%20in%20to%20Azure%20using%20the%20PowerShell%20command%20below.%20The%3CCODE%3E%24adminCredential%3C%2FCODE%3Eobject%20is%20the%20same%20one%20used%20for%20Azure%20AD%20log-in.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24connected%20%3D%20Connect-AzAccount%20-Credential%20%24adminCredential%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20You%20SHOULD%20install%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FAz%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EAz%3C%2FA%3E%20module%20beforehand.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20Install-Module%20-Name%20Az%20-Scope%20AllUsers%20-Repository%20PSGallery%20-Force%20-AllowClobber%0A%3C%2FPRE%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnly%20a%20limited%20number%20of%20resources%20are%20available%20in%20the%20trial%20subscription.%20For%20custom%20connectors%2C%20mainly%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Flogic-apps%2Flogic-apps-overview%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Logic%20Apps%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstorage%2F%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAsture%20Storage%20Account%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fvirtual-network%2Fvirtual-networks-overview%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Virtual%20Network%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fapi-management%2Fapi-management-key-concepts%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20API%20Management%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcosmos-db%2Fintroduction%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Cosmos%20DB%3C%2FA%3E%20are%20supposed%20to%20use.%20Therefore%2C%20to%20use%20those%20resources%2C%20run%20the%20following%20command%20to%20register%20those%20resource%20providers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24namespaces%20%3D%20%40(%0A%20%20%20%20%20%20%20%20%22Microsoft.Logic%22%2C%0A%20%20%20%20%20%20%20%20%22Microsoft.Storage%22%2C%0A%20%20%20%20%20%20%20%20%22Microsoft.Network%22%2C%0A%20%20%20%20%20%20%20%20%22Microsoft.ApiManagement%22%2C%0A%20%20%20%20%20%20%20%20%22Microsoft.DocumentDB%22%0A%20%20%20%20)%0A%20%20%20%20%0A%20%20%20%20%24namespaces%20%7C%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20%24provider%20%3D%20Get-AzResourceProvider%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-ProviderNamespace%20%24_%20%7C%20Where-Object%20%7B%20%24_.RegistrationState%20-eq%20%22Registered%22%20%7D%0A%20%20%20%20%20%20%20%20if%20((%24provider%20-eq%20%24null)%20-or%20(%24provider.Count%20-eq%200))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24registered%20%3D%20Register-AzResourceProvider%20-ProviderNamespace%20%24_%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%2C%20assign%20the%20subscription%20to%20each%20user%20account.%20For%20Azure%20Roles%2C%20visit%20this%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Frole-based-access-control%2Frole-assignments-powershell%3FWT.mc_id%3Dpower-23654-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAssign%20Azure%20Roles%20Using%20Azure%20PowerShell%3C%2FA%3E%20page%20for%20more%20details.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20Instead%20of%20scoping%20the%20entire%20subscription%20to%20each%20user%20account%2C%20it's%20better%20to%20create%20a%20resource%20group%20for%20each%20user%2C%20scope%20to%20the%20resource%20group%20and%20assign%20it%20to%20each%20account.%20For%20the%20resource%20group%2C%20you%20need%20a%20location.%20In%20this%20example%2C%3CCODE%3Ekoreacentral%3C%2FCODE%3Eis%20used.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24role%20%3D%20Get-AzRoleDefinition%20%7C%20Where-Object%20%7B%20%24_.Name%20-eq%20%22Contributor%22%20%7D%0A%20%20%20%20%24location%20%3D%20%22koreacentral%22%0A%20%20%20%20%0A%20%20%20%20%24users%20%7C%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20%24rg%20%3D%20Get-AzResourceGroup%20%7C%20Where-Object%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24_.ResourceGroupName%20-eq%20%24(%22rg-%22%20%2B%20%24_.MailNickName)%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%20(%24rg%20-eq%20%24null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24rg%20%3D%20New-AzResourceGroup%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-Name%20%24(%22rg-%22%20%2B%20%24_.MailNickName)%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-Location%20%24location%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%24assigned%20%3D%20New-AzRoleAssignment%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-ObjectId%20%24_.ObjectId%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-RoleDefinitionId%20%24role.Id%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20-Scope%20%24rg.ResourceId%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAll%20users%20are%20now%20able%20to%20access%20to%20Azure%20resources%20for%20the%20exercise.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20far%2C%20we've%20walked%20through%20how%20to%20automatically%20provision%20a%20Power%20Platform%20environment%20for%20hands-on%20labs%2C%20using%20PowerShell.%20Now%2C%20if%20you%20are%20going%20to%20run%20a%20hands-on%20lab%20session%20and%20need%20a%20new%20environment%2C%20simply%20run%20the%20code%20above.%20Then%2C%20it's%20all%20good%20to%20go!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3EThis%20article%20was%20originally%20published%20on%20%3CA%20href%3D%22https%3A%2F%2Fdevkimchi.com%2F2021%2F04%2F09%2Fautomatic-provisioning-power-platform-hands-on-labs-environment%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EDev%20Kimchi%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2263130%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22automatic-provisioning-power-platform-hands-on-labs-environment-00.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271414i61D7B21B597E0329%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22automatic-provisioning-power-platform-hands-on-labs-environment-00.png%22%20alt%3D%22Teacher%20with%20Students%20in%20a%20Hands-on%20Lab%20Session%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ETeacher%20with%20Students%20in%20a%20Hands-on%20Lab%20Session%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThis%20post%20discusses%20how%20to%20automate%20environment%20provisioning%20for%20Power%20Platform%20hands-on%20labs%20for%20session%20leaders.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2263130%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPower%20Platform%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2279570%22%20slang%3D%22en-US%22%3ERe%3A%20Single-Command%20Power%20Platform%20Hands-on-Lab%20Configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2279570%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20used%20to%20be%20easier%20when%20Learn%20On%20Demand%20managed%20labs.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Co-Authors
Version history
Last update:
‎Apr 11 2021 05:00 PM
Updated by: