Forum Discussion

Rohitb's avatar
Rohitb
Helper I
2 years ago
Solved

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 ?
  • Anonymous's avatar
    Anonymous
    2 years ago

    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

  • ahadkarimi's avatar
    ahadkarimi
    2 years ago
    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.

     


     


    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}")