class SystemName { #: System.Management.Automation.IValidateSetValuesGenerator { static [string[]] _GetValidValues([string]$wordToComplete,[bool]$CurrentOnly,[bool]$Strict) { $MyPSScriptRoot = "$global:MyPSScriptRoot"; $local:possibleValues = [ordered]@{} $possibleValues.out = @() $possibleValues.Current = @( $($global:PSVersionTable.OS -split ' '|Select-Object -First 1).Replace('Microsoft','Windows'), $global:PSVersionTable.Platform, $global:PSVersionTable.PSEdition ); $possibleValues.out = $possibleValues.Current if( -not $CurrentOnly ) { $possibleValues.Platform = @( 'Windows','Linux','Unix' ); $possibleValues.Edition = @( 'Desktop', 'Core' ); $possibleValues.Exist = Get-ChildItem (Join-Path $MyPSScriptRoot "sys.*") | ForEach-Object { $_.Name -replace 'sys\.','' }; $possibleValues.out += $possibleValues.Platform + $possibleValues.Edition + $possibleValues.Exist } $possibleValues.out = $possibleValues.out | Select-Object -Unique | Where-Object { $_ } | Sort-Object { $local:sortName = "zz_$_"; if( $_ -in $possibleValues.Exist -and $_ -in $possibleValues.Current ) { $sortName[0] = "a" } elseif( $_ -in $possibleValues.Exist ) { $sortName[0] = "b" } elseif( $_ -in $possibleValues.Current ) { $sortName[0] = "c" } if( $_ -in $possibleValues.Platform ) { $sortName[1] = "a" } if( $_ -in $possibleValues.Edition ) { $sortName[1] = "b" } $sortName; } return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues.out -Strict:$Strict ); } [String[]] GetValidValues() { return [SystemName]::_GetValidValues('',$false,$true) } }