Public/Get-JoinIf.ps1
# $SQLServer = Get-JoinIf $InstanceName @($ServerName, "\", $InstanceName) $ServerName function Get-JoinIf { param ( [string]$condition, [string[]]$trueResult, [string]$falseResult ) ForEach ( $siteurl in $trueResult ) { Write-Host $siteurl } if ($condition) { return [string]::Join("", $trueResult) # $ServerName + "\" + $InstanceName } else { $falseResult } } |