Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Nevergreen Appsource #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Scripts/Install-Modules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
87 changes: 87 additions & 0 deletions Scripts/Test-AppList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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
Expand Down