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.
Update:
The solution below works, but I've since come to realize that, due to a long-standing bug, it may be better to encode all arguments in a single string, because it makes the situational need for embedded double-quoting explicit - see this answer for background information; applied to the command at hand:
# Note the '...' around *all* pass-through arguments.
# This single string encoding all arguments implicitly binds to -ArgumentList
Start-Process -Wait "\\mynetworkpath\SQLServer2014SP1.exe" '/qs /IAcceptSQLServerLicenseTerms /Action=Patch /AllInstances'
Your Start-Process
call's syntax is flawed; try the following:
# Define executable
$exe = '\\mynetworkpath\SQLServer2014SP1.exe'
# Define *array* of arguments
$exeArgs = '/qs', '/IAcceptSQLServerLicenseTerms', '/Action=Patch', '/AllInstances'
Start-Process -Wait $exe -ArgumentList $exeArgs
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.