vmware-samples / euc-samples

Workspace ONE UEM (previously AirWatch) Samples and Guidance
https://code.vmware.com/web/workspace-one
BSD 3-Clause "New" or "Revised" License
271 stars 148 forks source link

Unable to create an application on the console using powershell script when FileShare is not enabled #268

Closed GMPrakhar closed 1 year ago

GMPrakhar commented 1 year ago

Describe the bug

While using the UploadApp.ps1 script, the script shows a successfully uploaded app but does not appear on the UEM Console, and from the MAM API logs, we can see the Internal server error.

Reproduction steps

  1. Update all the required details on the script for the targetted console and file location.
  2. Disable File Storage on the Console so the application goes to the database.
  3. Run the PowerShell script.

Expected behavior

The application is successfully uploaded to the console and is visible on the UI.

Additional context

The issue is due to the fact that we are first creating a chunk byte array

$chunk = New-Object byte[] $ChunkSize

and then preparing the whole array for upload:

$b64Chunk = [System.Convert]::ToBase64String($chunk)

This would mean that for the last chunk since the data would be almost always less than the $ChunkSize, we are sending trailing empty bytes in the request byte array. This is causing overflow on the server as it is trying to write the trailing bytes to a smaller array.

GMPrakhar commented 1 year ago

PR for the fix : https://github.com/vmware-samples/euc-samples/pull/269