microsoftgraph/powershell-intune-samples

Issues with PowerShell 7 (Application_LOB_Add.ps1)

Opened this issue · 0 comments

Most of these scripts were initially built with PowerShell 5 and do not work with PowerShell 7 as-is.

If you find yourself working through this, two key changes you need to make:

  1. Fix the header in UploadAzureStorageChunk to specify the content type as follows:
    $headers = @{
    "x-ms-blob-type" = "BlockBlob"
    "Content-Type" = "text/plain; charset=iso-8859-1"
    };

More detail on this problem covered here: Add-IntuneWin32App.ps1 'CommitFile' failed error with PowerShell 7.4.0 · Issue #128 · MSEndpointMgr/IntuneWin32App (github.com)

  1. Add a Content-Type header to the call to FinalizeAzureStorageUpload
    try
    {
    $headers = @{
    "Content-Type" = "application/json"
    };
    Invoke-RestMethod $uri -Method Put -Body $xml -Headers $headers; }
    catch
    {
    Write-Host -ForegroundColor Red $request;
    Write-Host -ForegroundColor Red $_.Exception.Message;
    throw;
    }