简体   繁体   中英

Powershell invoking DTUTIL error

I'm currently in the process of building a deployment process in octopus deploy and as part of that I want to use DTUTIL to create folders and load SSIS packages to our server. This text "C:\\Program Files (x86)\\Microsoft SQL Server\\130\\DTS\\Binn\\dtutil.exe" /SourceServer [servername] /FC SQL;\\;[foldername], with appropriate server and folder names, which works in DOS.

Here is the rub, if I use the same code in Powershell I get an error:

$Command ="`"C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe`"  /SourceServer MYSERVER /FC SQL;\;Folder1";
invoke-Expression $Command;
invoke-expression : At line:1 char:73
+ ...  Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe"  /SourceSe ...
+                                                                  ~
You must provide a value expression following the '/' operator.
At line:1 char:73
+ ... \Microsoft SQL Server\130\DTS\Binn\dtutil.exe"  /SourceServer MYSERVER ...
+                                                      ~~~~~~~~~~~~
Unexpected token 'SourceServer' in expression or statement.
At line:1 char:1
+ invoke-expression $Command
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression,Microsoft.PowerShell.Commands.InvokeExpressionCommand

Has anyone got any idea how to remedy this?

Anthony

You can execute the EXE using the & operator:

& "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe"  /SourceServer MYSERVER /FC SQL;\;Folder1

Also, the above Invoke-Expression command failed in the same way when I ran it in PowerShell directly, this doesn't appear to be an issue with running the PowerShell within Octopus.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM