Skip to content

Instantly share code, notes, and snippets.

@TinyToons
Forked from guyinacube/Get-PowerBI-DiagPort.ps1
Created August 17, 2022 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TinyToons/07a7fdd5d6550c3e37e7d08694c1e596 to your computer and use it in GitHub Desktop.
Save TinyToons/07a7fdd5d6550c3e37e7d08694c1e596 to your computer and use it in GitHub Desktop.
Get the Power BI Diagnostic port using PowerShell
#PLEASE OPEN YOUR POWER BI DESKTOP FILE BEFORE RUNNING THIS SCRIPT!!!!!
#Gets a list of teh ProcessIDs for all Open Power BI Desktop files
$processids = Get-Process msmdsrv | Select-Object -ExpandProperty id
#Loops through each ProcessIDs, gets the diagnostic port for each file, and finally generates the connection that can be use when connecting to the Vertipaq model.
if($processids)
{
foreach($processid in $processids)
{
$pbidiagnosticport = Get-NetTCPConnection | ? {($_.State -eq "Listen") -and ($_.RemoteAddress -eq "0.0.0.0") -and ($_.OwningProcess -eq $processid)} | Select-Object -ExpandProperty LocalPort
Write-Host "Enter this into the tool of your choice -- localhost:$pbidiagnosticport" -ForegroundColor Green
}
}
else
{
Write-Host "Please open a Power BI File!" -ForegroundColor Red
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment