internal/configurationvalidation/stringarray.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Register-PSFConfigValidation -Name "stringarray" -ScriptBlock {
    Param (
        $Value
    )
    
    $Result = New-Object PSObject -Property @{
        Success  = $True
        Value    = $null
        Message  = ""
    }
    
    try
    {
        $data = @()
        # Seriously, this should work for almost anybody and anything
        foreach ($item in $Value)
        {
            $data += [string]$item
        }
    }
    catch
    {
        $Result.Message = "Not a string array: $Value"
        $Result.Success = $False
        return $Result
    }
    
    $Result.Value = $data
    
    return $Result
}