1717 If parameter **Credential'* is not provided then the resource instance is
1818 run using the credential that runs the configuration.
1919
20+ . PARAMETER Protocol
21+ Specifies the network protocol to use when connecting to the _SQL Server_
22+ instance. Valid values are `'tcp'` for TCP/IP, `'np'` for Named Pipes,
23+ and `'lpc'` for Shared Memory.
24+
25+ If not specified, the connection will use the default protocol order
26+ configured on the client.
27+
28+ . PARAMETER Port
29+ Specifies the TCP port number to use when connecting to the _SQL Server_
30+ instance. This parameter is only applicable when connecting via TCP/IP.
31+
32+ If not specified for a named instance, the SQL Server Browser service
33+ will be used to determine the port. For default instances, port 1433
34+ is used by default.
35+
2036 . PARAMETER Reasons
2137 Returns the reason a property is not in desired state.
38+
39+ . NOTES
40+ The protocol values (`'tcp'`, `'np'`, `'lpc'`) are lowercase to match
41+ the SQL Server connection string prefix format, e.g.,
42+ `tcp:ServerName\Instance,Port`.
2243#>
2344class SqlResourceBase : ResourceBase
2445{
@@ -42,6 +63,15 @@ class SqlResourceBase : ResourceBase
4263 [PSCredential ]
4364 $Credential
4465
66+ [DscProperty ()]
67+ [ValidateSet (' tcp' , ' np' , ' lpc' )]
68+ [System.String ]
69+ $Protocol
70+
71+ [DscProperty ()]
72+ [Nullable [System.UInt16 ]]
73+ $Port
74+
4575 [DscProperty (NotConfigurable)]
4676 [SqlReason []]
4777 $Reasons
@@ -50,6 +80,18 @@ class SqlResourceBase : ResourceBase
5080 SqlResourceBase () : base ($PSScriptRoot )
5181 {
5282 $this.SqlServerObject = $null
83+
84+ <#
85+ These connection properties will not be enforced. Child classes
86+ should use += to append their own properties to this list.
87+ #>
88+ $this.ExcludeDscProperties = @ (
89+ ' ServerName'
90+ ' InstanceName'
91+ ' Credential'
92+ ' Protocol'
93+ ' Port'
94+ )
5395 }
5496
5597 <#
@@ -75,6 +117,16 @@ class SqlResourceBase : ResourceBase
75117 $connectSqlDscDatabaseEngineParameters.Credential = $this.Credential
76118 }
77119
120+ if ($this.Protocol )
121+ {
122+ $connectSqlDscDatabaseEngineParameters.Protocol = $this.Protocol
123+ }
124+
125+ if ($this.Port )
126+ {
127+ $connectSqlDscDatabaseEngineParameters.Port = $this.Port
128+ }
129+
78130 $this.SqlServerObject = Connect-SqlDscDatabaseEngine @connectSqlDscDatabaseEngineParameters
79131 }
80132
0 commit comments