1

In the following PowerShell v2.0 script, the command & is not executed :

$SqlPackageExe = "C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\sqlpackage.exe"
Write-Host "Before SqlPackage"
& "$SqlPackageExe" /Action:Publish $SqlPackageParameters
Write-Host "After SqlPackage"

On the console output, I see : Before SqlPackage After SqlPackage

I have no error, no log, nothing of the SqlPackage.exe. What's happen ? My command "& "$SqlPackageExe" /Action:Publish $SqlPackageParameters" works a first time, a second time (database is deployed), and then stops working. If I close the PowerShell session and open a new PowerShell session, the command works several times, then stops working.

Thank you for your help

1

1 Answer 1

1

You need to redirect StdError and StdOut, see the answer that discusses " -RedirectStandardError -RedirectStandardOutput":

Powershell: Capture program stdout and stderr to separate variables

Sign up to request clarification or add additional context in comments.

1 Comment

Ok. I could get an error number. It's a known bug in PowerShell when there are too many Console.Write() : support.microsoft.com/en-us/kb/2701373 Thank you for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.