Public/New-AndroidApplication.ps1

<#
 
.COPYRIGHT
Copyright (c) Office Center Hønefoss AS. All rights reserved. Licensed under the MIT license.
See https://github.com/officecenter/OCH-Public/blob/master/LICENSE for license information.
 
#>


Function New-AndroidApplication
{
  <#
      .SYNOPSIS
      This function is used to add an iOS application using the Graph API REST interface
      .DESCRIPTION
      The function connects to the Graph API Interface and adds an iOS application from the itunes store
      .EXAMPLE
      Add-iOSApplication -AuthHeader $AuthHeader
      Adds an iOS application into Intune from itunes store
      .NOTES
      NAME = Add-iOSApplication
  #>

    
  [cmdletbinding()]
    
  param
  (
    [Parameter(Mandatory = $True)]
    [String]
    $DisplayName,

    [String]
    $Description = $DisplayName,

    [Parameter(Mandatory = $True)]
    [String]
    $Publisher,

    [Parameter(Mandatory = $True)]
    [Uri]
    $AppstoreUrl,

    [Parameter(Mandatory = $True)]
    [ValidateSet('v4_0','v4_0_3','v4_1','v4_2','v4_3','v4_4','v5_0','v5_1')]
    $MinimumOsVersion,

    [Parameter(Mandatory = $True)]
    [Uri]
    $IconUrl,

    [Switch]
    $IsFeatured


  )

  $iconResponse = Invoke-WebRequest "$iconUrl"
    $base64icon = [System.Convert]::ToBase64String($iconResponse.Content)
    $iconExt = ([System.IO.Path]::GetExtension("$iconURL")).replace(".", "")
    $iconType = "image/$iconExt"

  New-Object -TypeName PSObject -Property @{
    "@odata.type" = "#microsoft.graph.androidStoreApp"
    "displayName" = "$DisplayName"
    "description" = "$Description"
    "publisher" = "$Publisher"
    "isFeatured" = $IsFeatured
    "largeIcon" = New-Object -TypeName PSObject -Property @{
      "@odata.type" = "#microsoft.graph.mimeContent"
      "type" = "$iconType"
      "value" = "$base64icon"
    }
    "appStoreUrl" = "$AppstoreUrl"
    "minimumSupportedOperatingSystem" = New-Object -TypeName PSObject -Property @{
      "@odata.type" = "#microsoft.graph.androidMinimumOperatingSystem"
      "$MinimumOsVersion" = 'true'
    }
  }
}