Microsoft SQL Server 2016 (SP2-CU14) (KB4564903) - 13.0.5830.85 (X64)
Jul 31 2020 18:47:07
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2012 Datacenter 6.2 <X64> (Build 9200: )
us_english
If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe
C:\PSScript> Get-DbaBuildReference -Update -Verbose
VERBOSE: GET https://sqlcollaborative.github.io/assets/dbatools-buildref-index.json with 0-byte payload
VERBOSE: received 98199-byte response of content type application/json; charset=utf-8
WARNING: [13:36:05][Get-DbaBuildReference] You need to choose at least one parameter.
PS C:\PSScript>
Error Stack
C:\PSScript> $error[0] | select *
writeErrorStream : True
PSMessageDetails :
Exception : System.Exception: You need to choose at least one parameter.
TargetObject :
CategoryInfo : InvalidArgument: (:) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_Get-DbaBuildReference,Stop-Function
ErrorDetails : You need to choose at least one parameter.
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Stop-Function, C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.116\allcommands.ps1: line 83939
at Get-DbaBuildReference<Process>, C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.116\allcommands.ps1: line 20371
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
running the following:
Get-DbaBuildReference -Update
or
Get-DbaBuildReference -Update -Verbose
dbatools should be updated. ideally a message should also indicate that it has been updated, what the version was and what it was updated to.
without the -Verbose switch I get this:
WARNING: [13:36:05][Get-DbaBuildReference] You need to choose at least one parameter.
if I add the -Verbose, I get this:
```VERBOSE: GET https://sqlcollaborative.github.io/assets/dbatools-buildref-index.json with 0-byte payload
VERBOSE: received 98199-byte response of content type application/json; charset=utf-8
WARNING: [13:36:05][Get-DbaBuildReference] You need to choose at least one parameter.
### Proposed Solution
Inside the allcommands.ps1 on line 20356 within the process section of funciton Get-DbaBuildReference. Why is 'Update' missing from the parm list? If it is added there as proposed below, then you can truly run the ```Get-DbaBuildReference -Update``` standalone to just update your build reference.
**change**
```PS
$ComplianceSpecExclusiveParams = @('Build', 'Kb', @( 'MajorVersion', 'ServicePack', 'CumulativeUpdate'), 'SqlInstance')
to
$ComplianceSpecExclusiveParams = @('Update', 'Build', 'Kb', @( 'MajorVersion', 'ServicePack', 'CumulativeUpdate'), 'SqlInstance')
Duplicate #6438
maybe we can support a "feature" allowing Get-DbaBuildReference -Update to return nothing and just be used to fetch the updated index.
I never thought about this particular usecase but I'm 100% on board with the feature request.
Or would it be more user friendly to just make it a separate command? Update-DbaBuildReference
I think that would clear up some understandings on how that file is managed and updated if we just made it a dedicated command...
having yet another separate command is an overkill IMHO, all that is needed is not to complain if Get-DbaBuildReference -Update is issued.
How exactly is it overkill? We have commands that literally perform $object.Disable; $object.Alter().
The point is that someone coming to discovery commands in our module (and on average are not going to read the help) see Get-Dba... and after reading best practices and use of keywords with functions will never make the connection "oh they have a parameter to change data". Having an Update command will make this more discoverable and more clear to users how they manage that asset in our module.
If you want to leave the -Update parameter itself no issue there, but a new command is now due because the conversation has been fairly constant on explaining how users update the file.
ah, gotcha. I thought users kept asking how to use Get-DbaBuildReference -Update only.
So we make Get-DbaBuildReference -Update work and then write also an Update-DbaBuildReference (no params) that is just a wrapper of Get-DbaBuildReference -Update. Agreed ?
I'm fine with that.