Get‑SqlDscCompatibilityLevel - dsccommunity/SqlServerDsc GitHub Wiki

SYNOPSIS

Gets the supported database compatibility levels for a SQL Server instance or version.

SYNTAX

ServerObject (Default)

Get-SqlDscCompatibilityLevel -ServerObject <Server> [<CommonParameters>]

Version

Get-SqlDscCompatibilityLevel -Version <Version> [<CommonParameters>]

DESCRIPTION

This command returns the supported database compatibility levels for a SQL Server Database Engine instance or a specific SQL Server version.

The compatibility levels are determined based on the SQL Server version, following the official Microsoft documentation for supported compatibility level ranges.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Get-SqlDscCompatibilityLevel -ServerObject $serverObject

Returns all supported compatibility levels for the connected SQL Server instance.

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Get-SqlDscCompatibilityLevel

Returns all supported compatibility levels using pipeline input.

EXAMPLE 3

Get-SqlDscCompatibilityLevel -Version '16.0.1000.6'

Returns all supported compatibility levels for SQL Server 2022 (version 16).

PARAMETERS

-ServerObject

Specifies the SQL Server connection object to get supported compatibility levels for.

Type: Server
Parameter Sets: ServerObject
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Version

Specifies the SQL Server version to get supported compatibility levels for. Only the major version number is used for determining compatibility levels.

Type: Version
Parameter Sets: Version
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Microsoft.SqlServer.Management.Smo.Server

The server object to get supported compatibility levels for.

OUTPUTS

System.String[]

Returns an array of supported compatibility level names (e.g., 'Version160', 'Version150').

NOTES

RELATED LINKS

⚠️ **GitHub.com Fallback** ⚠️