Skip to content

Commit

Permalink
Add LibraryUpdate report #488
Browse files Browse the repository at this point in the history
  • Loading branch information
chezzer64 committed Oct 11, 2023
1 parent c6e0b39 commit ea473f4
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Evergreen/Public/Invoke-EvergreenLibraryUpdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ function Invoke-EvergreenLibraryUpdate {
Write-Verbose -Message "Library exists: $LibraryFile."
$Library = Get-Content -Path $LibraryFile -ErrorAction "Stop" | ConvertFrom-Json -ErrorAction "Stop"

# Get current list of install media files present in library
$LibContentBefore = Get-ChildItem -Path $Path -File -Recurse -Exclude "*.json" | Select-Object FullName | Sort-Object FullName

foreach ($Application in $Library.Applications) {

# Return the application details
Expand Down Expand Up @@ -81,9 +84,33 @@ function Invoke-EvergreenLibraryUpdate {
}

# Write the application version information to the library
Export-EvergreenApp -InputObject $App -Path $(Join-Path -Path $AppPath -ChildPath "$($Application.Name).json")
Export-EvergreenApp -InputObject $App -Path $(Join-Path -Path $AppPath -ChildPath "$($Application.Name).json") | Out-Null
}
}

# Get new list of install media files present in library following update
$LibContentAfter = Get-ChildItem -Path $Path -File -Recurse -Exclude "*.json" | Select-Object FullName | Sort-Object FullName

# Output details of library updates
if ($Null -eq $LibContentAfter) {
Write-Output "No Installer Media found in Evergreen Library"
}
elseif ($Null -ne $LibContentBefore) {
(Compare-Object $LibContentBefore $LibContentAfter -Property FullName -IncludeEqual | ForEach-Object {
[PSCustomObject]@{
Installer = $_.Fullname
Status = $_.SideIndicator -replace '=>','NEW' -replace '==','UNCHANGED' -replace '<=','DELETED'
}
})
}
else {
($LibContentAfter | ForEach-Object {
[PSCustomObject]@{
Installer = $_.Fullname
Status = 'NEW'
}
})
}
}
else {
$Msg = "$Path is not an Evergreen Library. Cannot find EvergreenLibrary.json. Create a library with New-EvergreenLibrary."
Expand Down

0 comments on commit ea473f4

Please sign in to comment.