Property ​​value of Power Apps controls / Valeur des propriétés des contrôles Power Apps

Understand the value of Power Apps controls with PowerShell

PowerShell script to automatically retrieve the property ​​value of Power Apps controls.

PowerShell cmdlets

Firstly, PowerShell cmdlets can help you automate many of the monitoring, management, and quality assurance tasks that are only possible manually today in Power Apps or the Power Apps Admin center.

Secondly, you can use PowerShell cmdlets Get-PowerApp for apps and Get-Flow for flows to retrieve the resource ID and type.

Thirdly, you can also run cmdlets to interact with your Business Application Platform without having to go through the admin portal in a web browser.

Examples of tasks

Here are some examples of tasks that can be automated with PowerShell cmdlets in Power Apps:

  • User management
  • CI/CD
  • Managing cloud resources
  • Monitoring and management tasks

CI/CD stands for Continuous Integration/Continuous Deployment.

It is a set of practices that combines continuous integration and continuous delivery/deployment.

The goal of CI/CD is to provide a framework for developers to integrate their code changes into a shared repository frequently and automatically.

This helps to detect problems early and ensure that the code is always in a releasable state

Property ​​value of Power Apps controls

Property ​​value of Power Apps controls
Property ​​value of Power Apps controls

A CSV file is generated with all the properties and their value.

To make this script work properly, the Power Apps application must be registered locally on the computer: File > Save As > This Computer.

This program is not recursive. It stops at two levels: screens and 1st level controls. Controls that are grouped, datacards, controls inside galleries and so on are therefore not supported in this release.

The new version developed by Joël Kolly is recursive: https://github.com/jolscr/PowerAppsControlsPropertyValue/blob/main/Get-PropertyValue_PowerAppsControls.

<#
MAKE A BACKUP OF YOUR DATA BEFORE STARTING THE PROGRAM!
Use at your own risk.
Remember: Set-ExecutionPolicy RemoteSigned
#>

Clear-Host

# Personal settings
$importPath = "directory_where_you_saved_your_msapp"
# e.g.: "C:\Scripts\msapp"
$exportPath = "directory_where_csv_file_will_be_stored"
# e.g.: "C:\Scripts\controls"
$appName = "name_of_your_app_file_once_it_is_saved_w/o_extension_msapp"
# e.g.: "HelloWorld"

# Calculated settings and others
$exportFile = "$exportPath\$appName.csv"
$allObjects = @()

# Deletion of previous results from previous runs
if (test-path $exportfile) {
Remove-Item -path $exportfile}
if (Test-Path "$importPath\$appName.zip") {
Remove-Item -path "$importPath\$appName.zip"}
if (Test-Path "$importPath\$appName.expand") {
Remove-Item -path "$importPath\$appName.expand" -Recurse}

# Check the existence of the file "$importPath\$appName.msapp"
if (!(Test-Path "$importPath\$appName.msapp")) {
Write-Host "[HALT] $($MyInvocation.MyCommand.Name) Missing file:'$importPath\$appName.msapp' - Program stop with error $($MyInvocation.MyCommand.Name) " -ForegroundColor Red ;Sleep 3600;exit;}

# Unzip the compressed file
Copy-Item "$importPath\$appName.msapp" "$importPath\$appName.zip" -force
Expand-Archive -LiteralPath "$importPath\$appName.zip" -DestinationPath "$importPath\$appName.expand"

# Creation of the export folder
if (-not(test-path -path $exportPath)) {
New-Item $exportPath -type directory -force}

# Creation of the export CSV file
Get-ChildItem "$importPath\$appName.expand\Controls" -Name | ForEach-Object {
    $importFile = "$importPath\$appName.expand\Controls\$_"
    $json = (Get-Content $importfile -Raw) | ConvertFrom-Json
    $type = $json.TopParent | where { $_.Type -eq "ControlInfo" } 
    $rules = $type.Rules | Select-Object Property, InvariantScript
    $rules | ForEach-Object {
    $allObjects += [pscustomobject]@{
        AppScreen = $appName
        ScreenControl = $type.Name
        Property = $_.Property
        Value = $_.InvariantScript
        }
    $children = $type.Children | where { $_.Type -eq "ControlInfo" } 
    # Children of TopParent
    foreach ($child in $children) {
        $rules = $child.Rules | Select-Object Property, InvariantScript
        $rules | ForEach-Object {
        $allObjects += [pscustomobject]@{
            AppScreen = $type.Name
            ScreenControl = $child.Name
            Property = $_.Property
            Value = $_.InvariantScript
            }
        }
    }
}

$allObjects | Export-Csv -Path $exportfile -NoTypeInformation -Delimiter ";" -Encoding UTF8 -Append

# Open explorer
Invoke-Item $exportPath

In the CSV file, you will find properties that are not currently exposed by default in the Power Apps designer.

For example, the CalendarHeaderFill property of the Calendar control.

You can find the same post in french https://questcequecest.com/script-powershell-pour-recuperer-automatiquement-la-valeur-des-proprietes-des-controles-power-apps/.

Commentaires

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *