Closed flcdrg closed 3 years ago
Solved in the PR #110. My original code did not work, but your readme taught me to use "Test-Package" in the AU-module - great stuff!
Thanks for the PR, the new version is now published on Chocolatey
Thanks, @flcdrg !
Thanks for a great package (sql-server-2019).
However, the forced implementation of the command line option /SQLSYSADMINACCOUNTS: means that the package will always ignore the value for SQLSYSADMINACCOUNTS in an ini-file, since command line options always take precedence over ini-file options. The problem is that the implementation of the command line option does not support the syntax for multiple accounts or groups: .../SQLSYSADMINACCOUNTS:DOMAIN\SysAdmin1 DOMAIN\SysAdmin2 When 'chocolateyinstall.ps1' is run, the above is converted to .../SQLSYSADMINACCOUNTS:"DOMAIN\SysAdmin1 DOMAIN\SysAdmin2" and the installer will now treat that as a single account, trying to find the SID of "DOMAIN\SysAdmin1 DOMAIN\SysAdmin2".
The problem is I believe the line below: append remaining package parameters
$packageArgs.silentArgs += ($pp.GetEnumerator() | ForEach-Object { "/$($.name)="$($.value)"" }) -join " "
Of course, one could test for whitespaces in $_.value, and wrap each in quotation marks, but that would probably break for values that are supposed to have whitespaces in them (/Option:"value with whitespaces" becomes /Option:"value" "with" "whitespaces").
Better is perhaps the following, testing the configuration file for the presence of SQLSYSADMINACCOUNTS= at start of a line, and only adding command line option if the ini-file option is not present: if (!$pp['SQLSYSADMINACCOUNTS']) {
my additional if below
if ((Get-Content -Path $($pp['CONFIGURATIONFILE'])) -notmatch "^SQLSYSADMINACCOUNTS=") { $pp['SQLSYSADMINACCOUNTS'] = "$env:USERDOMAIN\$env:USERNAME" } }
Hope this can be implemented. Keep up the good work!