Function Select-ItemsWithListBoxes { <# .Synopsis Use a form with two list boxes to select items from list, or properties of objects in list, passing the results down the pipeline .DESCRIPTION This script uses a WPF form with two listbox columns to allow the user to select items from a list. This allows you to choose the order of and which items will be selected. When used with SelectProperties switch, user chooses from the properties of the input object, returns object with selected properties down the pipeline .PARAMETER InputObject Initial list for left panel .PARAMETER FormTitle Optional title for form .PARAMETER Color Optional background. May use .Net color names or values .PARAMETER SelectProperties Choose from the properties of the input object, and return object with selected properties down the pipeline .EXAMPLE #Get list of characters. $list = (33..126 | ForEach-Object{[char][byte]$_}) # Note that with a simple list you cannot use the pipeline. Select-ItemswithListboxes -inputobject $list .EXAMPLE #Get all domain names, sort and present in form with custom title $doms = ([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() | Select-Object domains).Domains.name | sort-object -CaseSensitive #Note that with a simple list you cannot use the pipeline. Select-ItemsWithListBoxes -formtitle "Choose Domains to Query" -InputObject $doms .Example #Get first 10 of all users with all properties, send to function to select properties $params = @{ Filter = '*' properties = '*' SearchScope = 'Subtree' ResultSetSize = 10 } #Here you can use the pipeline get-aduser @params | Select-ItemsWithListBoxes -SelectProperties .Notes Alan Kaplan 1/4/2018 Functions process block accepts one item at a time. If you only see one item in left column, assign the list to a variable, and use that as the inputobject The form XML is from Visual Studio. Method to use with PS is from https://foxdeploy.com/2015/04/16/part-ii-deploying-powershell-guis-in-minutes-using-visual-studio/ If form is closed, test for '', not $null #> #Requires -version 3 [CmdletBinding( SupportsShouldProcess = $false )] [OutputType([object])] Param ( [Parameter(Mandatory = $True, ValueFromPipeline = $true, Position = 0)] [Object[]]$InputObject, # Optional Form title [string] $formTitle = 'Choose in the order you want processed', #Optional form background color, default is a light blue [string] $color = '#b3dbff', #Display an choose properties only [Switch] $SelectProperties ) Begin {$FirstRun = $True} Process { if ($firstRun) { #only build form to select properties for first member of pipeline $script:SelectedItems = '' #XML from Visual Studio designed WPF form $InputXML = @" "@ $inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^ Get-Help $fn -detailed`n" } ELSE { if ($MyInvocation.InvocationName -ne '.') { "`nThis advanced function must be dot sourced to run.`n" "Load example:`nPS C:\> . `"$ScriptPath`"`n After loading, use `"Get-Help`" for information and usage, Ex: PS C:\> Get-Help $fn -detailed`n" Pause } ELSE { "`nYou have loaded the advanced function `"$fn`"" "`tUse `"Get-Help`" for information and usage, Ex:`n`tPS C:\> Get-Help $fn -ShowWindow`n" } } } #endregion Dot Source Reminder ###