Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlInstall: New resource #1912

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,19 @@
"creplace",
"dbatools",
"db_datareader",
"fastbuild"
"fastbuild",
"SSMS",
"HKEY",
"POWERPIVOT",
"Tempdb",
"NPENABLED",
"TCPENABLED",
"RSINSTALLMODE",
"SVCACCOUNT",
"SVCPASSWORD",
"SQLSERVERAGENT",
"MSSQLFD",
"MSRS"
],
"cSpell.ignorePaths": [
".git"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- New class-based resource:
- `SqlInstall` - Handles the Microsoft SQL Server setup action `Install`.
- New public commands:
- `Disconnect-SqlDscDatabaseEngine` - Disconnects from a SQL Server instance
that was previously connected to using `Connect-SqlDscDatabaseEngine`.
Expand All @@ -197,6 +199,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
for a file.
- `Assert-Feature` - Throws an exception if a feature is not supported
for a specific Microsoft SQL Server major version.
- `Get-RegistryPropertyValue` - Returns the value of the provided property
at the provided registry path.
- `ConvertFrom-ServiceStartMode` - Converts the specified start mode to
the equivalent normalized startup type.
- `Get-InstanceId` - Returns the SQL Server instance id of the specified
service type and instance name.
- SqlServerDsc.Common
- `Connect-SQL`.
- Add new parameter `Encrypt`.
Expand Down
86 changes: 86 additions & 0 deletions source/Classes/005.InstalledComponentSetting.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<#
.SYNOPSIS
Common properties across all components that can be installed.

.EXAMPLE
[InstalledComponentSetting]::new()

Creates a new empty object.

.NOTES
This class should be parent of an derived class that have more properties
that are unique for each component.
#>
class InstalledComponentSetting
{
[System.String[]]
$FeatureList

[System.Version]
$Version

[System.Version]
$PatchLevel

[System.String]
$Edition

[System.String]
$EditionType

[Nullable[System.UInt32]]
$Language

[System.String]
$ProductCode

[System.String]
$SqlPath

InstalledComponentSetting ()
{
}

static [InstalledComponentSetting] op_Addition([InstalledComponentSetting] $Left, [InstalledComponentSetting] $Right)
{
$propertyList = $Left.PSObject.Properties.Name

foreach ($property in $propertyList)
{
# Only add values if left side is $null and right side is not null.
if (-not $Left.$property -and $Right.$property)
{
$Left.$property = $Right.$property
}
}

return $Left
}

static [InstalledComponentSetting] Parse([PSCustomObject] $Settings)
{
$installedComponentSetting = [InstalledComponentSetting]::new()

if ($settings.FeatureList)
{
$installedComponentSetting.FeatureList = $settings.FeatureList -split ' '
}

$propertyList = (
$installedComponentSetting.PSObject.Properties |
Where-Object -FilterScript {
$_.Name -ne 'FeatureList'
}
).Name

foreach ($property in $propertyList)
{
if ($settings.$property)
{
$installedComponentSetting.$property = $settings.$property
}
}

return $installedComponentSetting
}
}
4 changes: 2 additions & 2 deletions source/Classes/011.SqlResourceBase.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<#
.SYNOPSIS
The SqlResource base have generic properties and methods for the class-based
resources.
The SqlResourceBase have generic properties and methods that are common for
all the class-based resources.

.PARAMETER InstanceName
The name of the _SQL Server_ instance to be configured. Default value is
Expand Down
34 changes: 34 additions & 0 deletions source/Classes/015.SqlSetupBase.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<#
.SYNOPSIS
The SqlSetupBase have generic properties and methods that are common for
the setup action class-based resources.

.PARAMETER MediaPath
Specifies the path where to find the SQL Server installation media. On this
path the SQL Server setup executable must be found.

.PARAMETER ConfigurationFile
Specifies an configuration file to use during SQL Server setup. This
parameter cannot be used together with any of the setup actions, but instead
it is expected that the configuration file specifies what setup action to
run.

.PARAMETER Timeout
Specifies how long to wait for the setup process to finish. Uses the default
value of the command `Install-SqlDscServer`. If the setup process does not
finish before this time, an exception will be thrown.
#>
class SqlSetupBase : SqlResourceBase
{
[DscProperty(Mandatory)]
[System.String]
$MediaPath

[DscProperty()]
[System.String]
$ConfigurationFile

[DscProperty()]
[System.UInt32]
$Timeout
}
Loading
Loading