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

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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

    • Rohitb's avatar
      Rohitb
      Helper I

      Thankyou for your response Anonymous .

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

      • Anonymous's avatar
        Anonymous
        Not applicable

        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:

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

         

        Best Regards,

        Wearsky

  • ahadkarimi's avatar
    ahadkarimi
    Solution Specialist

    Open PowerShell:

    Place PBIDesktop file path between double quotes, like this:

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

     

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

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

     

     

    • NandanHegde's avatar
      NandanHegde
      Super User

      Hey ahadkarimi 

      Opening the pbix was already stated by Anonymous . 

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

       

      • ahadkarimi's avatar
        ahadkarimi
        Solution Specialist
        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}")