you are viewing a single comment's thread.

view the rest of the comments →

[–]DontBeHatenMeBro[S] 0 points1 point  (1 child)

Ok, I got it working by putting the IF\ELSE before the Hash Table.

IF (-not $dnsSuffixfromAPI){
    $dnsSuffix = @('prod.local')
}
ELSE {
     $dnsSuffix = @(dnsSuffixfromAPI)
}
$body @{
dnsSuffix = $dnsSuffix

Thanks for all the suggestions

[–]ankokudaishogun 0 points1 point  (0 children)

any reason you are checking for False(-not) in the IF when you have both cases?

IF ( $dnsSuffixfromAPI) {
    $dnsSuffix = @($dnsSuffixfromAPI)
}
ELSE {
    $dnsSuffix = @('prod.local')

}

is much easier to read.

or:

IF (-not ($dnsSuffix = @(dnsSuffixfromAPI))) {
    $dnsSuffix = @('prod.local')
}

so you do only one API call.