Get all Power Apps by Summary
Clear-Host
#Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
#Add-PowerAppsAccount
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
Set-Location -Path $scriptPath
$AppRoleAssignmentsFilePath = ".\Apps.csv"
try { Remove-Item $AppRoleAssignmentsFilePath } catch{}
# Add the header to the app roles csv file
$appRoleAssignmentsHeaders = "EnvironmentName," `
+ "AppName," `
+ "AppDisplayName," `
+ "Description," `
+ "AppType," `
+ "UsesOnPremiseGateway," `
+ "UsesPremiumApi," `
+ "UsesCustomApi," `
+ "SharedUsers," `
+ "SharedGroups," `
+ "SharedWithTenant," `
+ "CreatedTime," `
+ "LastModifiedTime," `
+ "AppOwnerObjectId," `
+ "AppOwnerDisplayName," `
+ "AppOwnerDisplayEmail," `
+ "AppOwnerUserPrincipalName," `
+ "AppConnections";
Add-Content -Path $AppRoleAssignmentsFilePath -Value $appRoleAssignmentsHeaders
#populate the app files
$apps = Get-AdminPowerApp
foreach($app in $apps)
{
#Get the details around who created the app
$AppEnvironmentName = $app.EnvironmentName
$Name = $app.AppName
$DisplayName = $app.displayName -replace '[,]'
$OwnerObjectId = $app.owner.id
$OwnerDisplayName = $app.owner.displayName -replace '[,]'
$OwnerDisplayEmail = $app.owner.email
$CreatedTime = $app.CreatedTime
$LastModifiedTime = $app.LastModifiedTime
$Description = $app.Internal.properties.description -replace '[,]'
$AppType = $app.Internal.appType
$UsesOnPremiseGateway = $app.Internal.properties.usesOnPremiseGateway
$UsesPremiumApi = $app.Internal.properties.usesPremiumApi
$UsesCustomApi = $app.Internal.properties.usesCustomApi
Write-Host $DisplayName
if (-not [string]::IsNullOrWhiteSpace($OwnerObjectId))
{
$userOrGroupObject = Get-UsersOrGroupsFromGraph -ObjectId $OwnerObjectId
$OwnerUserPrincipalName = $userOrGroupObject.UserPrincipalName
}
$SharedUsers = $app.Internal.properties.sharedUsersCount
$SharedGroups = $app.Internal.properties.sharedGroupsCount
#Get the list of connections for the app
$connectionList = ""
foreach($conRef in $app.Internal.properties.connectionReferences)
{
foreach($connection in $conRef)
{
foreach ($connId in ($connection | Get-Member -MemberType NoteProperty).Name)
{
$connDetails = $($connection.$connId)
$connDisplayName = $connDetails.displayName -replace '[,]'
$connIconUri = $connDetails.iconUri
$isOnPremiseConnection = $connDetails.isOnPremiseConnection
$connId = $connDetails.id
$connectionList += $connDisplayName + "; "
}
}
}
$appRoles = ($app | Get-AdminPowerAppRoleAssignment)
$SharedWithTenant = 'No'
foreach($appRole in $appRoles)
{
If($appRole.PrincipalType -eq "Tenant")
{
$SharedWithTenant = 'Yes'
break
}
}
$CreatedTime = $app.CreatedTime
$LastModifiedTime = $app.LastModifiedTime
# Write this permission record
$row = $AppEnvironmentName + "," `
+ $Name + "," `
+ $DisplayName + "," `
+ $Description + "," `
+ $AppType + "," `
+ $UsesOnPremiseGateway + "," `
+ $UsesPremiumApi + "," `
+ $UsesCustomApi + "," `
+ $SharedUsers + "," `
+ $SharedGroups + "," `
+ $SharedWithTenant + "," `
+ $CreatedTime + "," `
+ $LastModifiedTime + "," `
+ $OwnerObjectId + "," `
+ $OwnerDisplayName + "," `
+ $OwnerDisplayEmail + "," `
+ $OwnerUserPrincipalName + "," `
+ $connectionList;
Add-Content -Path $AppRoleAssignmentsFilePath -Value $row
}
No comments:
Post a Comment