From e57f99440cf93d3de55038142009a4ffde6d3a2e Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 31 Dec 2018 21:00:59 +0100 Subject: [PATCH 1/5] SqlServerDsc: Fixes integration test fail to install default instance (#1262) - Changes to SqlServerDsc - During testing in AppVeyor the Build Worker is restarted in the install step to make sure the are no residual changes left from a previous SQL Server install on the Build Worker done by the AppVeyor Team (issue #1260). --- CHANGELOG.md | 6 ++++++ appveyor.yml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 524442d19..93cc7ffff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +- Changes to SqlServerDsc + - During testing in AppVeyor the Build Worker is restarted in the install + step to make sure the are no residual changes left from a previous SQL + Server install on the Build Worker done by the AppVeyor Team + ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). + ## 12.1.0.0 - Changes to SqlServerDsc diff --git a/appveyor.yml b/appveyor.yml index d890750f8..d6acc116a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,9 @@ version: 9.0.{build}.0 image: Visual Studio 2017 install: - git clone https://github.com/PowerShell/DscResource.Tests + - ps: Start-Sleep -Seconds 5 + - ps: Restart-Computer -Force + - ps: Start-Sleep -Seconds 5 - ps: Write-Verbose -Message "PowerShell version $($PSVersionTable.PSVersion)" -Verbose - ps: Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - ps: Invoke-AppveyorInstallTask From ade176051c5b265c6dd27bbf1ab06811e3cd3964 Mon Sep 17 00:00:00 2001 From: Jess Pomfret Date: Tue, 1 Jan 2019 03:49:54 -0500 Subject: [PATCH 2/5] SqlServerLogin: Addresses issue #1096 - doesn't check properties if login is not present on server (#1240) - Change to SqlServerLogin so it doesn't check properties for absent logins. - Fix for (issue #1096). --- CHANGELOG.md | 2 ++ .../MSFT_SqlServerLogin.psm1 | 2 +- Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 | 33 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93cc7ffff..df96a6631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ step to make sure the are no residual changes left from a previous SQL Server install on the Build Worker done by the AppVeyor Team ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). +- Change to SqlServerLogin so it doesn't check properties for absent logins. + - Fix for ([issue #1096](https://github.com/PowerShell/SqlServerDsc/issues/1096)) ## 12.1.0.0 diff --git a/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 index fd8f30d8f..c005746b1 100644 --- a/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 +++ b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 @@ -381,7 +381,7 @@ function Test-TargetResource $testPassed = $false } - if ( $Ensure -eq 'Present' ) + if ( $Ensure -eq 'Present' -and $($loginInfo.Ensure) -eq 'Present' ) { if ( $LoginType -ne $loginInfo.LoginType ) { diff --git a/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 b/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 index c1da064de..28575cf42 100644 --- a/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 @@ -385,6 +385,17 @@ try Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly } + It 'Should not be checking login properties when Windows user is Absent' { + Mock -CommandName New-VerboseMessage -ParameterFilter {$message.contains('rather than WindowsUser')} + + $testTargetResource_WindowsUserAbsent_EnsurePresent = $testTargetResource_WindowsUserAbsent.Clone() + $testTargetResource_WindowsUserAbsent_EnsurePresent.Add( 'Ensure', 'Present' ) + + ( Test-TargetResource @testTargetResource_WindowsUserAbsent_EnsurePresent ) | Should -Be $false + + Assert-MockCalled -CommandName New-VerboseMessage -Scope It -Times 0 -Exactly + } + It 'Should return $false when the specified Windows group is Absent' { $testTargetResource_WindowsGroupAbsent_EnsurePresent = $testTargetResource_WindowsGroupAbsent.Clone() $testTargetResource_WindowsGroupAbsent_EnsurePresent.Add( 'Ensure', 'Present' ) @@ -394,6 +405,17 @@ try Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly } + It 'Should not be checking login properties when Windows group is Absent' { + Mock -CommandName New-VerboseMessage -ParameterFilter {$message.contains('rather than WindowsGroup')} + + $testTargetResource_WindowsGroupAbsent_EnsurePresent = $testTargetResource_WindowsGroupAbsent.Clone() + $testTargetResource_WindowsGroupAbsent_EnsurePresent.Add( 'Ensure', 'Present' ) + + ( Test-TargetResource @testTargetResource_WindowsGroupAbsent_EnsurePresent ) | Should -Be $false + + Assert-MockCalled -CommandName New-VerboseMessage -Scope It -Times 0 -Exactly + } + It 'Should return $false when the specified SQL Login is Absent' { $testTargetResource_SqlLoginAbsent_EnsurePresent = $testTargetResource_SqlLoginAbsent.Clone() $testTargetResource_SqlLoginAbsent_EnsurePresent.Add( 'Ensure', 'Present' ) @@ -403,6 +425,17 @@ try Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly } + It 'Should not be checking login properties when SQL Login is Absent' { + Mock -CommandName New-VerboseMessage -ParameterFilter {$message.contains('rather than SqlLogin')} + + $testTargetResource_SqlLoginAbsent_EnsurePresent = $testTargetResource_SqlLoginAbsent.Clone() + $testTargetResource_SqlLoginAbsent_EnsurePresent.Add( 'Ensure', 'Present' ) + + ( Test-TargetResource @testTargetResource_SqlLoginAbsent_EnsurePresent ) | Should -Be $false + + Assert-MockCalled -CommandName New-VerboseMessage -Scope It -Times 0 -Exactly + } + It 'Should return $true when the specified Windows user is Present' { $testTargetResource_WindowsUserPresent_EnsurePresent = $testTargetResource_WindowsUserPresent.Clone() $testTargetResource_WindowsUserPresent_EnsurePresent.Add( 'Ensure', 'Present' ) From cb7a48869065f842b1147f7a5b6fcead15e7a21b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 1 Jan 2019 14:56:38 +0100 Subject: [PATCH 3/5] Code cleanup: Change parameter names of Connect-SQL to align with resources (#1228) - Changes to SqlServerDsc - Code cleanup: Change parameter names of Connect-SQL to align with resources. --- CHANGELOG.md | 1 + DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 | 4 +- .../MSFT_SqlAGDatabase.psm1 | 8 +- .../MSFT_SqlAGListener.psm1 | 8 +- .../MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 | 6 +- .../MSFT_SqlAlwaysOnService.psm1 | 2 +- .../MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 | 4 +- .../MSFT_SqlDatabaseDefaultLocation.psm1 | 4 +- .../MSFT_SqlDatabaseOwner.psm1 | 4 +- .../MSFT_SqlDatabasePermission.psm1 | 4 +- .../MSFT_SqlDatabaseRecoveryModel.psm1 | 4 +- .../MSFT_SqlDatabaseRole.psm1 | 4 +- .../MSFT_SqlServerConfiguration.psm1 | 4 +- .../MSFT_SqlServerDatabaseMail.psm1 | 4 +- .../MSFT_SqlServerEndpoint.psm1 | 4 +- .../MSFT_SqlServerEndpointPermission.psm1 | 4 +- .../MSFT_SqlServerEndpointState.psm1 | 4 +- .../MSFT_SqlServerLogin.psm1 | 6 +- .../MSFT_SqlServerMaxDop.psm1 | 4 +- .../MSFT_SqlServerMemory.psm1 | 4 +- .../MSFT_SqlServerPermission.psm1 | 4 +- .../MSFT_SqlServerRole.psm1 | 4 +- DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 | 10 +- .../1-AddDatabaseToAvailabilityGroup.ps1 | 2 +- .../2-RemoveDatabaseFromAvailabilityGroup.ps1 | 16 +-- ...atchDefinedDatabaseInAvailabilityGroup.ps1 | 2 +- .../1-CreateAvailabilityGroupReplica.ps1 | 2 +- .../2-RemoveAvailabilityGroupReplica.ps1 | 14 +- ...eplicasEachWithDifferentServiceAccount.ps1 | 10 +- ...eplicasEachWithDifferentServiceAccount.ps1 | 10 +- SqlServerDscHelper.psm1 | 24 ++-- Tests/Unit/MSFT_SqlAG.Tests.ps1 | 64 ++++----- Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 | 132 +++++++++--------- Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 | 114 +++++++-------- .../MSFT_SqlServerConfiguration.Tests.ps1 | 4 +- Tests/Unit/SqlServerDSCHelper.Tests.ps1 | 52 +++---- 36 files changed, 276 insertions(+), 275 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df96a6631..cf3ac060c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ step to make sure the are no residual changes left from a previous SQL Server install on the Build Worker done by the AppVeyor Team ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). + - Code cleanup: Change parameter names of Connect-SQL to align with resources. - Change to SqlServerLogin so it doesn't check properties for absent logins. - Fix for ([issue #1096](https://github.com/PowerShell/SqlServerDsc/issues/1096)) diff --git a/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 b/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 index 41ca2887d..f03d37eaf 100644 --- a/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 +++ b/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 @@ -35,7 +35,7 @@ function Get-TargetResource ) # Connect to the instance - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Define current version for check compatibility $sqlMajorVersion = $serverObject.Version.Major @@ -233,7 +233,7 @@ function Set-TargetResource ) # Connect to the instance - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Determine if HADR is enabled on the instance. If not, throw an error if ( -not $serverObject.IsHadrEnabled ) diff --git a/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 b/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 index b934b1331..6660f8fec 100644 --- a/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 +++ b/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 @@ -72,7 +72,7 @@ function Get-TargetResource } # Connect to the instance - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Is this node actively hosting the SQL instance? $currentConfiguration.IsActiveNode = Test-ActiveNode -ServerObject $serverObject @@ -194,7 +194,7 @@ function Set-TargetResource Import-SQLPSModule # Connect to the defined instance - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Get the Availability Group $availabilityGroup = $serverObject.AvailabilityGroups[$AvailabilityGroupName] @@ -239,7 +239,7 @@ function Set-TargetResource foreach ( $availabilityGroupReplica in $secondaryReplicas ) { - $currentAvailabilityGroupReplicaServerObject = Connect-SQL -SQLServer $availabilityGroupReplica.Name + $currentAvailabilityGroupReplicaServerObject = Connect-SQL -ServerName $availabilityGroupReplica.Name $impersonatePermissionsStatus.Add( $availabilityGroupReplica.Name, ( Test-ImpersonatePermissions -ServerObject $currentAvailabilityGroupReplicaServerObject ) @@ -679,7 +679,7 @@ function Test-TargetResource } # Connect to the defined instance - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Get the Availability Group if it exists if ( -not [System.String]::IsNullOrEmpty($currentConfiguration.AvailabilityGroupName) ) diff --git a/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 b/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 index f9bd1f682..69a01d975 100644 --- a/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 +++ b/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 @@ -172,7 +172,7 @@ function Set-TargetResource { New-VerboseMessage -Message "Create listener on $AvailabilityGroup" - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $availabilityGroupObject = $sqlServerObject.AvailabilityGroups[$AvailabilityGroup] if ($availabilityGroupObject) @@ -220,7 +220,7 @@ function Set-TargetResource { New-VerboseMessage -Message "Remove listener from $AvailabilityGroup" - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $availabilityGroupObject = $sqlServerObject.AvailabilityGroups[$AvailabilityGroup] if ($availabilityGroupObject) @@ -273,7 +273,7 @@ function Set-TargetResource throw New-TerminatingError -ErrorType AvailabilityGroupListenerDHCPChangeError -FormatArgs @( $DHCP, $($availabilityGroupListenerState.DHCP) ) -ErrorCategory InvalidOperation } - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $availabilityGroupObject = $sqlServerObject.AvailabilityGroups[$AvailabilityGroup] if ($availabilityGroupObject) @@ -484,7 +484,7 @@ function Get-SQLAlwaysOnAvailabilityGroupListener Write-Debug "Connecting to availability group $Name as $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)" - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $availabilityGroupObject = $sqlServerObject.AvailabilityGroups[$AvailabilityGroup] if ($availabilityGroupObject) diff --git a/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 b/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 index fb0fc0c2a..f47eac2e5 100644 --- a/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 +++ b/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 @@ -43,7 +43,7 @@ function Get-TargetResource ) # Connect to the instance - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Is this node actively hosting the SQL instance? $isActiveNode = Test-ActiveNode -ServerObject $serverObject @@ -238,7 +238,7 @@ function Set-TargetResource Import-SQLPSModule # Connect to the instance - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Determine if HADR is enabled on the instance. If not, throw an error if ( -not $serverObject.IsHadrEnabled ) @@ -385,7 +385,7 @@ function Set-TargetResource else { # Connect to the instance that is supposed to house the primary replica - $primaryReplicaServerObject = Connect-SQL -SQLServer $PrimaryReplicaServerName -SQLInstanceName $PrimaryReplicaInstanceName + $primaryReplicaServerObject = Connect-SQL -ServerName $PrimaryReplicaServerName -InstanceName $PrimaryReplicaInstanceName # Verify the Availability Group exists on the supplied primary replica $primaryReplicaAvailabilityGroup = $primaryReplicaServerObject.AvailabilityGroups[$AvailabilityGroupName] diff --git a/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 b/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 index efc32ee76..4f6aa384e 100644 --- a/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 +++ b/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 @@ -40,7 +40,7 @@ function Get-TargetResource $InstanceName ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $isAlwaysOnEnabled = [System.Boolean] $sqlServerObject.IsHadrEnabled if ($isAlwaysOnEnabled -eq $true) diff --git a/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 b/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 index ae2333b79..0f3bd5150 100644 --- a/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 +++ b/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 @@ -56,7 +56,7 @@ function Get-TargetResource $Collation ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { @@ -142,7 +142,7 @@ function Set-TargetResource $Collation ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 b/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 index c623091c8..cd02b9b39 100644 --- a/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 +++ b/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 @@ -54,7 +54,7 @@ Function Get-TargetResource Write-Verbose -Message ($script:localizedData.GetCurrentPath -f $Type, $InstanceName) # Connect to the instance - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Is this node actively hosting the SQL instance? $isActiveNode = Test-ActiveNode -ServerObject $sqlServerObject @@ -153,7 +153,7 @@ Function Set-TargetResource else { Write-Verbose -Message ($script:localizedData.SettingDefaultPath -f $Type) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Check which default location is being updated switch ($Type) diff --git a/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 index 428f7e5d5..ce7268158 100644 --- a/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 +++ b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 @@ -45,7 +45,7 @@ function Get-TargetResource ) Write-Verbose -Message "Getting owner of database $Database" - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { @@ -123,7 +123,7 @@ function Set-TargetResource ) Write-Verbose -Message "Setting owner $Name of database $Database" - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 b/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 index 3cbb9981a..178180639 100644 --- a/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 +++ b/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 @@ -60,7 +60,7 @@ function Get-TargetResource $InstanceName ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { @@ -208,7 +208,7 @@ function Set-TargetResource $InstanceName = 'MSSQLSERVER' ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 b/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 index 651504f47..b5d698536 100644 --- a/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 +++ b/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 @@ -45,7 +45,7 @@ function Get-TargetResource $Name ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { @@ -118,7 +118,7 @@ function Set-TargetResource $Name ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 b/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 index d762dec66..df2e34ffd 100644 --- a/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 +++ b/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 @@ -58,7 +58,7 @@ function Get-TargetResource Write-Verbose -Message "Getting SQL Database role for $Name" - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { @@ -198,7 +198,7 @@ function Set-TargetResource Write-Verbose -Message "Setting SQL Database role for $Name" - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 b/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 index e67497ce5..ce273a68b 100644 --- a/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 +++ b/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 @@ -63,7 +63,7 @@ function Get-TargetResource $RestartTimeout = 120 ) - $sql = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sql = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Get the current value of the configuration option. $option = $sql.Configuration.Properties | Where-Object { $_.DisplayName -eq $OptionName } @@ -142,7 +142,7 @@ function Set-TargetResource $RestartTimeout = 120 ) - $sql = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sql = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Get the current value of the configuration option. $option = $sql.Configuration.Properties | Where-Object { $_.DisplayName -eq $OptionName } diff --git a/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 b/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 index abef48882..efc7b7ac9 100644 --- a/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 +++ b/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 @@ -83,7 +83,7 @@ function Get-TargetResource -f $ServerName, $InstanceName ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { @@ -292,7 +292,7 @@ function Set-TargetResource -f $ServerName, $InstanceName ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 index 464a6dc0a..1bc760540 100644 --- a/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 +++ b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 @@ -42,7 +42,7 @@ function Get-TargetResource IpAddress = '' } - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { Write-Verbose -Message ('Connected to {0}\{1}' -f $ServerName, $InstanceName) @@ -135,7 +135,7 @@ function Set-TargetResource $getTargetResourceResult = Get-TargetResource -EndpointName $EndpointName -ServerName $ServerName -InstanceName $InstanceName - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { if ($Ensure -eq 'Present' -and $getTargetResourceResult.Ensure -eq 'Absent') diff --git a/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 index 1d2b104d9..16bb3ae3c 100644 --- a/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 +++ b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 @@ -42,7 +42,7 @@ function Get-TargetResource try { - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $endpointObject = $sqlServerObject.Endpoints[$Name] if ( $null -ne $endpointObject ) @@ -147,7 +147,7 @@ function Set-TargetResource $getTargetResourceResult = Get-TargetResource @parameters if ($getTargetResourceResult.Ensure -ne $Ensure) { - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $endpointObject = $sqlServerObject.Endpoints[$Name] if ($null -ne $endpointObject) diff --git a/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 index b1deecd0c..59b6bf88b 100644 --- a/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 +++ b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 @@ -37,7 +37,7 @@ function Get-TargetResource try { - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $endpointObject = $sqlServerObject.Endpoints[$Name] if ($null -ne $endpointObject) @@ -114,7 +114,7 @@ function Set-TargetResource { New-VerboseMessage -Message ('Changing state of endpoint ''{0}''' -f $Name) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $endpointObject = $sqlServerObject.Endpoints[$Name] diff --git a/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 index c005746b1..d180eaa14 100644 --- a/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 +++ b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 @@ -34,7 +34,7 @@ function Get-TargetResource $InstanceName ) - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName Write-Verbose 'Getting SQL logins' New-VerboseMessage -Message "Getting the login '$Name' from '$ServerName\$InstanceName'" @@ -161,7 +161,7 @@ function Set-TargetResource $Disabled ) - $serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $serverObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName switch ( $Ensure ) { @@ -416,7 +416,7 @@ function Test-TargetResource try { - Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName -SetupCredential $userCredential -LoginType 'SqlLogin' | Out-Null + Connect-SQL -ServerName $ServerName -InstanceName $InstanceName -SetupCredential $userCredential -LoginType 'SqlLogin' | Out-Null } catch { diff --git a/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 b/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 index 78fb15965..be82a50cb 100644 --- a/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 +++ b/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 @@ -28,7 +28,7 @@ function Get-TargetResource $ServerName = $env:COMPUTERNAME ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Is this node actively hosting the SQL instance? $isActiveNode = Test-ActiveNode -ServerObject $sqlServerObject @@ -108,7 +108,7 @@ function Set-TargetResource $ProcessOnlyOnActiveNode ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 b/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 index b637df416..1efba49ec 100644 --- a/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 +++ b/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 @@ -28,7 +28,7 @@ function Get-TargetResource $ServerName = $env:COMPUTERNAME ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { @@ -116,7 +116,7 @@ function Set-TargetResource $ProcessOnlyOnActiveNode ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 b/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 index 86454008d..fbe9f3a99 100644 --- a/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 +++ b/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 @@ -45,7 +45,7 @@ function Get-TargetResource try { - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName # Gets a set of permissions granted based on the desired permissions in $Permission $desiredPermissionSet = Get-SQLServerPermissionSet -Permission $Permission @@ -149,7 +149,7 @@ function Set-TargetResource { try { - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $permissionSet = Get-SQLServerPermissionSet -Permission $Permission diff --git a/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 b/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 index 5ec21c9d0..59ae0e17d 100644 --- a/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 +++ b/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 @@ -62,7 +62,7 @@ function Get-TargetResource $InstanceName ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName $ensure = 'Present' if ($sqlServerObject) @@ -221,7 +221,7 @@ function Set-TargetResource $InstanceName ) - $sqlServerObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName + $sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName if ($sqlServerObject) { diff --git a/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 b/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 index c44cc376e..a49c38b80 100644 --- a/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 +++ b/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 @@ -125,7 +125,7 @@ function Get-TargetResource Write-Verbose -Message $script:localizedData.DatabaseEngineFeatureFound $features += 'SQLENGINE,' - + $sqlServiceCimInstance = (Get-CimInstance -ClassName Win32_Service -Filter "Name = '$databaseServiceName'") $agentServiceCimInstance = (Get-CimInstance -ClassName Win32_Service -Filter "Name = '$agentServiceName'") @@ -188,7 +188,7 @@ function Get-TargetResource $instanceId = $fullInstanceId.Split('.')[1] $instanceDirectory = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$fullInstanceId\Setup" -Name 'SqlProgramDir').SqlProgramDir.Trim("\") - $databaseServer = Connect-SQL -SQLServer $sqlHostName -SQLInstanceName $InstanceName + $databaseServer = Connect-SQL -ServerName $sqlHostName -InstanceName $InstanceName $sqlCollation = $databaseServer.Collation @@ -1313,7 +1313,7 @@ function Set-TargetResource { $setupArguments += @{ AgtSvcStartupType = 'Automatic' } } - + if ($PSBoundParameters.ContainsKey('SqlSvcStartupType')) { $setupArguments += @{ SqlSvcStartupType = $SqlSvcStartupType} @@ -1380,7 +1380,7 @@ function Set-TargetResource $setupArguments['ASSysAdminAccounts'] += $ASSysAdminAccounts } } - + if ($PSBoundParameters.ContainsKey('AsSvcStartupType')) { $setupArguments += @{ AsSvcStartupType = $AsSvcStartupType} @@ -1393,7 +1393,7 @@ function Set-TargetResource { $setupArguments += (Get-ServiceAccountParameters -ServiceAccount $ISSvcAccount -ServiceType 'IS') } - + if ($PSBoundParameters.ContainsKey('IsSvcStartupType')) { $setupArguments += @{ IsSvcStartupType = $IsSvcStartupType} diff --git a/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 index c48e2c70d..679c2f452 100644 --- a/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 @@ -12,7 +12,7 @@ $ConfigurationData = @{ AllNodes = @( @{ NodeName = '*' - InstanceName = 'MSSQLSERVER' + InstanceName = 'MSSQLSERVER' AvailabilityGroupName = 'TestAG' }, diff --git a/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 index 5333cb3d6..32f22a0f1 100644 --- a/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 @@ -7,7 +7,7 @@ $ConfigurationData = @{ AllNodes = @( @{ NodeName = '*' - SQLInstanceName = 'MSSQLSERVER' + InstanceName = 'MSSQLSERVER' AvailabilityGroupName = 'TestAG' }, @@ -41,7 +41,7 @@ Configuration Example Name = 'NT SERVICE\ClusSvc' LoginType = 'WindowsUser' ServerName = $Node.NodeName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName PsDscRunAsCredential = $SqlAdministratorCredential } @@ -51,7 +51,7 @@ Configuration Example DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Principal = 'NT SERVICE\ClusSvc' Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' PsDscRunAsCredential = $SqlAdministratorCredential @@ -64,7 +64,7 @@ Configuration Example Ensure = 'Present' Port = 5022 ServerName = $Node.NodeName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName PsDscRunAsCredential = $SqlAdministratorCredential } @@ -75,7 +75,7 @@ Configuration Example { Ensure = 'Present' Name = $Node.AvailabilityGroupName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName ServerName = $Node.NodeName DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SqlAdministratorCredential @@ -91,9 +91,9 @@ Configuration Example Name = $Node.NodeName AvailabilityGroupName = $Node.AvailabilityGroupName ServerName = $Node.NodeName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName PrimaryReplicaServerName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName - PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).SQLInstanceName + PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).InstanceName } } @@ -104,7 +104,7 @@ Configuration Example AvailabilityGroupName = $Node.AvailabilityGroupName BackupPath = '\\SQL1\AgInitialize' DatabaseName = 'DB*', 'AdventureWorks' - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName ServerName = $Node.NodeName Ensure = 'Absent' PsDscRunAsCredential = $SqlAdministratorCredential diff --git a/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 index e8218117b..72d7ae0e7 100644 --- a/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 @@ -7,7 +7,7 @@ $ConfigurationData = @{ AllNodes = @( @{ NodeName = '*' - InstanceName = 'MSSQLSERVER' + InstanceName = 'MSSQLSERVER' AvailabilityGroupName = 'TestAG' }, diff --git a/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 b/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 index 08fac49ce..e2434ca25 100644 --- a/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 +++ b/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 @@ -12,7 +12,7 @@ $ConfigurationData = @{ AllNodes = @( @{ NodeName = '*' - InstanceName = 'MSSQLSERVER' + InstanceName = 'MSSQLSERVER' AvailabilityGroupName = 'TestAG' ProcessOnlyOnActiveNode = $true }, diff --git a/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 b/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 index f7a51ec84..530de81ae 100644 --- a/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 +++ b/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 @@ -7,7 +7,7 @@ $ConfigurationData = @{ AllNodes = @( @{ NodeName = '*' - SQLInstanceName = 'MSSQLSERVER' + InstanceName = 'MSSQLSERVER' AvailabilityGroupName = 'TestAG' }, @@ -41,7 +41,7 @@ Configuration Example Name = 'NT SERVICE\ClusSvc' LoginType = 'WindowsUser' ServerName = $Node.NodeName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName PsDscRunAsCredential = $SqlAdministratorCredential } @@ -51,7 +51,7 @@ Configuration Example DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Principal = 'NT SERVICE\ClusSvc' Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' PsDscRunAsCredential = $SqlAdministratorCredential @@ -64,7 +64,7 @@ Configuration Example Ensure = 'Present' Port = 5022 ServerName = $Node.NodeName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName PsDscRunAsCredential = $SqlAdministratorCredential } @@ -75,7 +75,7 @@ Configuration Example { Ensure = 'Present' Name = $Node.AvailabilityGroupName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName ServerName = $Node.NodeName DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SqlAdministratorCredential @@ -91,9 +91,9 @@ Configuration Example Name = $Node.NodeName AvailabilityGroupName = $Node.AvailabilityGroupName ServerName = $Node.NodeName - InstanceName = $Node.SQLInstanceName + InstanceName = $Node.InstanceName PrimaryReplicaServerName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName - PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).SQLInstanceName + PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).InstanceName } } } diff --git a/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 b/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 index 2d14af6f1..387b5d6d8 100644 --- a/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 +++ b/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 @@ -8,7 +8,7 @@ $ConfigurationData = @{ AllNodes = @( @{ NodeName = '*' - SqlInstanceName = 'MSSQLSERVER' + InstanceName = 'MSSQLSERVER' }, @{ @@ -48,7 +48,7 @@ Configuration Example { Ensure = 'Present' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode1Credential.UserName Permission = 'CONNECT' @@ -60,7 +60,7 @@ Configuration Example { Ensure = 'Present' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode2Credential.UserName Permission = 'CONNECT' @@ -75,7 +75,7 @@ Configuration Example { Ensure = 'Present' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode1Credential.UserName Permission = 'CONNECT' @@ -87,7 +87,7 @@ Configuration Example { Ensure = 'Present' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode2Credential.UserName Permission = 'CONNECT' diff --git a/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 b/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 index 4ac8b2a42..818f9913f 100644 --- a/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 +++ b/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 @@ -8,7 +8,7 @@ $ConfigurationData = @{ AllNodes = @( @{ NodeName = '*' - SqlInstanceName = 'MSSQLSERVER' + InstanceName = 'MSSQLSERVER' }, @{ @@ -48,7 +48,7 @@ Configuration Example { Ensure = 'Absent' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode1Credential.UserName Permission = 'CONNECT' @@ -60,7 +60,7 @@ Configuration Example { Ensure = 'Absent' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode2Credential.UserName Permission = 'CONNECT' @@ -75,7 +75,7 @@ Configuration Example { Ensure = 'Absent' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode1Credential.UserName Permission = 'CONNECT' @@ -87,7 +87,7 @@ Configuration Example { Ensure = 'Absent' ServerName = $Node.NodeName - InstanceName = $Node.SqlInstanceName + InstanceName = $Node.InstanceName Name = 'DefaultMirrorEndpoint' Principal = $SqlServiceNode2Credential.UserName Permission = 'CONNECT' diff --git a/SqlServerDscHelper.psm1 b/SqlServerDscHelper.psm1 index 00222aeb6..73e4bb76b 100644 --- a/SqlServerDscHelper.psm1 +++ b/SqlServerDscHelper.psm1 @@ -32,12 +32,12 @@ function Connect-SQL [Parameter()] [ValidateNotNull()] [System.String] - $SQLServer = $env:COMPUTERNAME, + $ServerName = $env:COMPUTERNAME, [Parameter()] [ValidateNotNull()] [System.String] - $SQLInstanceName = 'MSSQLSERVER', + $InstanceName = 'MSSQLSERVER', [Parameter()] [ValidateNotNull()] @@ -52,13 +52,13 @@ function Connect-SQL Import-SQLPSModule - if ($SQLInstanceName -eq 'MSSQLSERVER') + if ($InstanceName -eq 'MSSQLSERVER') { - $databaseEngineInstance = $SQLServer + $databaseEngineInstance = $ServerName } else { - $databaseEngineInstance = "$SQLServer\$SQLInstanceName" + $databaseEngineInstance = "$ServerName\$InstanceName" } if ($SetupCredential) @@ -772,7 +772,7 @@ function Restart-SqlService if (-not $SkipClusterCheck.IsPresent) { ## Connect to the instance - $serverObject = Connect-SQL -SQLServer $SQLServer -SQLInstanceName $SQLInstanceName + $serverObject = Connect-SQL -ServerName $SQLServer -InstanceName $SQLInstanceName if ($serverObject.IsClustered) { @@ -855,7 +855,7 @@ function Restart-SqlService do { # This call, if it fails, will take between ~9-10 seconds to return. - $testConnectionServerObject = Connect-SQL -SQLServer $SQLServer -SQLInstanceName $SQLInstanceName -ErrorAction SilentlyContinue + $testConnectionServerObject = Connect-SQL -ServerName $SQLServer -InstanceName $SQLInstanceName -ErrorAction SilentlyContinue if ($testConnectionServerObject -and $testConnectionServerObject.Status -ne 'Online') { # Waiting 2 seconds to not hammer the SQL Server instance. @@ -996,7 +996,7 @@ function Invoke-Query $WithResults ) - $serverObject = Connect-SQL -SQLServer $SQLServer -SQLInstanceName $SQLInstanceName + $serverObject = Connect-SQL -ServerName $SQLServer -InstanceName $SQLInstanceName if ( $WithResults ) { @@ -1162,7 +1162,7 @@ function Test-AvailabilityReplicaSeedingModeAutomatic # Assume automatic seeding is disabled by default $availabilityReplicaSeedingModeAutomatic = $false - $serverObject = Connect-SQL -SQLServer $SQLServer -SQLInstanceName $SQLInstanceName + $serverObject = Connect-SQL -ServerName $SQLServer -InstanceName $SQLInstanceName # Only check the seeding mode if this is SQL 2016 or newer if ( $serverObject.Version -ge 13 ) @@ -1221,7 +1221,7 @@ function Get-PrimaryReplicaServerObject # Determine if we're connected to the primary replica if ( ( $AvailabilityGroup.PrimaryReplicaServerName -ne $serverObject.DomainInstanceName ) -and ( -not [System.String]::IsNullOrEmpty($AvailabilityGroup.PrimaryReplicaServerName) ) ) { - $primaryReplicaServerObject = Connect-SQL -SQLServer $AvailabilityGroup.PrimaryReplicaServerName + $primaryReplicaServerObject = Connect-SQL -ServerName $AvailabilityGroup.PrimaryReplicaServerName } return $primaryReplicaServerObject @@ -1288,8 +1288,8 @@ function Split-FullSQLInstanceName } return @{ - SQLServer = $sqlServer - SQLInstanceName = $sqlInstanceName + ServerName = $sqlServer + InstanceName = $sqlInstanceName } } diff --git a/Tests/Unit/MSFT_SqlAG.Tests.ps1 b/Tests/Unit/MSFT_SqlAG.Tests.ps1 index 92ee1e2df..26f787015 100644 --- a/Tests/Unit/MSFT_SqlAG.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAG.Tests.ps1 @@ -78,7 +78,7 @@ try } # Define the values that could be passed into the InstanceName parameter - $mockSqlInstanceNameParameters = @( + $mockInstanceNameParameters = @( 'MSSQLSERVER', 'NamedInstance' ) @@ -210,16 +210,16 @@ try foreach ( $mockSqlServerParameter in $mockSqlServer.Value.Values ) { - foreach ( $mockSqlInstanceNameParameter in $mockSqlInstanceNameParameters ) + foreach ( $mockInstanceNameParameter in $mockInstanceNameParameters ) { # Build the domain instance name - if ( $mockSqlInstanceNameParameter -eq 'MSSQLSERVER' ) + if ( $mockInstanceNameParameter -eq 'MSSQLSERVER' ) { $domainInstanceNameProperty = $mockSqlServerParameter } else { - $domainInstanceNameProperty = '{0}\{1}' -f $mockSqlServerParameter,$mockSqlInstanceNameParameter + $domainInstanceNameProperty = '{0}\{1}' -f $mockSqlServerParameter,$mockInstanceNameParameter } if ( $mockSqlServerToBeUsed -eq 'Server1' ) @@ -227,14 +227,14 @@ try $getTargetResourceAbsentTestCases += @{ Name = $mockNameParameters.AbsentAvailabilityGroup ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } $getTargetResourcePresentTestCases += @{ Name = $mockNameParameters.PresentAvailabilityGroup ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } @@ -245,7 +245,7 @@ try Ensure = 'Present' Name = $createAvailabilityGroupFailureToTest.Key ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } } @@ -255,7 +255,7 @@ try Name = $mockNameParameters.AbsentAvailabilityGroup Result = 'DatabaseMirroringEndpointNotFound' ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } @@ -264,7 +264,7 @@ try Name = $mockNameParameters.AbsentAvailabilityGroup Result = 'HadrNotEnabled' ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } @@ -272,7 +272,7 @@ try Ensure = 'Absent' Name = $mockNameParameters.PresentAvailabilityGroup ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } } @@ -297,7 +297,7 @@ try Ensure = 'Absent' Name = $setTargetResourceRemoveAvailabilityGroupErrorTestCaseName ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } @@ -308,7 +308,7 @@ try Name = $mockNameParameters.PresentAvailabilityGroup ProcessOnlyOnActiveNode = $processOnlyOnActiveNode ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } } @@ -321,7 +321,7 @@ try Name = $mockNameParameters.AbsentAvailabilityGroup Result = ( $ensureCaseToTest -eq 'Absent' ) ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } @@ -330,7 +330,7 @@ try Name = $mockNameParameters.PresentAvailabilityGroup Result = ( $ensureCaseToTest -eq 'Present' ) ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } } @@ -394,7 +394,7 @@ try ParameterName = $resourceParameter.Key ParameterValue = $testCaseParameterValue ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } } @@ -406,7 +406,7 @@ try ParameterValue = $testCaseParameterValue Result = $false ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } @@ -417,7 +417,7 @@ try ParameterValue = $testCaseParameterValue Result = $false ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } } @@ -445,7 +445,7 @@ try Ensure = 'Present' Name = $mockNameParameters.PresentAvailabilityGroup ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } @@ -456,7 +456,7 @@ try Name = $mockNameParameters.PresentAvailabilityGroup Result = $false ServerName = $mockSqlServerParameter - InstanceName = $mockSqlInstanceNameParameter + InstanceName = $mockInstanceNameParameter Version = $majorVersionToTest } } @@ -474,11 +474,11 @@ try ( [Parameter()] [System.String] - $SQLServer, + $ServerName, [Parameter()] [System.String] - $SQLInstanceName, + $InstanceName, # The following two parameters are used to mock Get-PrimaryReplicaServerObject [Parameter()] @@ -491,21 +491,21 @@ try ) # If this mock function is called from the Get-PrimaryReplicaServerObject command mock - if ( [System.String]::IsNullOrEmpty($SQLServer) -and [System.String]::IsNullOrEmpty($SQLInstanceName) -and $AvailabilityGroup -and $ServerObject ) + if ( [System.String]::IsNullOrEmpty($ServerName) -and [System.String]::IsNullOrEmpty($InstanceName) -and $AvailabilityGroup -and $ServerObject ) { - $SQLServer,$SQLInstanceName = $AvailabilityGroup.PrimaryReplicaServerName.Split('\') + $ServerName,$InstanceName = $AvailabilityGroup.PrimaryReplicaServerName.Split('\') } # Determine which SQL Server mock data we will use - $mockSqlServer = ( $mockSqlServerParameters.GetEnumerator() | Where-Object -FilterScript { $_.Value.Values -contains $SQLServer } ).Name + $mockSqlServer = ( $mockSqlServerParameters.GetEnumerator() | Where-Object -FilterScript { $_.Value.Values -contains $ServerName } ).Name if ( [System.String]::IsNullOrEmpty($mockSqlServer) ) { - $mockSqlServer = $SQLServer + $mockSqlServer = $ServerName } $mockCurrentServerObjectProperties = $mockServerObjectProperties.$mockSqlServer # Build the domain instance name - if ( ( $SQLInstanceName -eq 'MSSQLSERVER' ) -or [System.String]::IsNullOrEmpty($SQLInstanceName) ) + if ( ( $InstanceName -eq 'MSSQLSERVER' ) -or [System.String]::IsNullOrEmpty($InstanceName) ) { $mockDomainInstanceName = $mockCurrentServerObjectProperties.NetName $mockPrimaryReplicaServerName = $mockAvailabilityGroupProperties.PrimaryReplicaServerName @@ -514,19 +514,19 @@ try } else { - $mockDomainInstanceName = '{0}\{1}' -f $mockCurrentServerObjectProperties.NetName,$SQLInstanceName - $mockPrimaryReplicaServerName = '{0}\{1}' -f $mockAvailabilityGroupProperties.PrimaryReplicaServerName,$SQLInstanceName - $mockAvailabilityGroupReplica1Name = '{0}\{1}' -f $mockAvailabilityGroupReplicaProperties.Server1.Name,$SQLInstanceName - $mockAvailabilityGroupReplica2Name = '{0}\{1}' -f $mockAvailabilityGroupReplicaProperties.Server2.Name,$SQLInstanceName + $mockDomainInstanceName = '{0}\{1}' -f $mockCurrentServerObjectProperties.NetName,$InstanceName + $mockPrimaryReplicaServerName = '{0}\{1}' -f $mockAvailabilityGroupProperties.PrimaryReplicaServerName,$InstanceName + $mockAvailabilityGroupReplica1Name = '{0}\{1}' -f $mockAvailabilityGroupReplicaProperties.Server1.Name,$InstanceName + $mockAvailabilityGroupReplica2Name = '{0}\{1}' -f $mockAvailabilityGroupReplicaProperties.Server2.Name,$InstanceName } $mockServerObject = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server $mockServerObject.DomainInstanceName = $mockDomainInstanceName $mockServerObject.IsHadrEnabled = $mockIsHadrEnabled - $mockServerObject.Name = $SQLServer + $mockServerObject.Name = $ServerName $mockServerObject.NetName = $mockCurrentServerObjectProperties.NetName - $mockServerObject.ServiceName = $SQLInstanceName + $mockServerObject.ServiceName = $InstanceName $mockServerObject.Version = @{ Major = $Version } diff --git a/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 b/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 index 9786856db..b6ccbb3a9 100644 --- a/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 @@ -468,9 +468,9 @@ WITH NORECOVERY' Mock -CommandName Add-SqlAvailabilityDatabase -Verifiable -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Mock -CommandName Backup-SqlDatabase -Verifiable -ParameterFilter { $BackupAction -eq 'Database' } Mock -CommandName Backup-SqlDatabase -Verifiable -ParameterFilter { $BackupAction -eq 'Log'} - Mock -CommandName Connect-SQL -MockWith { return $mockServerObject } -Verifiable -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Mock -CommandName Connect-SQL -MockWith { return $mockServerObject } -Verifiable -ParameterFilter { $SqlServer -eq 'Server1' } - Mock -CommandName Connect-SQL -MockWith { return $mockServer2Object } -Verifiable -ParameterFilter { $SqlServer -eq 'Server2' } + Mock -CommandName Connect-SQL -MockWith { return $mockServerObject } -Verifiable -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Mock -CommandName Connect-SQL -MockWith { return $mockServerObject } -Verifiable -ParameterFilter { $ServerName -eq 'Server1' } + Mock -CommandName Connect-SQL -MockWith { return $mockServer2Object } -Verifiable -ParameterFilter { $ServerName -eq 'Server2' } Mock -CommandName Invoke-Query -MockWith $mockResultInvokeQueryFileExist -Verifiable -ParameterFilter { $Query -like 'EXEC master.dbo.xp_fileexist *' } Mock -CommandName Remove-SqlAvailabilityDatabase -Verifiable Mock -CommandName Test-ImpersonatePermissions -MockWith { $true } -Verifiable @@ -486,9 +486,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -515,9 +515,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -544,9 +544,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -573,9 +573,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -602,9 +602,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -655,9 +655,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -687,9 +687,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -725,9 +725,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -758,9 +758,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -791,9 +791,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -824,9 +824,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -857,9 +857,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -890,9 +890,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -919,9 +919,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -948,9 +948,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -977,9 +977,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 2 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -1006,9 +1006,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -1039,9 +1039,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -1068,9 +1068,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -1097,9 +1097,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 0 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly @@ -1131,9 +1131,9 @@ WITH NORECOVERY' Assert-MockCalled -CommandName Add-SqlAvailabilityDatabase -Scope It -Times 0 -Exactly -ParameterFilter { $InputObject.PrimaryReplicaServerName -eq 'Server2' -and $InputObject.LocalReplicaRole -eq 'Secondary' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Database' } Assert-MockCalled -CommandName Backup-SqlDatabase -Scope It -Times 1 -Exactly -ParameterFilter { $BackupAction -eq 'Log' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' -and $SQLInstanceName -eq 'MSSQLSERVER' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $SqlServer -eq 'Server1' } - Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $SqlServer -eq 'Server2' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' -and $InstanceName -eq 'MSSQLSERVER' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 1 -Exactly -ParameterFilter { $ServerName -eq 'Server1' } + Assert-MockCalled -CommandName Connect-SQL -Scope It -Times 3 -Exactly -ParameterFilter { $ServerName -eq 'Server2' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 1 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Times 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } Assert-MockCalled -CommandName Import-SQLPSModule -Scope It -Times 1 -Exactly diff --git a/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 b/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 index c3eca28c9..ba16315cd 100644 --- a/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 @@ -182,11 +182,11 @@ try ( [Parameter()] [System.String] - $SQLServer, + $ServerName, [Parameter()] [System.String] - $SQLInstanceName, + $InstanceName, # The following two parameters are used to mock Get-PrimaryReplicaServerObject [Parameter()] @@ -285,11 +285,11 @@ try ( [Parameter()] [System.String] - $SQLServer, + $ServerName, [Parameter()] [System.String] - $SQLInstanceName, + $InstanceName, # The following two parameters are used to mock Get-PrimaryReplicaServerObject [Parameter()] @@ -405,11 +405,11 @@ try ( [Parameter()] [System.String] - $SQLServer, + $ServerName, [Parameter()] [System.String] - $SQLInstanceName, + $InstanceName, # The following two parameters are used to mock Get-PrimaryReplicaServerObject [Parameter()] @@ -631,13 +631,13 @@ try $mockServer1IsHadrEnabled = $true Mock -CommandName Connect-SQL -MockWith $mockConnectSqlServer1 -Verifiable -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } Mock -CommandName Connect-SQL -MockWith $mockConnectSqlServer2 -Verifiable -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } Mock -CommandName Connect-SQL -MockWith $mockConnectSqlServer3 -Verifiable -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } Mock -CommandName Get-PrimaryReplicaServerObject -MockWith $mockConnectSqlServer1 -Verifiable -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -678,13 +678,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -711,13 +711,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw 'RemoveAvailabilityGroupReplicaFailed' Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -772,13 +772,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw 'HadrNotEnabled' Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -807,13 +807,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -838,13 +838,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -871,13 +871,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw 'DatabaseMirroringEndpointNotFound' Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -904,13 +904,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -937,13 +937,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 1 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -970,13 +970,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw 'CreateAvailabilityGroupReplicaFailed' Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -1003,13 +1003,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw 'JoinAvailabilityGroupFailed' Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -1036,13 +1036,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw 'AvailabilityGroupNotFound' Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -1111,13 +1111,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Throw 'ReplicaNotFound' Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -1148,13 +1148,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -1182,13 +1182,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -1217,13 +1217,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name @@ -1252,13 +1252,13 @@ try { Set-TargetResource @setTargetResourceParameters } | Should -Not -Throw Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer1Name + $ServerName -eq $mockServer1Name } -Times 1 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer2Name + $ServerName -eq $mockServer2Name } -Times 0 -Exactly Assert-MockCalled -CommandName Connect-SQL -Scope It -ParameterFilter { - $SQLServer -eq $mockServer3Name + $ServerName -eq $mockServer3Name } -Times 0 -Exactly Assert-MockCalled -CommandName Get-PrimaryReplicaServerObject -Scope It -Time 0 -Exactly -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq $mockServer1Name diff --git a/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 b/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 index 7f51c0b74..67fcb2b5d 100644 --- a/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 @@ -222,7 +222,7 @@ try $mock.Configuration | Add-Member -MemberType ScriptMethod -Name Alter -Value {} return $mock - } -ModuleName $script:DSCResourceName -Verifiable -ParameterFilter { $SQLServer -eq 'CLU01' } + } -ModuleName $script:DSCResourceName -Verifiable -ParameterFilter { $ServerName -eq 'CLU01' } Mock -CommandName Connect-SQL -MockWith { $mock = New-Object -TypeName PSObject -Property @{ @@ -241,7 +241,7 @@ try $mock.Configuration | Add-Member -MemberType ScriptMethod -Name Alter -Value {} return $mock - } -ModuleName $script:DSCResourceName -Verifiable -ParameterFilter { $SQLServer -eq 'CLU02' } + } -ModuleName $script:DSCResourceName -Verifiable -ParameterFilter { $ServerName -eq 'CLU02' } Mock -CommandName Restart-SqlService -ModuleName $script:DSCResourceName -Verifiable Mock -CommandName Write-Warning -ModuleName $script:DSCResourceName -Verifiable diff --git a/Tests/Unit/SqlServerDSCHelper.Tests.ps1 b/Tests/Unit/SqlServerDSCHelper.Tests.ps1 index 371468004..6901308d8 100644 --- a/Tests/Unit/SqlServerDSCHelper.Tests.ps1 +++ b/Tests/Unit/SqlServerDSCHelper.Tests.ps1 @@ -153,7 +153,7 @@ InModuleScope $script:moduleName { Status = $mockDynamicStatus IsClustered = $false } - } -Verifiable -ParameterFilter { $SQLInstanceName -eq 'MSSQLSERVER' } + } -Verifiable -ParameterFilter { $InstanceName -eq 'MSSQLSERVER' } Mock -CommandName Connect-SQL -MockWith { return @{ @@ -163,7 +163,7 @@ InModuleScope $script:moduleName { Status = $mockDynamicStatus IsClustered = $true } - } -Verifiable -ParameterFilter { $SQLInstanceName -eq 'NOCLUSTERCHECK' } + } -Verifiable -ParameterFilter { $InstanceName -eq 'NOCLUSTERCHECK' } Mock -CommandName Connect-SQL -MockWith { return @{ @@ -173,7 +173,7 @@ InModuleScope $script:moduleName { Status = $mockDynamicStatus IsClustered = $true } - } -Verifiable -ParameterFilter { $SQLInstanceName -eq 'NOCONNECT' } + } -Verifiable -ParameterFilter { $InstanceName -eq 'NOCONNECT' } Mock -CommandName Connect-SQL -MockWith { return @{ @@ -182,7 +182,7 @@ InModuleScope $script:moduleName { ServiceName = 'NOAGENT' Status = $mockDynamicStatus } - } -Verifiable -ParameterFilter { $SQLInstanceName -eq 'NOAGENT' } + } -Verifiable -ParameterFilter { $InstanceName -eq 'NOAGENT' } Mock -CommandName Connect-SQL -MockWith { return @{ @@ -191,7 +191,7 @@ InModuleScope $script:moduleName { ServiceName = 'STOPPEDAGENT' Status = $mockDynamicStatus } - } -Verifiable -ParameterFilter { $SQLInstanceName -eq 'STOPPEDAGENT' } + } -Verifiable -ParameterFilter { $InstanceName -eq 'STOPPEDAGENT' } } BeforeAll { @@ -326,7 +326,7 @@ InModuleScope $script:moduleName { ServiceName = 'MSSQLSERVER' Status = $mockDynamicStatus } - } -Verifiable -ParameterFilter { $SQLInstanceName -eq 'MSSQLSERVER' } + } -Verifiable -ParameterFilter { $InstanceName -eq 'MSSQLSERVER' } } $mockDynamicStatus = 'Offline' @@ -359,7 +359,7 @@ InModuleScope $script:moduleName { IsClustered = $true Status = $mockDynamicStatus } - } -Verifiable -ParameterFilter { ($SQLServer -eq 'CLU01') -and ($SQLInstanceName -eq 'MSSQLSERVER') } + } -Verifiable -ParameterFilter { ($ServerName -eq 'CLU01') -and ($InstanceName -eq 'MSSQLSERVER') } Mock -CommandName Connect-SQL -MockWith { return @{ @@ -369,7 +369,7 @@ InModuleScope $script:moduleName { IsClustered = $true Status = $mockDynamicStatus } - } -Verifiable -ParameterFilter { ($SQLServer -eq 'CLU01') -and ($SQLInstanceName -eq 'NAMEDINSTANCE') } + } -Verifiable -ParameterFilter { ($ServerName -eq 'CLU01') -and ($InstanceName -eq 'NAMEDINSTANCE') } Mock -CommandName Connect-SQL -MockWith { return @{ @@ -379,7 +379,7 @@ InModuleScope $script:moduleName { IsClustered = $true Status = $mockDynamicStatus } - } -Verifiable -ParameterFilter { ($SQLServer -eq 'CLU01') -and ($SQLInstanceName -eq 'STOPPEDAGENT') } + } -Verifiable -ParameterFilter { ($ServerName -eq 'CLU01') -and ($InstanceName -eq 'STOPPEDAGENT') } } BeforeAll { @@ -1056,17 +1056,17 @@ InModuleScope $script:moduleName { ( [Parameter()] [System.String] - $SQLServer, + $ServerName, [Parameter()] [System.String] - $SQLInstanceName + $InstanceName ) $mock = @( ( New-Object -TypeName Object | - Add-Member -MemberType NoteProperty -Name 'DomainInstanceName' -Value $SQLServer -PassThru + Add-Member -MemberType NoteProperty -Name 'DomainInstanceName' -Value $ServerName -PassThru ) ) @@ -1123,11 +1123,11 @@ InModuleScope $script:moduleName { ( [Parameter()] [System.String] - $SQLServer, + $ServerName, [Parameter()] [System.String] - $SQLInstanceName + $InstanceName ) $mock = @( @@ -1240,7 +1240,7 @@ InModuleScope $script:moduleName { } } - Describe 'Testing Connect-SQL' -Tag ConnectSql { + Describe 'Testing Connect-SQL' -Tag 'ConnectSql' { BeforeEach { Mock -CommandName New-InvalidOperationException -MockWith $mockThrowLocalizedMessage -Verifiable Mock -CommandName Import-SQLPSModule @@ -1255,7 +1255,7 @@ InModuleScope $script:moduleName { $mockExpectedDatabaseEngineServer = 'TestServer' $mockExpectedDatabaseEngineInstance = 'MSSQLSERVER' - $databaseEngineServerObject = Connect-SQL -SQLServer $mockExpectedDatabaseEngineServer + $databaseEngineServerObject = Connect-SQL -ServerName $mockExpectedDatabaseEngineServer $databaseEngineServerObject.ConnectionContext.ServerInstance | Should -BeExactly $mockExpectedDatabaseEngineServer Assert-MockCalled -CommandName New-Object -Exactly -Times 1 -Scope It ` @@ -1269,7 +1269,7 @@ InModuleScope $script:moduleName { $mockExpectedDatabaseEngineInstance = 'MSSQLSERVER' $mockExpectedDatabaseEngineLoginSecure = $false - $databaseEngineServerObject = Connect-SQL -SQLServer $mockExpectedDatabaseEngineServer -SetupCredential $mockSetupCredential -LoginType 'SqlLogin' + $databaseEngineServerObject = Connect-SQL -ServerName $mockExpectedDatabaseEngineServer -SetupCredential $mockSetupCredential -LoginType 'SqlLogin' $databaseEngineServerObject.ConnectionContext.LoginSecure | Should -Be $false $databaseEngineServerObject.ConnectionContext.Login | Should -Be $mockSetupCredentialUserName $databaseEngineServerObject.ConnectionContext.SecurePassword | Should -Be $mockSetupCredentialSecurePassword @@ -1285,7 +1285,7 @@ InModuleScope $script:moduleName { $mockExpectedDatabaseEngineServer = $env:COMPUTERNAME $mockExpectedDatabaseEngineInstance = $mockInstanceName - $databaseEngineServerObject = Connect-SQL -SQLInstanceName $mockExpectedDatabaseEngineInstance + $databaseEngineServerObject = Connect-SQL -InstanceName $mockExpectedDatabaseEngineInstance $databaseEngineServerObject.ConnectionContext.ServerInstance | Should -BeExactly "$mockExpectedDatabaseEngineServer\$mockExpectedDatabaseEngineInstance" Assert-MockCalled -CommandName New-Object -Exactly -Times 1 -Scope It ` @@ -1299,7 +1299,7 @@ InModuleScope $script:moduleName { $mockExpectedDatabaseEngineInstance = $mockInstanceName $mockExpectedDatabaseEngineLoginSecure = $false - $databaseEngineServerObject = Connect-SQL -SQLInstanceName $mockExpectedDatabaseEngineInstance -SetupCredential $mockSetupCredential -LoginType 'SqlLogin' + $databaseEngineServerObject = Connect-SQL -InstanceName $mockExpectedDatabaseEngineInstance -SetupCredential $mockSetupCredential -LoginType 'SqlLogin' $databaseEngineServerObject.ConnectionContext.LoginSecure | Should -Be $false $databaseEngineServerObject.ConnectionContext.Login | Should -Be $mockSetupCredentialUserName $databaseEngineServerObject.ConnectionContext.SecurePassword | Should -Be $mockSetupCredentialSecurePassword @@ -1315,7 +1315,7 @@ InModuleScope $script:moduleName { $mockExpectedDatabaseEngineServer = 'SERVER' $mockExpectedDatabaseEngineInstance = $mockInstanceName - $databaseEngineServerObject = Connect-SQL -SQLServer $mockExpectedDatabaseEngineServer -SQLInstanceName $mockExpectedDatabaseEngineInstance + $databaseEngineServerObject = Connect-SQL -ServerName $mockExpectedDatabaseEngineServer -InstanceName $mockExpectedDatabaseEngineInstance $databaseEngineServerObject.ConnectionContext.ServerInstance | Should -BeExactly "$mockExpectedDatabaseEngineServer\$mockExpectedDatabaseEngineInstance" Assert-MockCalled -CommandName New-Object -Exactly -Times 1 -Scope It ` @@ -1329,8 +1329,8 @@ InModuleScope $script:moduleName { $mockExpectedDatabaseEngineInstance = $mockInstanceName $testParameters = @{ - SQLServer = $mockExpectedDatabaseEngineServer - SQLInstanceName = $mockExpectedDatabaseEngineInstance + ServerName = $mockExpectedDatabaseEngineServer + InstanceName = $mockExpectedDatabaseEngineInstance SetupCredential = $mockSetupCredential } @@ -1716,16 +1716,16 @@ InModuleScope $script:moduleName { $result = Split-FullSQLInstanceName -FullSQLInstanceName 'ServerName' $result.Count | Should -Be 2 - $result.SQLServer | Should -Be 'ServerName' - $result.SQLInstanceName | Should -Be 'MSSQLSERVER' + $result.ServerName | Should -Be 'ServerName' + $result.InstanceName | Should -Be 'MSSQLSERVER' } It 'Should throw when the "FullSQLInstanceName" parameter is "ServerName\InstanceName"' { $result = Split-FullSQLInstanceName -FullSQLInstanceName 'ServerName\InstanceName' $result.Count | Should -Be 2 - $result.SQLServer | Should -Be 'ServerName' - $result.SQLInstanceName | Should -Be 'InstanceName' + $result.ServerName | Should -Be 'ServerName' + $result.InstanceName | Should -Be 'InstanceName' } } } From 5757fdbb425988f8063b43bf41da4012c352552e Mon Sep 17 00:00:00 2001 From: Adam Rush Date: Thu, 3 Jan 2019 16:46:14 +0000 Subject: [PATCH 4/5] Fixed Examples README.md (#1241) - Changes to SqlServerDsc - Updated README.md in the Examples folder. - Added a link to the new xADObjectPermissionEntry examples in ActiveDirectory, fixed a broken link and a typo. --- CHANGELOG.md | 4 ++++ Examples/README.md | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf3ac060c..d761df126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Server install on the Build Worker done by the AppVeyor Team ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). - Code cleanup: Change parameter names of Connect-SQL to align with resources. + - Updated README.md in the Examples folder. + - Added a link to the new xADObjectPermissionEntry examples in + ActiveDirectory, fixed a broken link and a typo. + [Adam Rush (@adamrushuk)](https://github.com/adamrushuk) - Change to SqlServerLogin so it doesn't check properties for absent logins. - Fix for ([issue #1096](https://github.com/PowerShell/SqlServerDsc/issues/1096)) diff --git a/Examples/README.md b/Examples/README.md index 64d5bc090..e99ec7d67 100644 --- a/Examples/README.md +++ b/Examples/README.md @@ -69,15 +69,15 @@ Preferably the CNO should be added to an Active Directory security group and tha group has the permission to create computer objects inside the OU. This way, more than one CNO computer object can use the same OU. -There are currently no examples in xActiveDirectory to link to, so here are some -examples how this can be done. - Please note that the prestaged CNO computer object must be disabled before creating the failover cluster, and that the security group must be given the permission **Create Computer Objects** on the OU where the CNO computer object was created. Also the user creating the failover cluster must have the permission **Full Control** on the CNO computer object. -***There are currently no resources to do either of this.*** + +The [xADObjectPermissionEntry examples](https://github.com/PowerShell/xActiveDirectory/tree/dev/Examples/Resources/xADObjectPermissionEntry) +at the resource module [xActiveDirectory](https://github.com/PowerShell/xActiveDirectory) +can be used to set the correct permissions. ```powershell <# @@ -191,13 +191,13 @@ Availability Group. #### Enable AlwaysOn on both primary and secondary replica AlwaysOn must be enabled on both the primary and secondary replica, and the example -[Enable AlwaysOn](vhttps://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1) +[Enable AlwaysOn](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1) shows how to enable it (which requires that a working Failover Cluster is present on the node). #### Configure SQL Server AlwaysOn Availability Group -Once AlwaysOn is enabled we can create the Availabilty Group. The example [Create Availability Group](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1) +Once AlwaysOn is enabled we can create the Availability Group. The example [Create Availability Group](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1) shows how to create the Availability Group on the primary replica and join the Availability Group on the secondary replica. From c78a95cab99c70d4e067fd2f9b2e9408abf5dfff Mon Sep 17 00:00:00 2001 From: Katie Kragenbrink Date: Wed, 9 Jan 2019 13:51:31 -0800 Subject: [PATCH 5/5] Releasing version 12.2.0.0 --- CHANGELOG.md | 2 ++ SqlServerDsc.psd1 | 65 ++++++++++------------------------------------- 2 files changed, 15 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d761df126..22e62fe45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +## 12.2.0.0 + - Changes to SqlServerDsc - During testing in AppVeyor the Build Worker is restarted in the install step to make sure the are no residual changes left from a previous SQL diff --git a/SqlServerDsc.psd1 b/SqlServerDsc.psd1 index 4503a033e..3cfd6ca81 100644 --- a/SqlServerDsc.psd1 +++ b/SqlServerDsc.psd1 @@ -1,6 +1,6 @@ @{ # Version number of this module. - moduleVersion = '12.1.0.0' + moduleVersion = '12.2.0.0' # ID used to uniquely identify this module GUID = '693ee082-ed36-45a7-b490-88b07c86b42f' @@ -50,57 +50,17 @@ # ReleaseNotes of this module ReleaseNotes = '- Changes to SqlServerDsc - - Add support for validating the code with the DSC ResourceKit - Script Analyzer rules, both in Visual Studio Code and directly using - `Invoke-ScriptAnalyzer`. - - Opt-in for common test "Common Tests - Validate Markdown Links". - - Updated broken links in `\README.md` and in `\Examples\README.md` - - Opt-in for common test "Common Tests - Relative Path Length". - - Updated the Installation section in the README.md. - - Updated the Contributing section in the README.md after - [Style Guideline and Best Practices guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) - has merged into one document. - - To speed up testing in AppVeyor, unit tests are now run in two containers. - - Adding the PowerShell script `Assert-TestEnvironment.ps1` which - must be run prior to running any unit tests locally with - `Invoke-Pester`. - Read more in the specific contributing guidelines, under the section - [Unit Tests](https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.mdunit-tests). -- Changes to SqlServerDscHelper - - Fix style guideline lint errors. - - Changes to Connect-SQL - - Adding verbose message in Connect-SQL so it - now shows the username that is connecting. - - Changes to Import-SQLPS - - Fixed so that when importing SQLPS it imports - using the path (and not the .psd1 file). - - Fixed so that the verbose message correctly - shows the name, version and path when importing - the module SQLPS (it did show correctly for the - SqlServer module). -- Changes to SqlAg, SqlAGDatabase, and SqlAGReplica examples - - Included configuration for SqlAlwaysOnService to enable - HADR on each node to avoid confusion - ([issue 1182](https://github.com/PowerShell/SqlServerDsc/issues/1182)). -- Changes to SqlServerDatabaseMail - - Minor update to Ensure parameter description in the README.md. -- Changes to Write-ModuleStubFile.ps1 - - Create aliases for cmdlets in the stubbed module which have aliases - ([issue 1224](https://github.com/PowerShell/SqlServerDsc/issues/1224)). - [Dan Reist (@randomnote1)](https://github.com/randomnote1) - - Use a string builder to build the function stubs. - - Fixed formatting issues for the function to work with modules other - than SqlServer. -- New DSC resource SqlServerSecureConnection - - New resource to configure a SQL Server instance for encrypted SQL - connections. -- Changes to SqlAlwaysOnService - - Updated integration tests to use NetworkingDsc - ([issue 1129](https://github.com/PowerShell/SqlServerDsc/issues/1129)). -- Changes to SqlServiceAccount - - Fix unit tests that didn"t mock some of the calls. It no longer fail - when a SQL Server installation is not present on the node running the - unit test ([issue 983](https://github.com/PowerShell/SqlServerDsc/issues/983)). + - During testing in AppVeyor the Build Worker is restarted in the install + step to make sure the are no residual changes left from a previous SQL + Server install on the Build Worker done by the AppVeyor Team + ([issue 1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). + - Code cleanup: Change parameter names of Connect-SQL to align with resources. + - Updated README.md in the Examples folder. + - Added a link to the new xADObjectPermissionEntry examples in + ActiveDirectory, fixed a broken link and a typo. + [Adam Rush (@adamrushuk)](https://github.com/adamrushuk) +- Change to SqlServerLogin so it doesn"t check properties for absent logins. + - Fix for ([issue 1096](https://github.com/PowerShell/SqlServerDsc/issues/1096)) ' @@ -126,3 +86,4 @@ +