From a33bde1ea726833de9f8111891df3a0a65bb9ba1 Mon Sep 17 00:00:00 2001 From: dgosbell Date: Mon, 4 Mar 2019 16:06:24 +1100 Subject: [PATCH 1/3] Adding -UseBasicParsing to avoid the need to have IE configured on servers --- .../CatalogItems/Rest/Get-RsRestItemDataSource.ps1 | 8 ++++---- .../Functions/CatalogItems/Rest/New-RsRestFolder.ps1 | 4 ++-- .../CatalogItems/Rest/Out-RsRestCatalogItem.ps1 | 4 ++-- .../CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 | 4 ++-- .../CatalogItems/Rest/Out-RsRestFolderContent.ps1 | 12 ++++++------ .../CatalogItems/Rest/Remove-RsRestCatalogItem.ps1 | 4 ++-- .../CatalogItems/Rest/Remove-RsRestFolder.ps1 | 4 ++-- .../CatalogItems/Rest/Set-RsRestItemDataSource.ps1 | 4 ++-- .../CatalogItems/Rest/Write-RsRestCatalogItem.ps1 | 12 ++++++------ .../CatalogItems/Rest/Write-RsRestFolderContent.ps1 | 4 ++-- .../Functions/Utilities/New-RsRestSession.ps1 | 4 ++-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Get-RsRestItemDataSource.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Get-RsRestItemDataSource.ps1 index c962edb6..94d5700d 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Get-RsRestItemDataSource.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Get-RsRestItemDataSource.ps1 @@ -84,11 +84,11 @@ function Get-RsRestItemDataSource $catalogItemsUri = [String]::Format($catalogItemsUri, $RsItem) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false -UseBasicParsing } $item = ConvertFrom-Json $response.Content @@ -99,11 +99,11 @@ function Get-RsRestItemDataSource if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false -UseBasicParsing } $itemWithDataSources = ConvertFrom-Json $response.Content diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/New-RsRestFolder.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/New-RsRestFolder.ps1 index bec2a369..c05314df 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/New-RsRestFolder.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/New-RsRestFolder.ps1 @@ -91,11 +91,11 @@ function New-RsRestFolder if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false -UseBasicParsing } Write-Verbose "Folder $TargetFolderPath was created successfully!" diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItem.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItem.ps1 index b20a0cad..0adae309 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItem.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItem.ps1 @@ -114,11 +114,11 @@ function Out-RsRestCatalogItem $url = [string]::Format($catalogItemsByPathApi, $item) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false -UseBasicParsing } } catch diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 index 00ae5fec..d1a64502 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 @@ -128,11 +128,11 @@ function Out-RsRestCatalogItemId $url = [string]::Format($catalogItemContentApi, $itemId) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false -UseBasicParsing } } catch diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestFolderContent.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestFolderContent.ps1 index 0a72a34d..f36b76f4 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestFolderContent.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestFolderContent.ps1 @@ -108,11 +108,11 @@ function Out-RsRestFolderContent $url = [string]::Format($catalogItemsByPathApiV1, $RsFolder) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false -UseBasicParsing } } catch @@ -128,11 +128,11 @@ function Out-RsRestFolderContent $url = [string]::Format($folderCatalogItemsApiV1, $folder.Id) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false -UseBasicParsing } } catch @@ -148,11 +148,11 @@ function Out-RsRestFolderContent $url = [string]::Format($folderCatalogItemsApiLatest, $RsFolder) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false -UseBasicParsing } } catch diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestCatalogItem.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestCatalogItem.ps1 index 6487f685..5f6c9c42 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestCatalogItem.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestCatalogItem.ps1 @@ -76,11 +76,11 @@ function Remove-RsRestCatalogItem if ($Credential -ne $null) { - Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -Credential $Credential -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -Credential $Credential -Verbose:$false -UseBasicParsing | Out-Null } else { - Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -UseDefaultCredentials -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -UseDefaultCredentials -Verbose:$false -UseBasicParsing | Out-Null } Write-Verbose "Catalog item $RsItem was deleted successfully!" diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestFolder.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestFolder.ps1 index 344cb0ad..ad3baf4e 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestFolder.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Remove-RsRestFolder.ps1 @@ -76,11 +76,11 @@ function Remove-RsRestFolder if ($Credential -ne $null) { - Invoke-WebRequest -Uri $foldersUri -Method Delete -WebSession $WebSession -Credential $Credential -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $foldersUri -Method Delete -WebSession $WebSession -Credential $Credential -Verbose:$false -UseBasicParsing -UseBasicParsing | Out-Null } else { - Invoke-WebRequest -Uri $foldersUri -Method Delete -WebSession $WebSession -UseDefaultCredentials -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $foldersUri -Method Delete -WebSession $WebSession -UseDefaultCredentials -Verbose:$false -UseBasicParsing -UseBasicParsing | Out-Null } Write-Verbose "Folder $RsFolder was deleted successfully!" diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Set-RsRestItemDataSource.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Set-RsRestItemDataSource.ps1 index e80a1d0d..9211a140 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Set-RsRestItemDataSource.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Set-RsRestItemDataSource.ps1 @@ -235,11 +235,11 @@ function Set-RsRestItemDataSource Write-Verbose "Updating data sources for $($RsItem)..." if ($Credential -ne $null) { - Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -Credential $Credential -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -Credential $Credential -Verbose:$false -UseBasicParsing | Out-Null } else { - Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -UseDefaultCredentials -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -UseDefaultCredentials -Verbose:$false -UseBasicParsing | Out-Null } Write-Verbose "Data sources were updated successfully!" } diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 index 4622f394..61b7c092 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestCatalogItem.ps1 @@ -245,11 +245,11 @@ function Write-RsRestCatalogItem if ($Credential -ne $null) { - Invoke-WebRequest -Uri $catalogItemsUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $catalogItemsUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false -UseBasicParsing | Out-Null } else { - Invoke-WebRequest -Uri $catalogItemsUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $catalogItemsUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false -UseBasicParsing | Out-Null } Write-Verbose "$EntirePath was uploaded to $RsFolder successfully!" @@ -264,11 +264,11 @@ function Write-RsRestCatalogItem $uri = [String]::Format($catalogItemsByPathApi, $itemPath) if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false -UseBasicParsing } # parsing response to get Id @@ -279,11 +279,11 @@ function Write-RsRestCatalogItem $uri = [String]::Format($catalogItemsUpdateUri, $itemId) if ($Credential -ne $null) { - Invoke-WebRequest -Uri $uri -Method Put -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $uri -Method Put -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false -UseBasicParsing | Out-Null } else { - Invoke-WebRequest -Uri $uri -Method Put -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false | Out-Null + Invoke-WebRequest -Uri $uri -Method Put -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false -UseBasicParsing | Out-Null } Write-Verbose "$EntirePath was uploaded to $RsFolder successfully!" } diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestFolderContent.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestFolderContent.ps1 index 09113730..47bf167d 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestFolderContent.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Write-RsRestFolderContent.ps1 @@ -154,11 +154,11 @@ function Write-RsRestFolderContent # Try to get folder info if ($Credential -ne $null) { - $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false + $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false -UseBasicParsing } else { - $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false + $response = Invoke-WebRequest -Uri $uri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false -UseBasicParsing } # parsing response to get folder name diff --git a/ReportingServicesTools/Functions/Utilities/New-RsRestSession.ps1 b/ReportingServicesTools/Functions/Utilities/New-RsRestSession.ps1 index fdbb9af1..f78f62de 100644 --- a/ReportingServicesTools/Functions/Utilities/New-RsRestSession.ps1 +++ b/ReportingServicesTools/Functions/Utilities/New-RsRestSession.ps1 @@ -71,11 +71,11 @@ function New-RsRestSession Write-Verbose "Making call to $meUri to create a session..." if ($Credential) { - $result = Invoke-WebRequest -Uri $meUri -Credential $Credential -SessionVariable mySession -Verbose:$false -ErrorAction Stop + $result = Invoke-WebRequest -Uri $meUri -Credential $Credential -SessionVariable mySession -Verbose:$false -ErrorAction Stop -UseBasicParsing } else { - $result = Invoke-WebRequest -Uri $meUri -UseDefaultCredentials -SessionVariable mySession -Verbose:$false -ErrorAction Stop + $result = Invoke-WebRequest -Uri $meUri -UseDefaultCredentials -SessionVariable mySession -Verbose:$false -ErrorAction Stop -UseBasicParsing } if ($result.StatusCode -ne 200) From a1c29ad7e914676fb2dfe6aad548f3a047c06ed9 Mon Sep 17 00:00:00 2001 From: Darren Gosbell Date: Thu, 13 Jun 2019 09:45:55 +1000 Subject: [PATCH 2/3] Warning instead of exception on unsupported extensions --- .../CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 index d1a64502..17c1a07f 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 @@ -82,7 +82,16 @@ function Out-RsRestCatalogItemId if ($RsItemInfo.Type -ne 'MobileReport') { $itemId = $RsItemInfo.Id - $fileName = $RsItemInfo.Name + (Get-FileExtension -TypeName $RsItemInfo.Type) + var $extension = ""; + try { + $extension = (Get-FileExtension -TypeName $RsItemInfo.Type) + } + catch + { + Write-Warning "Unsupported Type: $($RsItemInfo.Type) Unable to export: $($RsItemInfo.Name)" + break; + } + $fileName = $RsItemInfo.Name + $extension } else { From f7ee10f50a324098c57271e0fba78ed5df91d797 Mon Sep 17 00:00:00 2001 From: Darren Gosbell Date: Thu, 13 Jun 2019 13:53:05 +1000 Subject: [PATCH 3/3] fixing bug where accidentally used c# syntax --- .../Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 index 17c1a07f..321da92c 100644 --- a/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 +++ b/ReportingServicesTools/Functions/CatalogItems/Rest/Out-RsRestCatalogItemId.ps1 @@ -82,7 +82,7 @@ function Out-RsRestCatalogItemId if ($RsItemInfo.Type -ne 'MobileReport') { $itemId = $RsItemInfo.Id - var $extension = ""; + $extension = ""; try { $extension = (Get-FileExtension -TypeName $RsItemInfo.Type) }