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

Phil
  • 1,035
  • 2
  • 10
  • 17
  • This answer http://stackoverflow.com/a/31351075/9976 has a script that logs output - will help you debug. – Mark Jul 13 '15 at 01:33

1 Answers1

1

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

Powershell: Capture program stdout and stderr to separate variables

Community
  • 1
  • 1
Ed Elliott
  • 6,666
  • 17
  • 32
  • Ok. I could get an error number. It's a known bug in PowerShell when there are too many Console.Write() : https://support.microsoft.com/en-us/kb/2701373 Thank you for your help. – Phil Jul 15 '15 at 12:53