← Files Power BI DesktopARCHIVED FILE

scripts/New-PowerBIRlsRoleDraft.ps1

818 Bytes · Oct 2, 2026 · 00:32 UTC

↓ Download file

param([string]$RoleName = 'Sales Region Access', [string]$TableName, [string]$FilterExpression, [string]$OutputPath, [switch]$Json)
$ErrorActionPreference = 'Stop'
$fence = [string]([char]96) * 3
$tmdl = @(
    "role $RoleName",
    "    tablePermission $TableName = $fence",
    $FilterExpression,
    $fence
) -join [Environment]::NewLine
$result = [pscustomobject]@{ schema = 'codex.powerbi.rlsRoleDraft.v1'; objectType = 'RLSRole'; roleName = $RoleName; tableName = $TableName; filterExpression = $FilterExpression; tmdl = $tmdl; validation = 'Validate with View As Role in Power BI Desktop and service workspace security settings.' }
if ($Json) { $text = $result | ConvertTo-Json -Depth 6; if ($OutputPath) { Set-Content -LiteralPath $OutputPath -Value $text -Encoding UTF8 }; $text; return }
$result

SHA-256: 8844032265351295c9662cd5276547a9aeb7511dd2e49358b0f200ed68fa5927