C’est un script PowerShell pour récupérer automatiquement la valeur des propriétés des contrôles Power Apps.

Un fichier CSV est généré avec toutes les propriétés et leur valeur.
Pour que ce script fonctionne correctement, l’application Power Apps doit être enregistrée localement sur l’ordinateur en allant dans Fichier > Enregistrer sous > Cet ordinateur.
Ce programme n’est pas récursif. Il n’exploite que deux niveaux : les écrans et les contrôles de 1er niveau. Cela signifie que les contrôles groupés, les cartes de données, les contrôles à l’intérieur des galeries, etc. ne sont pas pris en charge dans cette version.
La nouvelle version développée par Joël Kolly est récursive : https://github.com/jolscr/PowerAppsControlsPropertyValue/blob/main/Get-PropertyValue_PowerAppsControls.
<#
FAITES UNE SAUVEGARDE DE VOS DONNÉES AVANT DE DÉMARRER LE PROGRAMME !
À utiliser à vos risques et périls.
Rappelez-vous : Set-ExecutionPolicy RemoteSigned
#>
Clear-Host
# Paramètres personnels
$importPath = "directory_where_you_saved_your_msapp"
# par exemple : "C:\Scripts\msapp"
$exportPath = "directory_where_csv_file_will_be_stored"
# par exemple : "C:\Scripts\controls"
$appName = "name_of_your_app_file_once_it_is_saved_w/o_extension_msapp"
# par exemple : "HelloWorld"
# Paramètres calculés et autres
$exportFile = "$exportPath\$appName.csv"
$allObjects = @()
# Suppression des résultats des exécutions précédentes
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}
# Vérifier l'existence du fichier "$importPath\$appName.msapp"
if (!(Test-Path "$importPath\$appName.msapp")) {
Write-Host "[HALT] $($MyInvocation.MyCommand.Name) Missing file:'$importPath\$appName.msapp' -Arrêt du programme avec erreur $($MyInvocation.MyCommand.Name) " -ForegroundColor Red ;Sleep 3600;exit;}
# Décompresser le fichier compressé
Copy-Item "$importPath\$appName.msapp" "$importPath\$appName.zip" -force
Expand-Archive -LiteralPath "$importPath\$appName.zip" -DestinationPath "$importPath\$appName.expand"
# Créer le dossier d'exportation
if (-not(test-path -path $exportPath)) {
New-Item $exportPath -type directory -force}
# Créer le fichier CSV d'exportation
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
# Ouvrir l'explorateur
Invoke-Item $exportPath
Dans le fichier CSV, vous trouverez des propriétés qui ne sont pas actuellement exposées par défaut dans le concepteur Power Apps.
Par exemple, la propriété CalendarHeaderFill du contrôle Calendar.

Laisser un commentaire