Private/Select-ImageToDownload.ps1
function Select-ImageToDownload { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ImageUSBClass]$usbImage ) $menu = 0 while ( $menu -lt 1 -or $menu -gt $usbImage.config.UrlPath.Count) { Write-Host "`nWindows 10 Images`n" -ForegroundColor Green #Menu List foreach ( $item in $usbImage.config.UrlPath) { Write-Host $item.Prompt Write-Host "---------------------------------------------------`n" } $menu = Read-Host "Please make a selection" if ( $menu -lt 1 -or $menu -gt $usbImage.config.UrlPath.Count) { Write-Host "Please select one of the options available" -ForegroundColor Red; start-Sleep -Seconds 1 } } foreach ( $item in $usbImage.config.UrlPath ) { if ( $menu -eq $item.Index ) { $msg = "You Selected: $($item.Prompt)" Write-Host $msg -ForegroundColor Cyan return $item } } } |