我正在尝试使用以下代码片段执行命令:
foreach($package in (Get-Childitem *.dtsx | select-object -expand Name))
{
DTUTIL /COPY SQL;"\$package" /DESTSERVER "$global:SSISServer" /FILE "$package" /Q
}
但是,这样做会导致以下错误消息:
You must provide a value expression on the right-hand side of the '/' operator.
At C:\Projects\RiskOptix\Code\Deployment\BuildAll.ps1:267 char:39
+ DTUTIL /COPY SQL;"\$package" / <<<< DESTSERVER "$global:SSISServer" /FILE "$package" /Q
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
我也试过
& DTUTIL "/COPY SQL;'\" + [System.IO.Path]::GetFileNameWithoutExtension($package) + "' /DESTSERVER '$global:SSISServer' /FILE $package"
但现在这给了我
Microsoft (R) SQL Server SSIS Package Utilities
Version 10.50.1600.1 for 32-bit
Copyright (C) Microsoft Corporation 2010. All rights reserved.
At least one of the DTS, SQL, or File options must be specified.
但至少命令运行了,但它似乎没有收到我发送给它的任何参数......我猜我在这里忽略或未能掌握 PowerShell 的基本概念。我哪里出错了?