CmdLets/Test-LibraryPackage.ps1
|
Function Test-LibraryPackage { [CmdletBinding()] Param( [Parameter(Mandatory=$True,ValueFromPipeline=$True)] [ValidateNotNullOrEmpty()] [System.IO.FileInfo[]]$PackageFile, [Parameter(Mandatory=$false)] [System.IO.FileInfo]$ScriptRoot = "C:\Temp\Scripts" ) Begin {} Process{ Write-Host "Package File: $($PackageFile.FullName)" $Package = Get-Content $PackageFile | ConvertFrom-Json Write-Host "Package Name: $($Package.Name)" Write-Verbose $Package Write-verbose "Initializing Variables" -ForegroundColor Cyan Initialize-Variables $Package.Variables $Libraries = Get-Childitem (Join-Path $LibraryPath "*.json") Write-Host "Libraries Found: $($Libraries.Count)" Write-Verbose "Analyzing Applications" $Applications = @() $Unfound = @() ForEach ($Name in $Package.Applications) { Write-Verbose "`tFinding: $Name" $Application = Find-LibraryApplication $Name if ($Application) { $Applications += $Application } else { $Unfound += $Name } } Write-Host "Found Applications: $($Applications.Count)" -ForegroundColor Cyan $Applications.Name Write-Host "Unfound Applications: $($Unfound.Count)" -ForegroundColor Magenta $Unfound Read-Host "Press Enter to start Application Source Testing" $Applications | Test-LibraryApplication -Path $SoftwarePath } End{} } |