我正在调用 dbatoolsInstall-DbaInstance
函数,其中一个参数是Feature
. 我将变量初始化为“Engine”。如果$bolSSIS -eq $true
,我想将“IntegrationServices”添加到变量中。如果$bolSSAS -eq $true
,我想将“AnalysisServices”添加到变量中。
下面的代码不完整,但我相信足以解释我正在尝试做的事情:
$bolSSIS = $true
$bolSSAS = $false
$InstallFeatures = "Engine"
if ($bolInstallFeatureSSIS -eq $true) { $InstallFeatures += ",IntegrationServices" }
if ($bolInstallFeatureSSAS -eq $true) { $InstallFeatures += ",AnalysisServices" }
Install-DbaInstance -Feature $InstallFeatures
上面的代码返回错误:
Cannot validate argument on parameter 'Feature'. The argument "Engine,IntegrationServices" does not belong to the set "Default,All,Engine,Tools,Replication,FullText,DataQuality,PolyBase,MachineLearning,AnalysisServices,IntegrationServices, {others removed for brevity} " specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
这是我的问题:我该如何设置$InstallFeatures
?
我尝试过字符串、数组、哈希和其他变量类型。
FWIW,如果$InstallFeatures
仅设置为“默认”,则该Install-DbaInstance -Feature $InstallFeatures
命令有效且不返回错误。