diff --git a/DSCResources/MSFT_xSQLAOGroupEnsure/MSFT_xSQLAOGroupEnsure.psm1 b/DSCResources/MSFT_xSQLAOGroupEnsure/MSFT_xSQLAOGroupEnsure.psm1 index 65bf72bcf7..c8a0fd423c 100644 --- a/DSCResources/MSFT_xSQLAOGroupEnsure/MSFT_xSQLAOGroupEnsure.psm1 +++ b/DSCResources/MSFT_xSQLAOGroupEnsure/MSFT_xSQLAOGroupEnsure.psm1 @@ -129,12 +129,12 @@ function Set-TargetResource $FailoverCondition = 3 $HealthCheckTimeout = 30000 - $ConnectionModeInPrimary ="AllowAllConnections" + $ConnectionModeInPrimary = "AllowAllConnections" $ConnectionModeInSecondaryRole = switch ($ReadableSecondary) { 'None' {"AllowNoConnections"} 'ReadOnly' {"AllowAllConnections"} - 'ReadIntent'{"AllowReadIntentConnectionsOnly"} + 'ReadIntent' {"AllowReadIntentConnectionsOnly"} Default {"AllowAllConnections"} } @@ -149,17 +149,16 @@ function Set-TargetResource $availabilityGroup.AutomatedBackupPreference = $AutoBackupPreference $availabilityGroup.FailureConditionLevel = $FailoverCondition $availabilityGroup.HealthCheckTimeout = $HealthCheckTimeout - } + } Catch { Throw "Failed to connect to Cluster Nodes from $($sql.ClusterName)" - Exit - } + } - #Loop through Sync nodes Create Replica Object Assign properties and add it to AvailabilityGroup - foreach ($node in $syncNodes) - { + #Loop through Sync nodes Create Replica Object Assign properties and add it to AvailabilityGroup + foreach ($node in $syncNodes) + { Try { $Replica = New-Object -typename Microsoft.SqlServer.Management.Smo.AvailabilityReplica -ArgumentList $availabilityGroup, $node @@ -176,8 +175,7 @@ function Set-TargetResource { Throw "Failed to add $Replica to the Availability Group $AvailabilityGroupName" Exit - } - + } } #Loop through ASync nodes Create Replica Object Assign properties and add it to AvailabilityGroup @@ -236,42 +234,38 @@ function Set-TargetResource } Catch{ Throw "Failed to Add $AvailabilityGroupNameListener to $AvailabilityGroupName..." - Exit - } + } #Add Availabilty Group to the SQL connection Try{ $SQL.AvailabilityGroups.Add($availabilityGroup) New-VerboseMessage -Message "Added $availabilityGroupName Availability Group to Connection" - } + } Catch{ Throw "Unable to Add $AvailabilityGroup to $SQLServer\$SQLInstanceName" Exit - } + } #Create Availability Group - Try - { + Try{ $availabilityGroup.Create() New-VerboseMessage -Message "Created Availability Group $availabilityGroupName" - } - Catch - { + } + Catch{ Throw "Unable to Create $AvailabilityGroup on $SQLServer\$SQLInstanceName" Exit - } + } } "Absent" { - Try - { + Try{ $sql.AvailabilityGroups[$AvailabilityGroupName].Drop() New-VerboseMessage -Message "Dropped $AvailabilityGroupName" - } + } Catch{ Throw "Unable to Drop $AvailabilityGroup on $SQLServer\$SQLInstanceName" - } + } } } @@ -279,7 +273,6 @@ function Set-TargetResource } - function Test-TargetResource { [CmdletBinding()] @@ -340,15 +333,13 @@ function Test-TargetResource Switch ($Ensure) { "Present" - { - - $AGPresent=$sql.AvailabilityGroups.Contains($AvailabilityGroupName) - - if ($AGPresent) - {$Return = $true} - else - {$Return = $false} - } + { + $AGPresent=$sql.AvailabilityGroups.Contains($AvailabilityGroupName) + if ($AGPresent) + {$Return = $true} + else + {$Return = $false} + } "Absent" { if(!$sql.AvailabilityGroups[$AvailabilityGroupName]) diff --git a/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.psm1 b/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.psm1 index 0d453c9b5d..c6eacf0a00 100644 --- a/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.psm1 +++ b/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.psm1 @@ -8,7 +8,7 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] $Name @@ -17,13 +17,13 @@ function Get-TargetResource Write-Verbose -Message 'Get-TargetResource' $returnValue = @{ - Name = [System.String] - Protocol = [System.String] - ServerName = [System.String] - TCPPort = [System.Int32] - PipeName = [System.String] - Ensure = [System.String] - } + Name = [System.String] + Protocol = [System.String] + ServerName = [System.String] + TCPPort = [System.Int32] + PipeName = [System.String] + Ensure = [System.String] + } if ($null -ne (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo' -Name "$Name" -ErrorAction SilentlyContinue)) { @@ -54,7 +54,7 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] $Name, @@ -161,18 +161,15 @@ function Set-TargetResource } } } - - } - function Test-TargetResource { [CmdletBinding()] [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] $Name, diff --git a/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.schema.mof b/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.schema.mof index 4272659ebc..3deebbd407 100644 Binary files a/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.schema.mof and b/DSCResources/MSFT_xSQLAlias/MSFT_xSQLAlias.schema.mof differ diff --git a/README.md b/README.md index 9dddbdd8cb..9451e6a4cb 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,7 @@ Please check out common DSC Resources [contributing guidelines](https://github.c ### Unreleased * Added resources - xSQLServerReplication + - xSQLAlias * Added tests for resources - xSQLServerPermission - xSQLServerEndpointState @@ -345,6 +346,8 @@ Please check out common DSC Resources [contributing guidelines](https://github.c - Fixed the issue when trying to add a static IP to a listener was ignored. * Fixes in xSQLAOGroupEnsure - Added parameters to New-ListenerADObject to allow usage of a named instance. +* Pester Test for xSQLAlias +* Correction on xSQLAOGroupEnsure to pass Setup Credential Correctly ### 1.8.0.0 * Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey. @@ -358,14 +361,6 @@ Please check out common DSC Resources [contributing guidelines](https://github.c - xSQLServerEndpointPermission - xSQLServerAvailabilityGroupListener * xSQLServerHelper - - added functions - - Import-SQLPSModule - - Get-SQLPSInstanceName - - Get-SQLPSInstance - - Get-SQLAlwaysOnEndpoint - - modified functions - - New-TerminatingError - *added optional parameter `InnerException` to be able to give the user more information in the returned message* - - added functions - Import-SQLPSModule - Get-SQLPSInstanceName @@ -373,11 +368,6 @@ Please check out common DSC Resources [contributing guidelines](https://github.c - Get-SQLAlwaysOnEndpoint - modified functions - New-TerminatingError - *added optional parameter `InnerException` to be able to give the user more information in the returned message* -* Pester Tests for xSQLAOGroupEnsure and xSQLAlias -* Correction on xSQLAOGroupEnsure to pass Setup Credential Correctly - -* Resources Added - * xSQLAlias ### 1.7.0.0