private/Disk/Invoke-SelectUSBDisk.ps1

function Invoke-SelectUSBDisk {
    <#
    .SYNOPSIS
        Presents a picker for the user to select a USB disk.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
 
    Dependencies:
      Module Functions: Get-USBDisk
      .NET Classes: [System.Management.Automation.SwitchParameter]
    #>

    [CmdletBinding()]
    param (
        [Parameter(ValueFromPipeline = $true)]
        [Object]$Input,

        [Alias('Min','MinGB','MinSize')]
        [int]$MinimumSizeGB = 8,

        [Alias('Max','MaxGB','MaxSize')]
        [int]$MaximumSizeGB = 1800,

        [System.Management.Automation.SwitchParameter]$Skip,
        [System.Management.Automation.SwitchParameter]$SelectOne
    )
    #=================================================
    # Get-Disk
    #=================================================
    if ($Input) {
        $Results = $Input
    } else {
        $Results = Get-USBDisk | Where-Object {($_.Size -gt ($MinimumSizeGB * 1GB)) -and ($_.Size -lt ($MaximumSizeGB * 1GB))}
    }
    #=================================================
    # Process Results
    #=================================================
    if ($Results) {
        #=================================================
        # There was only 1 Item, then we will select it automatically
        #=================================================
        if ($PSBoundParameters.ContainsKey('SelectOne')) {
            Write-Verbose "Automatically select "
            if (($Results | Measure-Object).Count -eq 1) {
                $SelectedItem = $Results
                Return $SelectedItem
            }
        }
        #=================================================
        # Table of Items
        #=================================================
        $Results | Select-Object -Property Number, BusType, MediaType,`
        @{Name='SizeGB';Expression={[int]($_.Size / 1000000000)}},`
        FriendlyName, Model, PartitionStyle,`
        @{Name='Partitions';Expression={$_.NumberOfPartitions}} |`
        Format-Table | Out-Host
        #=================================================
        # Select an Item
        #=================================================
        if ($PSBoundParameters.ContainsKey('Skip')) {
            do {$Selection = Read-Host -Prompt "Select a USB Disk by Number, or press S to SKIP"}
            until (($Selection -ge 0) -and ($Selection -in $Results.Number) -or ($Selection -eq 'S'))

            if ($Selection -eq 'S') {Return $false}
        }
        else {
            do {$Selection = Read-Host -Prompt "Select a USB Disk by Number"}
            until (($Selection -ge 0) -and ($Selection -in $Results.Number))
        }
        #=================================================
        # Return Selection
        #=================================================
        Return ($Results | Where-Object {$_.Number -eq $Selection})
        #=================================================
    }
}