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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Rohitb
Helper I
Helper I

Open "PowerBI" Desktop using PowerShell

Hello,

I have a requirement where I have to open PowerBI Desktop Application via PowerShell & also open a PBIX File using PowerShell.

Can someone help me with this ?

2 ACCEPTED SOLUTIONS
v-xiaocliu-msft
Community Support
Community Support

Hi @Rohitb ,

 

At my knowledge, we can get path of the .pbix file and open power bi desktop with the .pbix file using powershell.

 

Sample:

$PowerBIFilePath = "C:\*** "

Start-Process -FilePath $PowerBIFilePath

 

Best Regards,

Wearsky

View solution in original post

This PowerShell code opens your Power BI and then saves your PBIX file as a PBIT.
You need to change lines two and three in this code according to your path.

ahadkarimi_1-1723396066882.png

 


ahadkarimi_2-1723396348173.png

 


Add-Type -AssemblyName System.Windows.Forms
$powerBIPath = "C:\Program Files\Microsoft Power BI Desktop RS\bin\PBIDesktop.exe"
$filePath = "C:\Users\Ahadk\OneDrive\Desktop\Working.pbix"

Start-Process $powerBIPath -ArgumentList $filePath
Start-Sleep -Seconds 30
[System.Windows.Forms.SendKeys]::SendWait('%')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('F')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 0.5
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")

View solution in original post

8 REPLIES 8
ahadkarimi
Solution Specialist
Solution Specialist

Open PowerShell:

ahadkarimi_0-1723388404350.png

Place PBIDesktop file path between double quotes, like this:

Start-Process -FilePath "C:\Program Files\Microsoft Power BI Desktop RS\bin\PBIDesktop.exe"

ahadkarimi_4-1723388791727.png

 

ahadkarimi_1-1723388431787.png

for PBIX files:
Place your file path between double quotes, like this:

Start-Process -FilePath "C:\Users\Ahadk\OneDrive\Desktop\test.pbix"

ahadkarimi_3-1723388569010.png

 

 

Hey @ahadkarimi 

Opening the pbix was already stated by @v-xiaocliu-msft . 

The next ask from the user is to save the opened file as another format. 

 

This PowerShell code opens your Power BI and then saves your PBIX file as a PBIT.
You need to change lines two and three in this code according to your path.

ahadkarimi_1-1723396066882.png

 


ahadkarimi_2-1723396348173.png

 


Add-Type -AssemblyName System.Windows.Forms
$powerBIPath = "C:\Program Files\Microsoft Power BI Desktop RS\bin\PBIDesktop.exe"
$filePath = "C:\Users\Ahadk\OneDrive\Desktop\Working.pbix"

Start-Process $powerBIPath -ArgumentList $filePath
Start-Sleep -Seconds 30
[System.Windows.Forms.SendKeys]::SendWait('%')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('F')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 0.5
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{DOWN}')
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
v-xiaocliu-msft
Community Support
Community Support

Hi @Rohitb ,

 

At my knowledge, we can get path of the .pbix file and open power bi desktop with the .pbix file using powershell.

 

Sample:

$PowerBIFilePath = "C:\*** "

Start-Process -FilePath $PowerBIFilePath

 

Best Regards,

Wearsky

Thankyou for your response @v-xiaocliu-msft .

How do I save the PowerBI File as PBIT/PBIP using PowerShell ?

Hi @Rohitb ,

 

I'm afraid that this requirement cannot be easily implemented with PowerShell. This may require programming experience with PowerShell and .NET. As a simple workaround, please try Power Automate Desktop.

Sample:

vxiaocliumsft_0-1722922456789.png

vxiaocliumsft_0-1722922490157.png

You can record your operation steps, such as saving, etc…

 

Best Regards,

Wearsky

@v-xiaocliu-msft  Thankyou for your response.

I have already explored Power Automate way but we want to explore via PowerShell/Python/.Net

Can you please help with either of the 3 coding language ?

I am not sure whether this is even possible because based on MSFT documentation; the only was is for it to be done manually

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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