dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.39k stars 787 forks source link

Update-DbaInstance not installing latest security update for a CU #9327

Open dokier opened 2 months ago

dokier commented 2 months ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

WARNING: [10:28:44][Get-SqlInstanceUpdate] 14.0.3460 on computer [mysqlserver.domain.com] is already the latest available.

Steps to Reproduce

I have a SQL Server 2017 instance I was trying to patch to the latest available build version (14.0.3465.1) This is 5029376 Security update for SQL Server 2017 CU31: October 10, 2023. You can also refer to https://sqlserverbuilds.blogspot.com/

# provide your command(s) executed pertaining to dbatools
Update-DbaInstance -ComputerName mysqlserver -Restart -Path \\share\Updates -Confirm:$false
# please include variable values (redacted or fake if needed) for reference

Please confirm that you are running the most recent version of dbatools

2.1.14

Other details or mentions

dbatools-buildref-index.json has the latest information

{ "CU": "CU31", "Version": "14.0.3456", "KBList": "5016884" }, { "Version": "14.0.3460", "KBList": "5021126" }, { "Version": "14.0.3465", "KBList": "5029376" },

but because the last two elements do not have "CU" tags, these are not installed. This all comes down to Get-SqlInstanceUpdate calling Test-DbaBuild on line 109.

$latestCU = Test-DbaBuild -Build $currentVersion.BuildLevel -MaxBehind '0CU'

If this is by designed, should we have an option in Update-DbaInstance to override this so that it includes security updates for a CU? You can always specify the KB in the cmdlet but that doesn't scale well when you're passing a long list of servers that includes different versions of SQL.

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.20348.2227
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.2227
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

SQL 2017, (14.0.3465.1) now, but that's because I ended up using Update-DbaInstance by specifying the KB number.

.NET Framework Version

PSChildName Version


Client 4.8.04161 Full 4.8.04161 Client 4.0.0.0