如何在PowerShell脚本中正确使用SSISDeploy命令
问题根因
你的语法存在两个核心错误:
- 错误1:
-at:win是SSISDeploy.exe的运行参数,不是PowerShell内置Start-Processcmdlet的参数,你把它写到了Start-Process的参数列表里,导致PowerShell解析参数时无法识别,把后续的TEST03,1234识别为了不存在的位置参数,触发报错。 - 错误2:
ArgumentList中destination参数的引号嵌套语法错误,"/destination:catalog;${Target};"${Env}""的写法会被PowerShell拆分为两个独立的字符串,传递给程序的参数格式错误。
修正后的语法
$SSISDeploy = Start-Process -FilePath SSISDeploy.exe ` -ArgumentList @( '/source:"download\Integration Services.ispac"', "/destination:catalog;${Target};`"${Env}`"", '-at:win' ) ` -Wait -PassThru -Credential $cred ` -RedirectStandardOutput ssisstdout.txt ` -RedirectStandardError ssisstderr.txt
补充说明
- 用数组形式传递
ArgumentList更易读,也能避免大量转义符的混乱 - destination参数中变量
${Env}外层加了反引号转义的双引号,保证传递给SSISDeploy的参数格式和你原本CMD中执行的格式完全一致 - 原本属于SSISDeploy的
-at:win参数已经移到了ArgumentList数组内,不会再被PowerShell识别为Start-Process的参数
内容的提问来源于stack exchange,提问作者arielma
相关产品推荐
相关产品推荐

