Forum Discussion
Power BI Auto Login
- Anonymous10 years ago
AUaero Just checking around the web it appears that you could script something to auto log in, but I'm not going to recommend anything as I've never done it and it deals with areas I'm unfamiliar with. If you can get a process to kick off and log in to Power BI, you can set a particular dashboard as your favorite and that will always show up after log in.. but I'm not aware of being able to navigate to a particular report.
If you have a report page, you could pin the report page to a dashboard and make that your favorite, which might get you close to what you want... no garauntee's though.
This code isn't in production any more, so I can't assure you that it still works, but this is what we used in 2017.
<#*****************************************************************************
This script will launch a report on powerbi.com. After
opening the report, the script sets focus to IE, brings the IE window to the
foreground, and sets the powerbi app to full screen mode.
This script will not function if powerbi.com has not been previously opened
on the computer the the script is ran on with the option for the app to
remember the current username.
*******************************************************************************#>
# Set report URL
$URL = <Your_Report_URL_Here>
# 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.Body.getElementsByClassName('glyphicon glyph-small pbi-glyph-fullscreen') | Select-Object -first 1
$fs.click()Apparently the message board software interprets a colon followed by an "S" as a smiley face.
The part with the smiley should be
$handles|%{[win32]::SetForegroundWindow($_)}