Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
clarity. The old names `*-SqlDscBIReportServer` and `*-SqlDscPBIReportServer`
are available as aliases for backward compatibility
([issue #2071](https://github.com/dsccommunity/SqlServerDsc/issues/2071)).
- `SqlProtocol`
- Refactored to use the public command `Get-SqlDscServerProtocolName` instead
of the deprecated private function `Get-ProtocolNameProperties`
([issue #2104](https://github.com/dsccommunity/SqlServerDsc/issues/2104)).
- Refactored to use the public command `Get-SqlDscServerProtocol` instead
of the deprecated private function `Get-ServerProtocolObject`
([issue #2104](https://github.com/dsccommunity/SqlServerDsc/issues/2104)).
- `SqlProtocolTcpIp`
- Refactored to use the public command `Get-SqlDscServerProtocol` instead
of the deprecated private function `Get-ServerProtocolObject`
([issue #2104](https://github.com/dsccommunity/SqlServerDsc/issues/2104)).
- `SqlPermission`
- Refactored to use the new object-based server permission commands
(`Grant-SqlDscServerPermission`, `Deny-SqlDscServerPermission`,
Expand Down Expand Up @@ -96,6 +107,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`System.Management.Automation.SwitchParameter` to follow PowerShell best practices.
([issue #2190](https://github.com/dsccommunity/SqlServerDsc/issues/2190)).

### Removed

- Removed deprecated private function `Get-ProtocolNameProperties` from the
SqlServerDsc.Common module. Use the public command `Get-SqlDscServerProtocolName`
instead ([issue #2104](https://github.com/dsccommunity/SqlServerDsc/issues/2104)).
- Removed deprecated private function `Get-ServerProtocolObject` from the
SqlServerDsc.Common module. Use the public command `Get-SqlDscServerProtocol`
instead ([issue #2104](https://github.com/dsccommunity/SqlServerDsc/issues/2104)).

## [17.3.0] - 2025-12-01

### Removed
Expand Down
22 changes: 10 additions & 12 deletions source/DSCResources/DSC_SqlProtocol/DSC_SqlProtocol.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function Get-TargetResource
HasMultiIPAddresses = $false
}

$protocolNameProperties = Get-ProtocolNameProperties -ProtocolName $ProtocolName
$protocolNameProperties = Get-SqlDscServerProtocolName -ProtocolName $ProtocolName

# Getting the server protocol properties by using the computer name.
$computerName = Get-ComputerName
Expand All @@ -95,13 +95,13 @@ function Get-TargetResource
Must connect to the local machine name because $ServerName can point
to a cluster instance or availability group listener.
#>
$getServerProtocolObjectParameters = @{
$getSqlDscServerProtocolParameters = @{
ServerName = $computerName
Instance = $InstanceName
InstanceName = $InstanceName
ProtocolName = $ProtocolName
}

$serverProtocolProperties = Get-ServerProtocolObject @getServerProtocolObjectParameters
$serverProtocolProperties = Get-SqlDscServerProtocol @getSqlDscServerProtocolParameters

if ($serverProtocolProperties)
{
Expand Down Expand Up @@ -229,12 +229,10 @@ function Set-TargetResource
$RestartTimeout = 120
)

$protocolNameProperties = Get-ProtocolNameProperties -ProtocolName $ProtocolName
$protocolNameProperties = Get-SqlDscServerProtocolName -ProtocolName $ProtocolName

<#
Compare the current state against the desired state. Calling this will
also import the necessary module to later call Get-ServerProtocolObject
which uses the SMO class ManagedComputer.
Compare the current state against the desired state.
#>
$propertyState = Compare-TargetResourceState @PSBoundParameters

Expand All @@ -254,13 +252,13 @@ function Set-TargetResource
Must connect to the local machine name because $ServerName can point
to a cluster instance or availability group listener.
#>
$getServerProtocolObjectParameters = @{
$getSqlDscServerProtocolParameters = @{
ServerName = $computerName
Instance = $InstanceName
InstanceName = $InstanceName
ProtocolName = $ProtocolName
}

$serverProtocolProperties = Get-ServerProtocolObject @getServerProtocolObjectParameters
$serverProtocolProperties = Get-SqlDscServerProtocol @getSqlDscServerProtocolParameters

if ($serverProtocolProperties)
{
Expand Down Expand Up @@ -459,7 +457,7 @@ function Test-TargetResource
$RestartTimeout = 120
)

$protocolNameProperties = Get-ProtocolNameProperties -ProtocolName $ProtocolName
$protocolNameProperties = Get-SqlDscServerProtocolName -ProtocolName $ProtocolName

Write-Verbose -Message (
$script:localizedData.TestDesiredState -f $protocolNameProperties.DisplayName, $InstanceName, $ServerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ function Get-TargetResource
Must connect to the local machine name because $ServerName can point
to a cluster instance or availability group listener.
#>
$getServerProtocolObjectParameters = @{
$getSqlDscServerProtocolParameters = @{
ServerName = $computerName
Instance = $InstanceName
InstanceName = $InstanceName
ProtocolName = 'TcpIp'
}

$serverProtocolProperties = Get-ServerProtocolObject @getServerProtocolObjectParameters
$serverProtocolProperties = Get-SqlDscServerProtocol @getSqlDscServerProtocolParameters

if ($serverProtocolProperties)
{
Expand Down Expand Up @@ -274,9 +274,7 @@ function Set-TargetResource
$IpAddressGroup = Convert-IpAdressGroupCasing -IpAddressGroup $IpAddressGroup

<#
Compare the current state against the desired state. Calling this will
also import the necessary module to later call Get-ServerProtocolObject
which uses the SMO class ManagedComputer.
Compare the current state against the desired state.
#>
$propertyState = Compare-TargetResourceState @PSBoundParameters

Expand All @@ -296,13 +294,13 @@ function Set-TargetResource
Must connect to the local machine name because $ServerName can point
to a cluster instance or availability group listener.
#>
$getServerProtocolObjectParameters = @{
$getSqlDscServerProtocolParameters = @{
ServerName = $computerName
Instance = $InstanceName
InstanceName = $InstanceName
ProtocolName = 'TcpIp'
}

$serverProtocolProperties = Get-ServerProtocolObject @getServerProtocolObjectParameters
$serverProtocolProperties = Get-SqlDscServerProtocol @getSqlDscServerProtocolParameters

if ($serverProtocolProperties)
{
Expand Down
2 changes: 0 additions & 2 deletions source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
'Find-ExceptionByNumber'
'Compare-ResourcePropertyState'
'Test-DscPropertyState'
'Get-ProtocolNameProperties'
'Get-ServerProtocolObject'
'Import-Assembly'
'ConvertTo-ServerInstanceName'
'Get-FilePathMajorVersion'
Expand Down
120 changes: 0 additions & 120 deletions source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1943,126 +1943,6 @@ function Find-ExceptionByNumber
return $errorFound
}

<#
.SYNOPSIS
Get static name properties of he specified protocol.

.PARAMETER ProtocolName
Specifies the name of network protocol to return name properties for.
Possible values are 'TcpIp', 'NamedPipes', or 'ShareMemory'.

.NOTES
The static values returned matches the values returned by the class
ServerProtocol. The property DisplayName could potentially be localized
while the property Name must be exactly like it is returned by the
class ServerProtocol, with the correct casing.

The Get-ProtocolNameProperties function is deprecated and should be removed
in the future when existing code has moved to new public commands.
#>
function Get-ProtocolNameProperties
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter(Mandatory = $true)]
[ValidateSet('TcpIp', 'NamedPipes', 'SharedMemory')]
[System.String]
$ProtocolName
)

$protocolNameProperties = @{ }

switch ($ProtocolName)
{
'TcpIp'
{
$protocolNameProperties.DisplayName = 'TCP/IP'
$protocolNameProperties.Name = 'Tcp'
}

'NamedPipes'
{
$protocolNameProperties.DisplayName = 'Named Pipes'
$protocolNameProperties.Name = 'Np'
}

'SharedMemory'
{
$protocolNameProperties.DisplayName = 'Shared Memory'
$protocolNameProperties.Name = 'Sm'
}
}

return $protocolNameProperties
}

<#
.SYNOPSIS
Returns the ServerProtocol object for the specified SQL Server instance
and protocol name.

.PARAMETER InstanceName
Specifies the name of the SQL Server instance to connect to.

.PARAMETER ProtocolName
Specifies the name of network protocol to be configured. Possible values
are 'TcpIp', 'NamedPipes', or 'ShareMemory'.

.PARAMETER ServerName
Specifies the host name of the SQL Server to connect to.

.NOTES
The class Microsoft.SqlServer.Management.Smo.Wmi.ServerProtocol is
returned by this function.
#>
function Get-ServerProtocolObject
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[System.String]
$InstanceName,

[Parameter(Mandatory = $true)]
[ValidateSet('TcpIp', 'NamedPipes', 'SharedMemory')]
[System.String]
$ProtocolName,

[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]
$ServerName
)

$serverProtocolProperties = $null

$newObjectParameters = @{
TypeName = 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer'
ArgumentList = @($ServerName)
}

$managedComputerObject = New-Object @newObjectParameters

$serverInstance = $managedComputerObject.ServerInstances[$InstanceName]

if ($serverInstance)
{
$protocolNameProperties = Get-ProtocolNameProperties -ProtocolName $ProtocolName

$serverProtocolProperties = $serverInstance.ServerProtocols[$protocolNameProperties.Name]
}
else
{
$errorMessage = $script:localizedData.FailedToObtainServerInstance -f $InstanceName, $ServerName
New-InvalidOperationException -Message $errorMessage
}

return $serverProtocolProperties
}

<#
.SYNOPSIS
Converts the combination of server name and instance name to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ ConvertFrom-StringData @'
NotOwnerOfClusterResource = The node '{0}' is not the owner of the cluster resource '{1}'. The owner is '{2}' so no restart is needed. (SQLCOMMON0067)
LoadedAssembly = Loaded the assembly '{0}'. (SQLCOMMON0068)
FailedToLoadAssembly = Failed to load the assembly '{0}'. (SQLCOMMON0069)
FailedToObtainServerInstance = Failed to obtain a SQL Server instance with name '{0}' on server '{1}'. Ensure the SQL Server instance exists on the server and that the 'SQLServer' module references a version of the 'Microsoft.SqlServer.Management.Smo.Wmi' library that supports the version of the SQL Server instance. (SQLCOMMON0070)
DatabaseEngineInstanceNotOnline = The SQL instance '{0}' was expected to have the status 'Online', but had status '{1}'. (SQLCOMMON0071)
WaitForDatabaseEngineInstanceStatus = The SQL instance status is '{0}' expected '{1}', waiting {2} seconds. (SQLCOMMON0072)
'@
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ ConvertFrom-StringData @'
NotOwnerOfClusterResource = The node '{0}' is not the owner of the cluster resource '{1}'. The owner is '{2}' so no restart is needed. (SQLCOMMON0067)
LoadedAssembly = Loaded the assembly '{0}'. (SQLCOMMON0068)
FailedToLoadAssembly = Failed to load the assembly '{0}'. (SQLCOMMON0069)
FailedToObtainServerInstance = Failed to obtain a SQL Server instance with name '{0}' on server '{1}'. Ensure the SQL Server instance exists on the server and that the 'SQLServer' module references a version of the 'Microsoft.SqlServer.Management.Smo.Wmi' library that supports the version of the SQL Server instance. (SQLCOMMON0070)
DatabaseEngineInstanceNotOnline = The SQL instance '{0}' was expected to have the status 'Online', but had status '{1}'. (SQLCOMMON0071)
WaitForDatabaseEngineInstanceStatus = The SQL instance status is '{0}' expected '{1}', waiting {2} seconds. (SQLCOMMON0072)
'@
Loading
Loading