Set-PowerAppRoleAssignment-Admin
PowerApps Admin: Sets app role assignment
#Requires -Version 5.1
#Requires -Modules Microsoft.PowerApps.Administration.PowerShell
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[pscredential]$PACredential,
[Parameter(Mandatory = $true)]
[string]$AppName,
[Parameter(Mandatory = $true)]
[string]$PrincipalObjectId,
[Parameter(Mandatory = $true)]
[ValidateSet('CanView', 'CanEdit', 'CanViewWithShare')]
[string]$RoleName,
[string]$EnvironmentName,
[string]$ApiVersion
)
Process {
try {
ConnectPowerApps -PAFCredential $PACredential
$args = @{ ErrorAction = 'Stop'; AppName = $AppName; PrincipalObjectId = $PrincipalObjectId; RoleName = $RoleName }
if ($PSBoundParameters.ContainsKey('EnvironmentName')) { $args.Add('EnvironmentName', $EnvironmentName) }
if ($PSBoundParameters.ContainsKey('ApiVersion')) { $args.Add('ApiVersion', $ApiVersion) }
$result = Set-AdminPowerAppRoleAssignment @args -ErrorAction Stop | Select-Object *
if ($null -ne $result) { $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force }
}
catch { throw }
finally { DisconnectPowerApps }
}PowerApps credentials for authentication
The app identifier
Principal object ID to assign
Role: CanView, CanEdit, CanViewWithShare
The app's environment
API version to call