1

入力文字列の先頭が複数の組み合わせから生成された可能性の 1 つと一致するかどうかを比較する関数を作成しようとしていますSystem.Arrays。この関数の結果は、GroupName受け取った入力とそれが有効な名前かどうかを含むオブジェクトとして返されます$true/$false

配列 1:

Country
-------
BEL
NLD

配列 2:

Color
----
Green
Red

配列 3:

Type            Object
----            ------
Fruit           Banana
Veggetables     Aubergine
Fruit           Appel
Veggetables     Carrot
Fruit           Peer

有効性をチェックする関数で生成されたリスト:

BEL Green-Fruit-Banana
BEL Green-Fruit-Appel
BEL Green-Fruit-Peer
BEL Green-Vegetables-Aubergine
BEL Green-Vegetables-Carrot
NLD Green-Fruit-Banana
NLD Green-Fruit-Appel
NLD Green-Fruit-Peer
NLD Green-Vegetables-Aubergine
NLD Green-Vegetables-Carrot
BEL Red-Fruit-Banana
BEL Red-Fruit-Appel
BEL Red-Fruit-Peer
BEL Red-Vegetables-Aubergine
BEL Red-Vegetables-Carrot
NLD Red-Fruit-Banana
NLD Red-Fruit-Appel
NLD Red-Fruit-Peer
NLD Red-Vegetables-Aubergine
NLD Red-Vegetables-Carrot

私が既に持っているコードは、オブジェクトを作成することです。しかし、関数でこのリストを生成し、値を入力する最良の方法がわかりませんValid

Function Compare-Names {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
        [string[]]$GroupName
    )
    PROCESS {
        # Generate all options
        <# Fill Valid $true or false here #>

        foreach ($Group in $GroupName) {
            $obj = New-Object -TypeName psobject -Property ([ordered] @{
                'GroupName' = $Group;
                'Valid' = $Valid;
            })
        Write-Output $obj
        }
    }
}
4

2 に答える 2