从 powershell 创建具有多个依赖项的新服务

Create new-service with multiple dependencies from powershell

背景:我有一个 TFS 2015 的自定义任务 Build/Release 使用 powershell

创建一个新的 windows 服务
New-Service -BinaryPathName $servicePath -Name $serviceName -Credential $cred -Description $description -DependsOn $dependsOn -DisplayName $friendlyName -StartupType $startupType

这对于使用 -DependsOn 参数的单个依赖项非常有效。问题是我的一项服务有两个依赖项。 MSDN 文档声明使用逗号分隔的依赖项列表。我试过这个没有运气。服务已创建,但缺少依赖项,服务无法启动。我已验证该任务正在按预期将值传递给 powershell 脚本。我正在通过 -DependsOn MSMQ,MSDTC

我试过将它作为带引号的字符串传递,但失败了。我可以单独传递依赖关系,而且效果很好。

我的问题很简单,如何将多个依赖项从 TFS 构建任务传递到 New-Service powershell 命令?

根据MSDN-DependsOn是一个字符串数组,所以将其作为字符串数组传递,即:

-DependsOn ("MSMQ","MSDTC")