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?