MSEndpointMgr / IntuneWin32App

Provides a set of functions to manage all aspects of Win32 apps in Microsoft Intune.
MIT License
345 stars 88 forks source link

How to rename/specify the .intunewin file's name before upload? #109

Open rodw-wilkins opened 1 year ago

rodw-wilkins commented 1 year ago

I have the same issue as listed here, but the fix wasn't mentioned. Even if I specify a renamed file for the cmdlet, it still uses the default name.

https://github.com/MSEndpointMgr/IntuneWin32App/issues/47#issue-1328886260

I think it has something to do with the metadata but I'm not sure how to override this?

My organization process requires I number this file. Thanks for any assistance you can provide.

NickolajA commented 1 year ago

It's essentially because I've set it to use the actually encrypted .intunewin file's name:

image

Would you like to simply take the actual file name instead?

rodw-wilkins commented 1 year ago

It's essentially because I've set it to use the actually encrypted .intunewin file's name:

image

Would you like to simply take the actual file name instead?

I’m thinking maybe just add a parameter (for example -CustomName) that can override it?  (Nothing wrong with allowing it to use the name specified in the .xml by default, but not sure of any other way to change this value). Using the actual filename by default is also ok, so another possibility may be to use a parameter flag (-EncryptedName) to use the internal name in the intunewin file (instead of the current default behavior).   So I guess whichever is easier and doesn’t deviate from the current model more than necessary. In any case, thank you, it’s very much appreciated!

obuolinis commented 3 weeks ago

Also noticed that all intunewin packages get uploaded as "IntunePackage.intunewin" whereas I'd like them to have custom names. Started looking into the Add-IntuneWin32App.ps1 function code and I see this: https://github.com/MSEndpointMgr/IntuneWin32App/blob/21b0c09691d864f30a00d611f568a6fde10b7afb/Public/Add-IntuneWin32App.ps1#L540-L553

Specifically line 548: it takes the name of the original intunewin file and passes it as part of MS Graph request body a few lines later: https://github.com/MSEndpointMgr/IntuneWin32App/blob/21b0c09691d864f30a00d611f568a6fde10b7afb/Public/Add-IntuneWin32App.ps1#L556

However in the end the file gets uploaded as IntunePackage.intunewin nonetheless. Why could that be?

obuolinis commented 2 weeks ago

I tried to trace the intunewin file upload process step by step:

  1. from IntuneWin32App perspective when it's done by a script,
  2. from browser (MS Edge) perspective when it's done manually via Intune.

Scenario 1: the name of the original file features all along up to this line: https://github.com/MSEndpointMgr/IntuneWin32App/blob/21b0c09691d864f30a00d611f568a6fde10b7afb/Public/Add-IntuneWin32App.ps1#L617 ($CommitFileRequest.name still holds the original name) And then after the very last commit request here the file name somehow ends up as IntunePackage.intunewin.

I even tried renaming the expanded IntunePackage.intunewin file before it gets sent to Azure storage - to no avail.

Scenario 2: when done from a browser, all the requests and responses feature the name IntunePackage.intunewin, up to the point when commitFileSuccess gets reported (inclusive). Intune portal even throws a notification that "Upload of IntunePackage.intunewin finished." However the very last PATCH request that the browser does seems to feature all the app properties in the body (contrary to IntuneWin32App), incl fileName. Not sure that's the reason but after this the intunewin file ends up with the original name.

Both scenarios work counterintuitive to what I'd expect, I'm afraid this file name issue is beyond my understanding :(