簡體   English   中英

Powershell執行文件,並在參數中包含路徑

[英]Powershell execute file with path in parameters

我正在嘗試使用變量字符串作為SourceFile參數從Powershell運行SqlPackage.exe:

$fileExe = "C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\SqlPackage.exe"

& $fileExe /Action:Publish /SourceFile:$OutputVariable\file.dacpac /Profile:C:\sql\file.sqldatabase.publish.xml

其中$ OutputVariable是包含完整路徑的文件夾

不幸的是,我得到以下錯誤:

SqlPackage.exe : *** Illegal characters in path.
At C:\powershell\test.ps1:20 char:6
+      & $fileExe /Action:Publish /SourceFile:$OutputVariable\file.dacpac     /Profile:C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (*** Illegal characters in path.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

我嘗試用引號引起來並拆分參數,但沒有找到解決方案。 任何想法?

提前致謝!

顯然是通過修剪$ OutputVariable

$OutputVariable.Trim()

該問題已解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM