Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AUaero
Responsive Resident
Responsive Resident

Automate opening Power BI report via Powershell

I'm posting this in case someone has a similar requirement and finds this useful.  

 

We have a requirement to display KPIs on large monitors in a warehouse environment.  We installed monitors and PCs and set the PCs to auto logon after bootup.  After the user is logged on, the following Powershell script runs to open the KPI report in IE and set Power BI to full screen.  We didn't attempt to script login to Power BI, so you'll need to make sure Power BI is set to remember the current user credentials before using this script.

 

 

# Set report URL
$URL = "https://app.powerbi.com/" #replace this URL with a direct URL to the report you want to open

 

# Open an IE window and navigate to the URL
$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.FullScreen = $true
$ie.navigate($URL)

 

# Wait on IE to load page
while ($ie.Busy -eq $true)
{
Start-Sleep -Milliseconds 100
}

 

# Bring IE to the foreground
$code=@'
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

static public class Win32{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static public extern bool SetForegroundWindow(IntPtr hWnd);
}
'@
Add-Type $code

$handles=(get-process iexplore).MainWindowHandle
$handles|%{[win32]::SetForegroundWindow($_)}

 

# Set Power BI Fullscreen
$fs = $ie.Document.DocumentElement.getElementsByClassName('glyphicon glyph-small pbi-glyph-fullscreen') | Select-Object -first 1
$fs.click()

 

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors