From d82306b64b211fc3a13daafa8536aaaf52cd83ae Mon Sep 17 00:00:00 2001 From: Christian Oeser Date: Fri, 22 Nov 2024 11:36:58 +0100 Subject: [PATCH 1/2] Added Nevergreen Appsource --- Scripts/Install-Modules.ps1 | 3 +- Scripts/Test-AppList.ps1 | 87 +++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/Scripts/Install-Modules.ps1 b/Scripts/Install-Modules.ps1 index 94a5278..759f90d 100644 --- a/Scripts/Install-Modules.ps1 +++ b/Scripts/Install-Modules.ps1 @@ -18,12 +18,13 @@ Version history: 1.0.0 - (2022-04-04) Script created 1.0.1 - (2024-03-04) Improved module installation logic + 1.0.2 - (2024-11-22) Added Nevergreen Module #> Process { # Ensure package provider is installed $PackageProvider = Install-PackageProvider -Name "NuGet" -Force - $Modules = @("Evergreen", "IntuneWin32App", "Az.Storage", "Az.Resources", "MSGraphRequest") + $Modules = @("Evergreen", "Nevergreen", "IntuneWin32App", "Az.Storage", "Az.Resources", "MSGraphRequest") foreach ($Module in $Modules) { try { Write-Output -InputObject "Attempting to locate module: $($Module)" diff --git a/Scripts/Test-AppList.ps1 b/Scripts/Test-AppList.ps1 index 99c34b0..5086ad1 100644 --- a/Scripts/Test-AppList.ps1 +++ b/Scripts/Test-AppList.ps1 @@ -23,6 +23,7 @@ 1.0.4 - (2024-03-07) Added support for empty filter options in Get-EvergreenAppItem function 1.0.5 - (2024-08-25) Added function to test and convert version strings with invalid characters to improve version comparison for detected applications in Intune. Improved application detection logic using the new naming convention property specified in the appList.json file. + 1.0.6 - (2024-11-22) Added Nevergreen Appsource #> [CmdletBinding(SupportsShouldProcess = $true)] param ( @@ -140,6 +141,76 @@ Process { return $EvergreenApp } + function Get-NevergreenAppItem { + param ( + [parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string]$AppId, + + [Parameter(Mandatory = $false)] + [System.Collections.Hashtable] $AppParams, + + [parameter(Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [System.Object[]]$FilterOptions + ) + if ($PSBoundParameters["FilterOptions"]) { + # Construct array list to build the dynamic filter list + $FilterList = New-Object -TypeName "System.Collections.ArrayList" + + # Process known filter properties and add them to array list if present on current object + if ($FilterOptions.Architecture) { + $FilterList.Add("`$PSItem.Architecture -eq ""$($FilterOptions.Architecture)""") | Out-Null + } + if ($FilterOptions.Platform) { + $FilterList.Add("`$PSItem.Platform -eq ""$($FilterOptions.Platform)""") | Out-Null + } + if ($FilterOptions.Channel) { + $FilterList.Add("`$PSItem.Channel -eq ""$($FilterOptions.Channel)""") | Out-Null + } + if ($FilterOptions.Type) { + $FilterList.Add("`$PSItem.Type -eq ""$($FilterOptions.Type)""") | Out-Null + } + if ($FilterOptions.Installer) { + $FilterList.Add("`$PSItem.Installer -eq ""$($FilterOptions.Installer)""") | Out-Null + } + if ($FilterOptions.InstallerType) { + $FilterList.Add("`$PSItem.InstallerType -eq ""$($FilterOptions.InstallerType)""") | Out-Null + } + if ($FilterOptions.Language) { + $FilterList.Add("`$PSItem.Language -eq ""$($FilterOptions.Language)""") | Out-Null + } + if ($FilterOptions.Edition) { + $FilterList.Add("`$PSItem.Edition -eq ""$($FilterOptions.Edition )""") | Out-Null + } + if ($FilterOptions.Ring) { + $FilterList.Add("`$PSItem.Ring -eq ""$($FilterOptions.Ring)""") | Out-Null + } + if ($FilterOptions.Release) { + $FilterList.Add("`$PSItem.Release -eq ""$($FilterOptions.Release)""") | Out-Null + } + if ($FilterOptions.ImageType) { + $FilterList.Add("`$PSItem.Release -eq ""$($FilterOptions.ImageType)""") | Out-Null + } + + # Construct script block from filter list array + $FilterExpression = [scriptblock]::Create(($FilterList -join " -and ")) + + # Get the evergreen app based on dynamic filter list + If ($null -ne $AppParams){ + $NevergreenApp = Get-NevergreenApp -Name $AppId -AppParams $AppParams | Where-Object -FilterScript $FilterExpression + } else { + $NevergreenApp = Get-NevergreenApp -Name $AppId | Where-Object -FilterScript $FilterExpression + } + } + else { + $NevergreenApp = Get-NevergreenApp -Name $AppId + } + + # Handle return value + return $NevergreenApp + } + function Get-WindowsPackageManagerItem { param ( [parameter(Mandatory = $true)] @@ -328,6 +399,22 @@ Process { $AppItem = Get-EvergreenAppItem -AppId $App.AppId } } + "Nevergreen" { + Write-Output -InputObject "Attempting to retrieve app details from Nevergreen" + if ($null -ne $App.FilterOptions) { + Write-Output -InputObject "AppId value: $($App.AppId)" + Write-Output -InputObject "Filter options: $($App.FilterOptions)" + If ($null -ne $App.AppParams.AppLanguage){ + $AppItem = Get-NevergreenAppItem -AppId $App.AppId -AppParams @{Language = $App.AppParams.AppLanguage} -FilterOptions $App.FilterOptions + } else { + $AppItem = Get-NevergreenAppItem -AppId $App.AppId -FilterOptions $App.FilterOptions + } + } + else { + Write-Output -InputObject "AppId value: $($App.AppId)" + $AppItem = Get-NevergreenAppItem -AppId $App.AppId + } + } "StorageAccount" { Write-Output -InputObject "Attempting to retrieve app details from Storage Account" $AppItem = Get-StorageAccountAppItem -StorageAccountName $App.StorageAccountName -ContainerName $App.StorageAccountContainerName From 164be004be87f73fb56d0629a5f3a164c6890871 Mon Sep 17 00:00:00 2001 From: ChristianOe <39793553+ChristianOe@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:29:41 +0100 Subject: [PATCH 2/2] Fixed Filter ImageType --- Scripts/Test-AppList.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/Test-AppList.ps1 b/Scripts/Test-AppList.ps1 index 5086ad1..4bff25e 100644 --- a/Scripts/Test-AppList.ps1 +++ b/Scripts/Test-AppList.ps1 @@ -124,7 +124,7 @@ Process { $FilterList.Add("`$PSItem.Release -eq ""$($FilterOptions.Release)""") | Out-Null } if ($FilterOptions.ImageType) { - $FilterList.Add("`$PSItem.Release -eq ""$($FilterOptions.Release)""") | Out-Null + $FilterList.Add("`$PSItem.ImageType -eq ""$($FilterOptions.Release)""") | Out-Null } # Construct script block from filter list array @@ -190,7 +190,7 @@ Process { $FilterList.Add("`$PSItem.Release -eq ""$($FilterOptions.Release)""") | Out-Null } if ($FilterOptions.ImageType) { - $FilterList.Add("`$PSItem.Release -eq ""$($FilterOptions.ImageType)""") | Out-Null + $FilterList.Add("`$PSItem.ImageType -eq ""$($FilterOptions.ImageType)""") | Out-Null } # Construct script block from filter list array @@ -588,4 +588,4 @@ Process { Write-Output -InputObject "##vso[task.setvariable variable=shouldrun;isOutput=true]false" throw "$($MyInvocation.MyCommand): Failed to retrieve authentication token with error message: $($_.Exception.Message)" } -} \ No newline at end of file +}