Forum Discussion

Suleyman Ali's avatar
Suleyman Ali
Iron Contributor
Sep 15, 2023

Uploading app icons for manage apps in intune using microsoft graph SDK Powershell

hi all,

 

I am creating a script to add apps to intune and assign them.  currently, all is working well apart from uploading the icon.  Here is the portion of the body parameters

 

 $appBody = @{
            '@odata.type'         = "#microsoft.graph.winGetApp"
            description           = $appInfo.ShortDescription
            developer             = $appInfo.Publisher
            displayName           = "$($appInfo.packageName) ($($runAsScope))"
            informationUrl        = $appInfo.PublisherSupportUrl
            largeIcon             = @{
                "@odata.type"= "#microsoft.graph.mimeContent"
                "type" = "image/jpeg"
                "value" = $base64string
            }
            installExperience     = @{
                runAsAccount = $runAsScope
            }
            isFeatured            = $True
            packageIdentifier     = $appId
            privacyInformationUrl = $appInfo.PrivacyUrl
            publisher             = $appInfo.publisher
            repositoryType        = "microsoftStore"
            roleScopeTagIds       = @()
        }  
 
There are no errors
 
i have tried type "image/png" as well, but again no errors.  I am using the 
New-MgBetaDeviceAppManagementMobileApp command.  
 
I will try to manually use graph explorer to see if I can do it post app creation.  Any pointers and examples welcomed
  • PH-AaronHall's avatar
    PH-AaronHall
    Brass Contributor

    Suleyman Ali Were you able to get your script working? I'm attempting the same, but would be interested in saving myself the time if you have a working implementation already.

    • Suleyman Ali's avatar
      Suleyman Ali
      Iron Contributor
      hi there, apologies for the delay. Firstly, with the above you are not using the MS Graph Powershell SDK. Which we want. Also, if you look at the code snippet, the image is in base64 value and put into the var $base64string. Although i maybe should of put that there to make it clearer.

      IT seems that it does not upload the icon straight away when creating the app. we looked at other examples, and we can see that some are creating the app, and once finished, they then upload the image icon. Once we did this it seems to work. I cant find any documentation yet to see if this is the case. but we can live with that workaround
      • Harm_Veenstra's avatar
        Harm_Veenstra
        MVP
        Ok, like a two-stage thing and not possible in one run? I couldn't find anything about that either. I'm curious about that let us know if you find anything
  • Suleyman Ali 

     

    I'm working on something similar, used this blog post https://rozemuller.com/add-microsoft-store-app-with-icon-into-intune-automated/ for that. Basically you create a Base64 of it

     

    $imageUrl = "https://apps.microsoft.com/store/api/ProductsDetails/GetProductDetailsById/{0}?hl=en-US&gl=US" -f $exactApp.PackageIdentifier
    $image = Invoke-RestMethod -Uri $imageUrl -Method GET
    $wc = New-Object System.Net.WebClient
    $wc.DownloadFile($image.IconUrl, "./temp.jpg")
    $base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes('./temp.jpg'))

     

    and use that as icon like this, type should be string:

     

    $deployUrl = "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps"
    $appBody = @{
        '@odata.type'         = "#microsoft.graph.winGetApp"
        description           = $appInfo.ShortDescription
        developer             = $appInfo.Publisher
        displayName           = $appInfo.packageName
        informationUrl        = $appInfo.PublisherSupportUrl
        largeIcon             = @{
            "@odata.type"= "#microsoft.graph.mimeContent"
            type = "String"
            value = $base64string 
        }
        installExperience     = @{
            runAsAccount = $appInstaller.scope
        }
        isFeatured            = $false
        packageIdentifier     = $appId
        privacyInformationUrl = $appInfo.PrivacyUrl
        publisher             = $appInfo.publisher
        repositoryType        = "microsoftStore"
        roleScopeTagIds       = @()
    } | ConvertTo-Json 
    $appDeploy = Invoke-RestMethod -uri $deployUrl -Method POST -Headers $authHeader -Body $appBody

     

Resources