MSEndpointMgr / IntuneAppFactory

Intune App Factory automates Win32 application packaging in Intune.
https://msendpointmgr.com/intune-app-factory
MIT License
36 stars 11 forks source link

Issues with Graph Requests #2

Open rickdm opened 1 year ago

rickdm commented 1 year ago

Initially there was an error thrown by Install-Modules because the MSGraphRequest module required an additional flag to be passed. Now I am receiving another error related to Graph

WARNING: Graph request failed with status code '400 (BadRequest)'. Error details: AuthenticationError - Error 
authenticating with resource
WARNING: Unhandled error occurred, application will be skipped

My Service Principle has the permissions DeviceManagementApps.ReadWrite.All and DeviceManagementRBAC.ReadWrite.All

uevinysses commented 1 year ago

I have a similar issue. Initially I had an error thrown by Install-Modules because the MSGraphRequest module thew up this error "This module 'MSGraphRequest' may override the existing commands. If you still want to install this module 'MSGraphRequest', use -AllowClobber parameter." So I added the -AllowClobber to the script.

I'm now getting an issue when the Test-AppList script runs: "Attempting to find application in Intune WARNING: Unhandled error occurred, application will be skipped"

Unlike the issue reported by rickdm I'm not getting an authentication error. I'm not sure if the Invoke-MSGraphOperation Command is even running on the build agent and I'm unsure how I can see this in the Pipeline logs or test it. Could this be related to the issue that I had in the Install-Modules script?

uevinysses commented 1 year ago

I have managed to resolve my issue.

The unhandled error message was caused because we had no Win32 apps registered in Intune which caused the error in the Test-AppList script. When the Graph query pulled back no results (null) the if statement is set to error.

skyblaster commented 1 year ago

Just in case it's relevant, here's an MSGraph error from my first run.

Starting: Install-Modules
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.220.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
Formatted command: . 'C:\ADOAgent\_work\1\s\Scripts\Install-Modules.ps1'
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\ADOAgent\_work\_temp\c11b2b7e-ee91-489f-8b38-56e161b1789b.ps1'"
Attempting to install the following module: Evergreen
Attempting to install the following module: IntuneWin32App
Attempting to install the following module: MSGraphRequest
PackageManagement\Install-Package : The following commands are already available on this system:'Test-AccessToken'. 
This module 'MSGraphRequest' may override the existing commands. If you still want to install this module 
'MSGraphRequest', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],  
   Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack 
   ageManagement.Cmdlets.InstallPackage

##[error]PowerShell exited with code '1'.
Finishing: Install-Modules
SUBnet192 commented 1 year ago

Fresh install, exact same issue (Install-Modules section fails) with the @skyblaster 's error message. Any insight?

SUBnet192 commented 1 year ago

So adding the AllowClobber parameter to the script made it go further. I expected 7ZIP and Notepad++ to be added to our Intune App repository after execution but no such luck. I do get this warning: Directory 'C:\ADOAgent_work\1\b' is empty. Nothing will be added to build artifact 'AppsDownloadList'.

nithilin1 commented 1 year ago

Also had original issue with the -allowclobber fixing my installing of prerequest items. Should just be pushed to sourcecode. Not recognizing the graph issue though.

nithilin1 commented 1 year ago

So adding the AllowClobber parameter to the script made it go further. I expected 7ZIP and Notepad++ to be added to our Intune App repository after execution but no such luck. I do get this warning: Directory 'C:\ADOAgent_work\1\b' is empty. Nothing will be added to build artifact 'AppsDownloadList'.

Ran into same warning in my testing - mine came from my icon wasnt named "icon.png" in one of my application folders. I suggest you go back to check_app_files stage and see if you can spot anything giving you errors there. Not sure if "Enable system diagnostics" in your run pipeline gives you any help. Either way, dont think this is related to the issue with the install-modules or graph errors.

nithilin1 commented 1 year ago

5 should fix the issue!