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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors