3

I want to install SQLServer2014SP1 and then SQL Data Tools. I need it to wait for SP1 to complete before installing SQL Data Tools.

Here's what I've been trying:

Write-Host "Launching SQL SP 1 ..."
Start-Process "\\mynetworkpath\SQLServer2014SP1.exe" -wait /qs /IAcceptSQLServerLicenseTerms /Action=Patch /AllInstances 

Write-Host "Lauching SQL Server Data Tools install ..."
& "\\mynetworthpath\SSDTBI_x86_ENU.exe" /ACTION=INSTALL /FEATURES=SSDTBI,SNAC_SDK /Q /IACCEPTSQLSERVERLICENSETERMS

I've tried different combinations of -wait and the / install parameters, but I get generic errors for the SP1 install failing, or it will complete and the SSDT install will never launch.

If there's a better way to do this I'm open to suggestions. It does have to be automated though.

henrycarteruk
  • 11,908
  • 2
  • 32
  • 38
jdope
  • 115
  • 2
  • 13
  • 2
    You need to use the `ArgumentList` param to pass your arguments: `Start-Process "\\mynetworkpath\SQLServer2014SP1.exe" -ArgumentList "/qs","/IAcceptSQLServerLicenseTerms","/Action=Patch","/AllInstances" -Wait` – henrycarteruk May 12 '17 at 21:12

1 Answers1

6

Your Start-Process call's syntax is flawed; try the following:

# Define executable
$exe = '\\mynetworkpath\SQLServer2014SP1.exe'
# Define *array* of arguments
$args = '/qs', '/IAcceptSQLServerLicenseTerms', '/Action=Patch', '/AllInstances'

Start-Process -Wait $exe -ArgumentList $args

The intermediate variables aren't strictly needed, but I've chosen them both for readability and to illustrate how the arguments fit into the Start-Process syntax:
The pass-through arguments must be passed as an array, to the -ArgumentList (-Args) parameter.

The -Wait option waits for the process created by the specified executable to terminate before moving on to the next command. Of course, this only works as intended if that process doesn't spawn other processes asynchronously that do the actual work - I don't know if that's the case with your specific executable.

With literal arguments, you could do the following, which requires less quoting:

Start-Process -Wait \\mynetworkpath\SQLServer2014SP1.exe -ArgumentList `
  /qs, /IAcceptSQLServerLicenseTerms, /Action=Patch, /AllInstances        

Generally, however, you need to be mindful of PowerShell's up-front interpretation of unquoted or double-quoted arguments (such as unquoted use of , which is interpreted as the array-construction operator), which is more extensive than cmd.exe's - see this answer of mine.

mklement0
  • 312,089
  • 56
  • 508
  • 622