forked from dsccommunity/SqlServerDsc
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAssert-Feature.ps1
More file actions
59 lines (49 loc) · 1.6 KB
/
Assert-Feature.ps1
File metadata and controls
59 lines (49 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<#
.SYNOPSIS
Assert that a feature is supported by a Microsoft SQL Server major version.
.DESCRIPTION
Assert that a feature is supported by a Microsoft SQL Server major version.
.PARAMETER Feature
Specifies the feature to evaluate.
.PARAMETER ProductVersion
Specifies the product version of the Microsoft SQL Server. At minimum the
major version must be provided.
.EXAMPLE
Assert-Feature -Feature 'RS' -ProductVersion '14'
Throws an exception if the feature is not supported.
.INPUTS
`System.String[]`
Accepts an array of feature names via the pipeline.
.OUTPUTS
None.
#>
function Assert-Feature
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[System.String[]]
$Feature,
[Parameter(Mandatory = $true)]
[System.String]
$ProductVersion
)
process
{
foreach ($currentFeature in $Feature)
{
if (-not ($currentFeature | Test-SqlDscIsSupportedFeature -ProductVersion $ProductVersion))
{
$PSCmdlet.ThrowTerminatingError(
[System.Management.Automation.ErrorRecord]::new(
($script:localizedData.Feature_Assert_NotSupportedFeature -f $currentFeature, $ProductVersion),
'AF0001', # cSpell: disable-line
[System.Management.Automation.ErrorCategory]::InvalidOperation,
$currentFeature
)
)
}
}
}
}