From 8f50cab07f7a2fbf8421933bf11b5f7cb2d1a4d0 Mon Sep 17 00:00:00 2001 From: Mark Kuschel Date: Tue, 14 Oct 2025 16:15:24 +0200 Subject: [PATCH] Replace byte array file writing with OutFile Parameter --- .../CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 index 54285ce..4520657 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 @@ -135,15 +135,15 @@ function Out-RsRestCatalogItemId try { - Write-Verbose "Downloading item content from server..." + Write-Verbose "Downloading item content from server and writing to $destinationFilePath......" $url = [string]::Format($catalogItemContentApi, $itemId) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -UseBasicParsing -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -UseBasicParsing -Verbose:$false -OutFile $destinationFilePath } else { - $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -UseBasicParsing -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -UseBasicParsing -Verbose:$false -OutFile $destinationFilePath } } catch @@ -151,8 +151,6 @@ function Out-RsRestCatalogItemId throw (New-Object System.Exception("Error while downloading $($RsItemInfo.Name)! Exception: $($_.Exception.Message)", $_.Exception)) } - Write-Verbose "Writing content to $destinationFilePath..." - [System.IO.File]::WriteAllBytes($destinationFilePath, $response.Content) Write-Verbose "$($RsItemInfo.Path) was downloaded to $destinationFilePath successfully!" } }