Skip to content

Instantly share code, notes, and snippets.

@robertosljunior
Last active October 18, 2022 17:16
Show Gist options
  • Save robertosljunior/278dcaccf81b7b6694e888a7b52d7b76 to your computer and use it in GitHub Desktop.
Save robertosljunior/278dcaccf81b7b6694e888a7b52d7b76 to your computer and use it in GitHub Desktop.
Function Get-LocalPowerBIPorts {
$obj=@()
Foreach($p In (Get-Process -Name "PBIDesktop" -ErrorAction Ignore | `
select Id, ProcessName, mainWindowTitle)) {
$properties = @{ 'PID'=$p.Id;
'ProcessName'=$p.ProcessName
'Title'=$p.mainWindowTitle
'Port'=( get-nettcpconnection -OwningProcess ([int]$p.Id) | Where-Object { ($_.State -eq "Established") -and ($_.RemotePort -ne "443") } | Select-Object remoteport -Unique ).remoteport
}
$psobj = New-Object -TypeName psobject -Property $properties
$obj+=$psobj
}
return $obj
}
#Get-LocalPowerBIPorts
Export-ModuleMember -Function Get-LocalPowerBIPorts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment