< Back
Test-DbaBuild
Post
NAME Test-DbaBuild
SYNOPSIS
Returns SQL Server Build "compliance" level on a build.
SYNTAX
Test-DbaBuild [[-Build] <System.Version[]>] [[-MinimumBuild] <Version>] [[-MaxBehind] <String>] [-Latest <Switch>]
[[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential] <Pscredential>]
[-Update <Switch>] [-Quiet <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Returns info about the specific build of a SQL instance, including the SP, the CU and the reference KB, End Of
Support, wherever possible. It adds a Compliance property as true/false, and adds details about the "targeted
compliance".
The build data used can be found here: https://dbatools.io/builds
PARAMETERS
-Build [<System.Version[]>]
Instead of connecting to a real instance, pass a string identifying the build to get the info back.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Latest [<Switch>]
Shortcut for specifying the very most up-to-date build available.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MaxBehind [<String>]
Instead of using a specific MinimumBuild here you can pass "how many service packs and cu back" is the
targeted compliance level. You can use xxSP or xxCU or both, where xx is a number. See the Examples for more
information.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MinimumBuild [<Version>]
This is the build version to test "compliance" against. Anything below this is flagged as not compliant.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Quiet [<Switch>]
Makes the function just return $true/$false. It's useful if you use Test-DbaBuild in your own scripts.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
Target any number of instances, in order to return their compliance state.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Update [<Switch>]
Looks online for the most up to date reference, replacing the local one.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: SqlBuild, Version
Author: Simone Bizzotto (@niphold) | Friedrich Weinmann (@FredWeinmann)
dbatools PowerShell module (https://dbatools.io)
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MinimumBuild "12.0.5557"
Returns information about a build identified by "12.0.5540" (which is SQL 2014 with SP2 and CU4), which is not
compliant as the minimum required
build is "12.0.5557" (which is SQL 2014 with SP2 and CU8).
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MaxBehind "1SP"
Returns information about a build identified by "12.0.5540", making sure it is AT MOST 1 Service Pack "behind".
For that version,
that identifies an SP2, means accepting as the lowest compliance version as "12.0.4110", that identifies 2014 with
SP1.
Output column CUTarget is not relevant (empty). SPTarget and BuildTarget are filled in the result.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MaxBehind "1SP 1CU"
Returns information about a build identified by "12.0.5540", making sure it is AT MOST 1 Service Pack "behind",
plus 1 CU "behind". For that version,
that identifies an SP2 and CU, rolling back 1 SP brings you to "12.0.4110", but given the latest CU for SP1 is
CU13, the target "compliant" build
will be "12.0.4511", which is 2014 with SP1 and CU12.
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MaxBehind "0CU"
Returns information about a build identified by "12.0.5540", making sure it is the latest CU release.
Output columns CUTarget, SPTarget and BuildTarget are relevant. If the latest build is a service pack (not a CU),
CUTarget will be empty.
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -Latest
Returns information about a build identified by "12.0.5540", making sure it is the latest build available.
Output columns CUTarget and SPTarget are not relevant (empty), only the BuildTarget is.
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Test-DbaBuild -Build "12.00.4502" -MinimumBuild "12.0.4511" -Update
Same as before, but tries to fetch the most up to date index online. When the online version is newer, the local
one gets overwritten.
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.4502","10.50.4260" -MinimumBuild "12.0.4511"
Returns information builds identified by these versions strings.
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Get-DbaRegServer -SqlInstance sqlserver2014a | Test-DbaBuild -MinimumBuild "12.0.4511"
Integrate with other cmdlets to have builds checked for all your registered servers on sqlserver2014a.
RELATED LINKS
https://dbatools.io/Test-DbaBuild
SYNOPSIS
Returns SQL Server Build "compliance" level on a build.
SYNTAX
Test-DbaBuild [[-Build] <System.Version[]>] [[-MinimumBuild] <Version>] [[-MaxBehind] <String>] [-Latest <Switch>]
[[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential] <Pscredential>]
[-Update <Switch>] [-Quiet <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Returns info about the specific build of a SQL instance, including the SP, the CU and the reference KB, End Of
Support, wherever possible. It adds a Compliance property as true/false, and adds details about the "targeted
compliance".
The build data used can be found here: https://dbatools.io/builds
PARAMETERS
-Build [<System.Version[]>]
Instead of connecting to a real instance, pass a string identifying the build to get the info back.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Latest [<Switch>]
Shortcut for specifying the very most up-to-date build available.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MaxBehind [<String>]
Instead of using a specific MinimumBuild here you can pass "how many service packs and cu back" is the
targeted compliance level. You can use xxSP or xxCU or both, where xx is a number. See the Examples for more
information.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MinimumBuild [<Version>]
This is the build version to test "compliance" against. Anything below this is flagged as not compliant.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Quiet [<Switch>]
Makes the function just return $true/$false. It's useful if you use Test-DbaBuild in your own scripts.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
Target any number of instances, in order to return their compliance state.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Update [<Switch>]
Looks online for the most up to date reference, replacing the local one.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: SqlBuild, Version
Author: Simone Bizzotto (@niphold) | Friedrich Weinmann (@FredWeinmann)
dbatools PowerShell module (https://dbatools.io)
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MinimumBuild "12.0.5557"
Returns information about a build identified by "12.0.5540" (which is SQL 2014 with SP2 and CU4), which is not
compliant as the minimum required
build is "12.0.5557" (which is SQL 2014 with SP2 and CU8).
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MaxBehind "1SP"
Returns information about a build identified by "12.0.5540", making sure it is AT MOST 1 Service Pack "behind".
For that version,
that identifies an SP2, means accepting as the lowest compliance version as "12.0.4110", that identifies 2014 with
SP1.
Output column CUTarget is not relevant (empty). SPTarget and BuildTarget are filled in the result.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MaxBehind "1SP 1CU"
Returns information about a build identified by "12.0.5540", making sure it is AT MOST 1 Service Pack "behind",
plus 1 CU "behind". For that version,
that identifies an SP2 and CU, rolling back 1 SP brings you to "12.0.4110", but given the latest CU for SP1 is
CU13, the target "compliant" build
will be "12.0.4511", which is 2014 with SP1 and CU12.
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -MaxBehind "0CU"
Returns information about a build identified by "12.0.5540", making sure it is the latest CU release.
Output columns CUTarget, SPTarget and BuildTarget are relevant. If the latest build is a service pack (not a CU),
CUTarget will be empty.
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.5540" -Latest
Returns information about a build identified by "12.0.5540", making sure it is the latest build available.
Output columns CUTarget and SPTarget are not relevant (empty), only the BuildTarget is.
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Test-DbaBuild -Build "12.00.4502" -MinimumBuild "12.0.4511" -Update
Same as before, but tries to fetch the most up to date index online. When the online version is newer, the local
one gets overwritten.
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Test-DbaBuild -Build "12.0.4502","10.50.4260" -MinimumBuild "12.0.4511"
Returns information builds identified by these versions strings.
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Get-DbaRegServer -SqlInstance sqlserver2014a | Test-DbaBuild -MinimumBuild "12.0.4511"
Integrate with other cmdlets to have builds checked for all your registered servers on sqlserver2014a.
RELATED LINKS
https://dbatools.io/Test-DbaBuild