1

I'm installing SQL Data Tools via a PowerShell script. I run my script, but the final part where the Data Tools are installed fails (inside of the SQL installer window). If I run the script without that part, and install Data Tools manually it works.

The error is:

VS Shell installation has failed with exit code -2147205120.

The parts before this install .NET and SQL Server Management Studio. I don't think they're relevant to my issue, but I will post that part if requested. Here are the relevant parts. The first try block installs SQL SP1 (removed now for readability), the second installs Data Tools and SNAC_SDK.

try
{
    Write-Host "Lauching SQL Server Data Tools install ..."
    & "\\mynetworkpath\SSDTBI_x86_ENU.exe" "/ACTION=INSTALL" "/FEATURES=SSDTBI,SNAC_SDK" "/Q" "/IACCEPTSQLSERVERLICENSETERMS"
    Write-Host "Installer launched ..."
}
catch
{
    Write-Host "SQL Server Data Tools installation failed"
    exit
}

I have tried juggling around the arguments for the Data Tools install part, and playing with the -wait verb to make sure SP1 is done for sure, but no luck.

EDIT: Per Matt's suggestion I added /NORESTART to my argument list, but now it doesn't install anything, and doesn't error either...

EDIT: Added updated code with quoted arguments. Still doesn't work, but I think it's closer than it was originally.

jdope
  • 115
  • 2
  • 14
  • 1
    To follow up on Matt's comment, here's the [MSDN article on that error](https://msdn.microsoft.com/en-us/library/mt613186.aspx) – BenH May 15 '17 at 16:57
  • @BenH I actually found that article while troubleshooting. It doesn't make sense though, as when I do the automated SP1 install, and then manually install Data Tools, it works and I don't have to restart. – jdope May 15 '17 at 17:00
  • 1
    Can't compare installing manually to using switches since the options will be different. Have you tried supressing the reboot message with `/norestart` instead? – Matt May 15 '17 at 17:09
  • @Matt Ah! I will have to try that. I will report back. – jdope May 15 '17 at 17:12
  • @Matt Unfortunately that did not change the result :( – jdope May 16 '17 at 14:38

1 Answers1

2

I think the comma in the arguments is the culprit here because powershell interprets entities separated by comma as an array.

You can see how parameters get passed with this little hack

& { $args } /ACTION=INSTALL /FEATURES=SSDTBI,SNAC_SDK /Q /IACCEPTSQLSERVERLICENSETERMS

which gives

/ACTION=INSTALL

/FEATURES=SSDTBI

SNAC_SDK

/Q

/IACCEPTSQLSERVERLICENSETERMS

To get rid of this problem you need to quote at least the FEATURES argument. I usually quote everything in those cases, just to be consistent, so

& { $args } "/ACTION=INSTALL" "/FEATURES=SSDTBI,SNAC_SDK" "/Q" "/IACCEPTSQLSERVERLICENSETERMS"

gives you the wanted parameters:

/ACTION=INSTALL

/FEATURES=SSDTBI,SNAC_SDK

/Q

/IACCEPTSQLSERVERLICENSETERMS

Update: Many installers return immediately after they have been called while the install process still runs in the background, which can be a bugger when the rest of the script depends on the install.

There are several methods to make powershell wait for a process exit. One of the shortest is to use Out-Null like this:

& "\\mynetworkpath\SSDTBI_x86_ENU.exe" "/ACTION=INSTALL" "/FEATURES=SSDTBI,SNAC_SDK" "/Q" "/IACCEPTSQLSERVERLICENSETERMS" | Out-Null

You may also want to look at $? or $LASTEXITCODE afterwards to check for errors.

Community
  • 1
  • 1
TToni
  • 9,145
  • 1
  • 28
  • 42
  • I'm testing the quoted arguments right now! I am wondering about the Out-Null, though. Doesn't putting -Wait in my SP1 install do the same thing, cause the Data Tools install to wait until the SP1 install is done? – jdope May 15 '17 at 19:57
  • 1
    @jdope Essentially, yes. As he said, there are many ways to cause PowerShell to wait for a command to finish executing. You could just as easily use `Start-Process -Path "\\mynetworkpath\SSDTBI_x86_ENU.exe" -Wait -ArgumentList "/ACTION=INSTALL","/FEATURES=SSDTBI,SNAC_SDK","/Q","/IACCEPTSQLSERVERLICENSETERMS";` – Bacon Bits May 15 '17 at 20:35
  • Alright, I tried `& "\\mynetworkpath\SSDTBI_x86_ENU.exe" "/ACTION=INSTALL" "/FEATURES=SSDTBI,SNAC_SDK" "/Q" "/IACCEPTSQLSERVERLICENSETERMS" | Out-Null`, and it installed Visual Studio, but not Data Tools. Kind of strange. It's working... but not all the way. – jdope May 15 '17 at 20:43
  • Which version of the tools are you installing? Do you get parameter help when calling the exe with `/?`? Can you find or specify a log file for the setup? – TToni May 15 '17 at 22:13
  • @TToni Installer says Version 12.0.2344.23. I'm not familiar with `/?` syntax, but I haven't been able to get that to do anything. I did find a log, but it doesn't have any more info that I could find other than the original error I posted. – jdope May 16 '17 at 14:08
  • @jdope Is there a specific reason why you are not using the latest tools (https://msdn.microsoft.com/en-us/mt186501.aspx)? AFAIK they should be compatible with previous versions. Other than that I'm not sure how I could help you further, sorry. – TToni May 16 '17 at 18:29
  • @TToni It's being installed on Windows Server 2012 R2, so that's the version I was told to use. I think it may actually be an issue with the install file itself (Microsoft's fault), rather than PowerShell. Thanks for your help though, I appreciate it. – jdope May 16 '17 at 19:16