I’m trying to execute a command using the following code snippet:
foreach($package in (Get-Childitem *.dtsx | select-object -expand Name))
{
DTUTIL /COPY SQL;"\$package" /DESTSERVER "$global:SSISServer" /FILE "$package" /Q
}
However doing so results in the following error message:
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
I also tried
& DTUTIL "/COPY SQL;'\" + [System.IO.Path]::GetFileNameWithoutExtension($package) + "' /DESTSERVER '$global:SSISServer' /FILE $package"
But now this gives me
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.
But at least the command ran but it seems like it didn’t receive any of the parameters I sent it …I’m guessing there’s a fundamental concept of PowerShell I’m overlooking or failed to grasp here. Where have I gone wrong?
When passing variables as arguments to a command, you don’t need to quote them. That being said, it looks like you have a rogue semi-colon in your command. Semi-colons are optional in PowerShell, but when present, is used as the command separator. In this case, you’ll need to quote the argument that has a semi-colon, or create a variable for that argument:
I’ve never used
diutil, so don’t know the commands arguments or syntax.