【发布时间】:2019-05-01 05:15:26
【问题描述】:
我有一个应该将项目部署到我的 SSIS 服务器的 PS 脚本。 当我在控制台中运行生成的命令时,它运行良好,但是当从 Powershell 执行命令时,由于此(Windows)错误而失败:
标题:SQL Server 集成服务
路径格式无效。 参数名称:DestinationPath (ISDeploymentWizard)
其他信息:
路径格式无效。 (Microsoft.SqlServer.IntegrationServices.Wizard.Common)
如果我从控制台运行生成的命令,它运行良好:
D:\Deploy\ISDeploymentWizard.exe /Silent /ModelType:Project /SourcePath:"D:\Deploy\Receive\My_Beautiful_Project.ispac" /DestinationServer:"localhost" /DestinationPath:"/SSISDB/My Beautiful Project/My_Beautiful_Project" /ProjectPassword:"SuperSecretPassword"
脚本(感谢 Guenther Schmitz 和 Janne Tukaanen 的建议):
#region script configuration
$SsisServer = "."
$ProjectFileFolder = "D:\Deploy\Receive"
$ProjectFileName = "My_Beautiful_Project.ispac"
$ProjectFilePassword = "SuperSecretPassword"
$FolderName = "My Beautiful Project"
$ProjectName = "My_Beautiful_Project"
$ISDeploymentWizard = "D:\Deploy\ISDeploymentWizard.exe"
#endregion
#region project deployment
# Create command line arguments
$DestinationPath = "/SSISDB/" + $FolderName + "/" + $ProjectName
$ProjectFilePath = $ProjectFileFolder + "\" + $ProjectFileName
$cmd = $ISDeploymentWizard
$arg1 = "/Silent"
$arg1a= "/ModelType:Project"
$arg2 = "/SourcePath:""$ProjectFilePath"""
$arg3 = "/DestinationServer:""$SsisServer"""
$arg4 = "/DestinationPath:""$DestinationPath"""
$arg5 = "/ProjectPassword:""$ProjectFilePassword"""
Write-Host "$cmd" $arg1 $arg1a $arg2 $arg3 $arg4 $arg5
& "$cmd" $arg1 $arg1a $arg2 $arg3 $arg4 $arg5
Write-Host "Done"
#endregion
【问题讨论】:
-
你的执行行不是缺少
$cmd吗?您现在正尝试运行$arg1。 -
确实如此。但现在我有一个不同的错误:| (见问题)
-
用直引号替换所有卷曲的“智能”引号
-
这是由于stackoverflow的格式化:|
-
你尝试过纯powershell解决方案吗? docs.microsoft.com/en-us/sql/integration-services/…
标签: sql-server powershell deployment ssis