← Files Power BI DesktopARCHIVED FILE
scripts/New-PowerBIOwnerActionDispatch.ps1
1.62 KB · Oct 2, 2026 · 00:32 UTC
param([Parameter(Mandatory)][string]$ActionListPath,[string]$OutputDirectory='powerbi-owner-action-dispatch',[ValidateSet('Teams','Email','Jira','AzureDevOps')][string]$Destination='Teams',[switch]$Json)
$ErrorActionPreference='Stop';if(-not(Test-Path -LiteralPath $ActionListPath)){throw "ActionListPath not found: $ActionListPath"};$out=$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputDirectory);New-Item -ItemType Directory -Force -Path $out|Out-Null
$input=Get-Content -Raw -LiteralPath $ActionListPath|ConvertFrom-Json;$items=if($input.PSObject.Properties.Name -contains 'items'){@($input.items)}elseif($input.PSObject.Properties.Name -contains 'actions'){@($input.actions)}elseif($input.PSObject.Properties.Name -contains 'exceptions'){@($input.exceptions)}else{@()}
$drafts=@($items|Where-Object {$_.status -ne 'OnTrack'}|ForEach-Object {[pscustomobject]@{destination=$Destination;owner=if($_.owner){$_.owner}else{'Unassigned'};title="Power BI action: $(if($_.metricName){$_.metricName}else{$_.exceptionId})";priority=if($_.priority){$_.priority}else{$_.severity};body=if($_.nextAction){$_.nextAction}else{$_.proposedAction};status='DraftOnly';sendBlocked=$true}})
$path=Join-Path $out 'owner-action-drafts.json';$drafts|ConvertTo-Json -Depth 8|Set-Content -LiteralPath $path -Encoding UTF8
$result=[pscustomobject]@{schema='codex.powerbi.ownerActionDispatch.v1';status='DraftsReady';destination=$Destination;draftCount=$drafts.Count;draftPath=$path;sendBlocked=$true;nextAction='Review, approve, then copy drafts into the chosen ticketing or notification system.'};if($Json){$result|ConvertTo-Json -Depth 8}else{$result}
SHA-256: 05a948677ca3e01fb7ffba31c6a734b62e59efd02a89e210e09cfab48bf39ec1