<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Amend Power Shell Script to save and replace older files with new ones everyday in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Amend-Power-Shell-Script-to-save-and-replace-older-files-with/m-p/3107582#M41495</link>
    <description>&lt;P&gt;Here is the answer if other User or member what to do this see link&lt;/P&gt;&lt;P&gt;&lt;A title="Backup and download PBI Report from Workspaces" href="http:// https://sidequests.blog/2021/02/01/exporting-all-your-power-bi-reports-at-once/" target="_self"&gt;https://sidequests.blog/2021/02/01/exporting-all-your-power-bi-reports-at-once/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll have to do the other POwer Shell work but its a good start&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 10:32:13 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-03-02T10:32:13Z</dc:date>
    <item>
      <title>Amend Power Shell Script to save and replace older files with new ones everyday</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Amend-Power-Shell-Script-to-save-and-replace-older-files-with/m-p/3107338#M41494</link>
      <description>&lt;P&gt;Hi Experts&lt;/P&gt;&lt;P&gt;Totally new to powershell - how can i amend the following code to save the file from specific workspace in Power Bi to folders with the same name as the workspace, every day and delete the older files in the folder with the new files.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script to run at 1.00am everymorning&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Workspace name&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trading&lt;/P&gt;&lt;P&gt;Oil&lt;/P&gt;&lt;P&gt;Stocks&lt;/P&gt;&lt;P&gt;Comm&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Folder name as above&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Set-StrictMode -Version "latest"

$ErrorActionPreference="Stop"

&amp;lt;#

    Download all reports from the specified Power BI Workspace

    Ensure you have called login.ps1

#&amp;gt;




[System.Net.WebRequest]::DefaultWebProxy.Credentials=[System.Net.CredentialCache]::DefaultCredentials




$script:WorkspaceName="Soft Launch Power BI Central Workspace"

$OutputFolder=Join-Path -Path $PSScriptRoot -ChildPath "out"

$Script:Reports=$null

$script:Workspace=$null




function CreateOutputFolder{

    if (Test-Path -Path $OutputFolder)

    {

        Write-Host "The output folder $OutputFolder already exists. Not creating"

        return

    }

    New-Item -ItemType Directory -Path $OutputFolder

    Write-Host "The output folder $OutputFolder was created"

}



function DownloadAllReports{

    foreach ($report in $reports){

        Write-Host "----------------------------"

        Write-Host "Downloading report $($report.name)"

        $downloadPath = Join-Path -Path $OutputFolder -ChildPath "$($report.Name).pbix"

        if (Test-Path -Path $downloadPath){

            Remove-Item -Path $downloadPath

            Write-Host "Deleted report file $downloadPath"

        }

        Export-PowerBIReport -WorkspaceId $Workspace.Id  -Id $report.id -OutFile $downloadPath

        $downloadPath

    }

   

}



function GetListOfReports{

    $script:Workspace=Get-PowerBIWorkspace -Name $script:WorkspaceName

    Write-Host "Going to get all reports in the workspace: $script:WorkspaceName"

    $Script:Reports=Get-PowerBIReport -Workspace $script:Workspace

    Write-Host "Found $($reports.Count) reports in the workspace: $script:WorkspaceName"

   

}




CreateOutputFolder

GetListOfReports

DownloadAllReports&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 08:07:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Amend-Power-Shell-Script-to-save-and-replace-older-files-with/m-p/3107338#M41494</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-02T08:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Amend Power Shell Script to save and replace older files with new ones everyday</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Amend-Power-Shell-Script-to-save-and-replace-older-files-with/m-p/3107582#M41495</link>
      <description>&lt;P&gt;Here is the answer if other User or member what to do this see link&lt;/P&gt;&lt;P&gt;&lt;A title="Backup and download PBI Report from Workspaces" href="http:// https://sidequests.blog/2021/02/01/exporting-all-your-power-bi-reports-at-once/" target="_self"&gt;https://sidequests.blog/2021/02/01/exporting-all-your-power-bi-reports-at-once/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll have to do the other POwer Shell work but its a good start&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 10:32:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Amend-Power-Shell-Script-to-save-and-replace-older-files-with/m-p/3107582#M41495</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-02T10:32:13Z</dc:date>
    </item>
  </channel>
</rss>

