1

I've written a script that downloads the MS ODBC driver, installs it, then checks the new driver .dll exists. However, I'm stuck on the "installs it" part.

The best version of the install command I have right now is: Start-Process -Filepath "msiexec.exe" -ArgumentList "/i msodbcsql.msi", "/qb", "IACCEPTMSODBCSQLLICENSETERMS=YES"

When I run this on its own (to troubleshoot it), however, the installer launches and immediately displays the error:

The required IACCEPTMSODBCSQLLICENSETERMS=YES command-line parameter is missing.

The required IACCEPTMSODBCSQLLICENSETERMS=YES command-line parameter is missing.

If I run Start-Process -Filepath msiexec -ArgumentList /i, "msodbcsql.msi" the regular GUI installer starts up which presumably means the "/qb", "IACCEPTMSODBCSQLLICENSETERMS=YES" part of the command is the problem.

I'm having no luck with this in spite of adapting every example I can find on the web. I'd be grateful for help!

Profplum
  • 89
  • 1
  • 9
  • 1
    Have you tried to simply pass it as a single argument? `"/i msodbcsql.msi /qb IACCEPTMSODBCSQLLICENSETERMS=YES"`? Is there a particular reason you need to pass it as a string array? – Seth Jan 17 '22 at 13:39
  • 1
    I have tried it as a single argument like that. Same error, sadly. – Profplum Jan 17 '22 at 14:02
  • 2
    As an aside regarding `Start-Process`'s argument-passing: While passing the pass-through arguments _individually_ to `-ArgumentList` may be conceptually preferable, a [long-standing bug](https://github.com/PowerShell/PowerShell/issues/5576) unfortunately makes it better to encode all arguments in a _single string_ - see [this answer](https://stackoverflow.com/a/62784608/45375). – mklement0 Jan 17 '22 at 18:21
  • Curious! I'll certainly change it in that case. – Profplum Jan 18 '22 at 10:41

1 Answers1

1

The problem: I wasn't running PowerShell in Administrator mode

Profplum
  • 89
  • 1
  • 9