diff --git a/Private/Invoke-AzureStorageBlobUploadFinalize.ps1 b/Private/Invoke-AzureStorageBlobUploadFinalize.ps1 index 13d47ba..d76e3f3 100644 --- a/Private/Invoke-AzureStorageBlobUploadFinalize.ps1 +++ b/Private/Invoke-AzureStorageBlobUploadFinalize.ps1 @@ -7,17 +7,18 @@ function Invoke-AzureStorageBlobUploadFinalize { Finalize upload of chunks of the .intunewin file into Azure Storage blob container. This is a modified function that was originally developed by Dave Falkus and is available here: - https://github.com/microsoftgraph/powershell-intune-samples/blob/master/LOB_Application/Win32_Application_Add.ps1 + https://github.com/microsoftgraph/powershell-intune-samples/blob/master/LOB_Application/Win32_Application_Add.ps1 .NOTES Author: Nickolaj Andersen Contact: @NickolajA Created: 2020-01-04 - Updated: 2020-01-04 + Updated: 2024-05-29 Version history: 1.0.0 - (2020-01-04) Function created - #> + 1.0.1 - (2024-05-29) Added content-type header to the REST request to ensure correct handling of the request body (thanks to @tjgruber) + #> param( [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] @@ -27,17 +28,25 @@ function Invoke-AzureStorageBlobUploadFinalize { [ValidateNotNullOrEmpty()] [System.Object]$ChunkID ) + $Uri = "$($StorageUri)&comp=blocklist" - $XML = '' - foreach ($Chunk in $ChunkID) { - $XML += "$($Chunk)" - } - $XML += '' - - try { - $WebResponse = Invoke-RestMethod -Uri $Uri -Method "Put" -Body $XML -ErrorAction Stop - } - catch { - Write-Warning -Message "Failed to finalize Azure Storage blob upload. Error message: $($_.Exception.Message)" - } -} \ No newline at end of file + + $XML = '' + + foreach ($Chunk in $ChunkID) { + $XML += "$($Chunk)" + } + + $XML += '' + + $Headers = @{ + "content-type" = "text/plain; charset=UTF-8" + } + + try { + $WebResponse = Invoke-RestMethod -Uri $Uri -Method "Put" -Body $XML -Headers $Headers -ErrorAction Stop + } + catch { + Write-Warning -Message "Failed to finalize Azure Storage blob upload. Error message: $($_.Exception.Message)" + } +}