Private/Build-MenuFromArray.ps1
function Build-MenuFromArray { param( [Parameter(Mandatory)] [array]$array, [Parameter(Mandatory)] [string]$property, [Parameter()] [string]$message = "Select item" ) Write-Host '------' $menuarray = @() foreach ($i in $array) { $o = New-Object psobject $o | Add-Member -MemberType NoteProperty -Name $property -Value $i.$property $menuarray += $o } $menu = @{} for ( $i=1 $i -le $menuarray.count $i++ ) { Write-Host "$i. $($menuarray[$i-1].$property)" $menu.Add($i,($menuarray[$i-1].$property)) } Write-Host '------' [int]$mntselect = Read-Host $message $menu.Item($mntselect) Write-Host `n`n } |