From dde0254485adbe54ff6f2b75bb3bfedea63968c3 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Fri, 15 May 2026 11:16:50 +0100 Subject: [PATCH 01/11] Remove script resource items --- .../DSC_RDConnectionBrokerHAMode.psm1 | 167 ----------- .../DSC_RDConnectionBrokerHAMode.schema.mof | 9 - .../DSC_RDConnectionBrokerHAMode/README.md | 3 - .../DSC_RDConnectionBrokerHAMode.strings.psd1 | 7 - .../DSC_RDConnectionBrokerHAMode.Tests.ps1 | 269 ------------------ 5 files changed, 455 deletions(-) delete mode 100644 source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.psm1 delete mode 100644 source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.schema.mof delete mode 100644 source/DSCResources/DSC_RDConnectionBrokerHAMode/README.md delete mode 100644 source/DSCResources/DSC_RDConnectionBrokerHAMode/en-US/DSC_RDConnectionBrokerHAMode.strings.psd1 delete mode 100644 tests/Unit/DSC_RDConnectionBrokerHAMode.Tests.ps1 diff --git a/source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.psm1 b/source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.psm1 deleted file mode 100644 index b40a407..0000000 --- a/source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.psm1 +++ /dev/null @@ -1,167 +0,0 @@ -$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' - -# Import the Common Modules -Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'RemoteDesktopServicesDsc.Common') -Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') - -if (-not (Test-RemoteDesktopServicesDscOsRequirement)) -{ - throw 'The minimum OS requirement was not met.' -} - -$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' - -$localhost = Get-ComputerName -FullyQualifiedDomainName - -####################################################################### -# The Get-TargetResource cmdlet. -####################################################################### -function Get-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Collections.Hashtable])] - param - ( - [Parameter()] - [System.String] - $ConnectionBroker, - - [Parameter(Mandatory = $true)] - [System.String] - $DatabaseConnectionString, - - [Parameter()] - [System.String] - $DatabaseSecondaryConnectionString, - - [Parameter()] - [System.String] - $DatabaseFilePath, - - [Parameter(Mandatory = $true)] - [ValidateLength(1, 256)] - [System.String] - $ClientAccessName - ) - - Import-RemoteDesktopModule - - Write-Verbose -Message ($script:localizedData.VerboseGetHAMode -f $ConnectionBroker, $ClientAccessName) - - if ([string]::IsNullOrWhiteSpace($ConnectionBroker)) - { - $ConnectionBroker = $localhost - } - - $ConnectionBrokerHighAvailability = Get-RDConnectionBrokerHighAvailability -ConnectionBroker $ConnectionBroker -ErrorAction SilentlyContinue - - @{ - ConnectionBroker = $ConnectionBrokerHighAvailability.ConnectionBroker - ActiveManagementServer = $ConnectionBrokerHighAvailability.ActiveManagementServer - ClientAccessName = $ConnectionBrokerHighAvailability.ClientAccessName - DatabaseConnectionString = $ConnectionBrokerHighAvailability.DatabaseConnectionString - DatabaseSecondaryConnectionString = $DatabaseSecondaryConnectionString - DatabaseFilePath = $ConnectionBrokerHighAvailability.DatabaseFilePath - } -} - -######################################################################## -# The Set-TargetResource cmdlet. -######################################################################## -function Set-TargetResource -{ - [CmdletBinding()] - param - ( - [Parameter()] - [System.String] - $ConnectionBroker, - - [Parameter(Mandatory = $true)] - [System.String] - $DatabaseConnectionString, - - [Parameter()] - [System.String] - $DatabaseSecondaryConnectionString, - - [Parameter()] - [System.String] - $DatabaseFilePath, - - [Parameter(Mandatory = $true)] - [ValidateLength(1, 256)] - [System.String] - $ClientAccessName - ) - - Import-RemoteDesktopModule - - Write-Verbose -Message ($script:localizedData.VerboseConfigureHAMode -f $ConnectionBroker, $ClientAccessName) - - if ([string]::IsNullOrWhiteSpace($ConnectionBroker)) - { - $ConnectionBroker = $localhost - } - - $parameters = @{ - ConnectionBroker = $ConnectionBroker - DatabaseConnectionString = $DatabaseConnectionString - ClientAccessName = $ClientAccessName - } - - if (-not [string]::IsNullOrWhiteSpace($DatabaseFilePath)) - { - $parameters['DatabaseFilePath'] = $DatabaseFilePath - } - - if (-not [string]::IsNullOrWhiteSpace($DatabaseSecondaryConnectionString)) - { - $parameters['DatabaseSecondaryConnectionString'] = $DatabaseSecondaryConnectionString - } - - Set-RDConnectionBrokerHighAvailability @parameters -} - -####################################################################### -# The Test-TargetResource cmdlet. -####################################################################### -function Test-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Boolean])] - param - ( - [Parameter()] - [System.String] - $ConnectionBroker, - - [Parameter(Mandatory = $true)] - [System.String] - $DatabaseConnectionString, - - [Parameter()] - [System.String] - $DatabaseSecondaryConnectionString, - - [Parameter()] - [System.String] - $DatabaseFilePath, - - [Parameter(Mandatory = $true)] - [ValidateLength(1, 256)] - [System.String] - $ClientAccessName - ) - - Write-Verbose ($script:localizedData.VerboseTestHAMode -f $ConnectionBroker, $ClientAccessName) - - if ([string]::IsNullOrWhiteSpace($ConnectionBroker)) - { - $PSBoundParameters['ConnectionBroker'] = $localhost - } - - -not [string]::IsNullOrWhiteSpace((Get-TargetResource @PSBoundParameters).ActiveManagementServer) -} - -Export-ModuleMember -Function *-TargetResource diff --git a/source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.schema.mof b/source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.schema.mof deleted file mode 100644 index 010f3f5..0000000 --- a/source/DSCResources/DSC_RDConnectionBrokerHAMode/DSC_RDConnectionBrokerHAMode.schema.mof +++ /dev/null @@ -1,9 +0,0 @@ -[ClassVersion("1.0.0.0"), FriendlyName("RDConnectionBrokerHAMode")] -class DSC_RDConnectionBrokerHAMode : OMI_BaseResource -{ - [Key, Description("Specifies the FQDN of client access name.")] string ClientAccessName; - [write, required, Description("Specifies the primary connection string to the database.")] string DatabaseConnectionString; - [write, Description("Specifies the secondary connection string to the database.")] string DatabaseSecondaryConnectionString; - [write, Description("Specifies the FQDN of a server to host the RD Connection Broker role service.")] string ConnectionBroker; - [write, Description("Specifies the database file path of SQL Server.")] string DatabaseFilePath; -}; diff --git a/source/DSCResources/DSC_RDConnectionBrokerHAMode/README.md b/source/DSCResources/DSC_RDConnectionBrokerHAMode/README.md deleted file mode 100644 index b3b6171..0000000 --- a/source/DSCResources/DSC_RDConnectionBrokerHAMode/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Description - -This resource is used to configure the Remote Desktop Connection Broker HA. diff --git a/source/DSCResources/DSC_RDConnectionBrokerHAMode/en-US/DSC_RDConnectionBrokerHAMode.strings.psd1 b/source/DSCResources/DSC_RDConnectionBrokerHAMode/en-US/DSC_RDConnectionBrokerHAMode.strings.psd1 deleted file mode 100644 index 26d4a76..0000000 --- a/source/DSCResources/DSC_RDConnectionBrokerHAMode/en-US/DSC_RDConnectionBrokerHAMode.strings.psd1 +++ /dev/null @@ -1,7 +0,0 @@ -# Localized resources for DSC_RDConnectionBrokerHAMode - -ConvertFrom-StringData @' - VerboseConfigureHAMode = Set RD Connection Broker {0} for high availability mode using Client Access name {1}. - VerboseGetHAMode = Getting information about Connection Broker {0} for high availability mode using Client Access name {1}. - VerboseTestHAMode = Testing existing HA configuration for Connection Broker {0} using Client Access name {1}. -'@ diff --git a/tests/Unit/DSC_RDConnectionBrokerHAMode.Tests.ps1 b/tests/Unit/DSC_RDConnectionBrokerHAMode.Tests.ps1 deleted file mode 100644 index 4b906b2..0000000 --- a/tests/Unit/DSC_RDConnectionBrokerHAMode.Tests.ps1 +++ /dev/null @@ -1,269 +0,0 @@ -# Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] -param () - -BeforeDiscovery { - try - { - if (-not (Get-Module -Name 'DscResource.Test')) - { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. - if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) - { - # Redirect all streams to $null, except the error stream (stream 2) - & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null - } - - # If the dependencies has not been resolved, this will throw an error. - Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' - } - } - catch [System.IO.FileNotFoundException] - { - throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.' - } -} - -BeforeAll { - $script:dscModuleName = 'RemoteDesktopServicesDsc' - $script:dscResourceName = 'DSC_RDConnectionBrokerHAMode' - - $script:testEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType 'Unit' - - # Load stub cmdlets and classes. - Import-Module (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs\RemoteDesktop.stubs.psm1') - - $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:dscResourceName - $PSDefaultParameterValues['Mock:ModuleName'] = $script:dscResourceName - $PSDefaultParameterValues['Should:ModuleName'] = $script:dscResourceName -} - -AfterAll { - $PSDefaultParameterValues.Remove('InModuleScope:ModuleName') - $PSDefaultParameterValues.Remove('Mock:ModuleName') - $PSDefaultParameterValues.Remove('Should:ModuleName') - - Restore-TestEnvironment -TestEnvironment $script:testEnvironment - - # Unload stub module - Remove-Module -Name RemoteDesktop.stubs -Force - - # Unload the module being tested so that it doesn't impact any other tests. - Get-Module -Name $script:dscResourceName -All | Remove-Module -Force -} - -Describe 'DSC_RDConnectionBrokerHAMode\Get-TargetResource' -Tag 'Get' { - Context 'When the resource is in the desired state' { - Context 'When the connection broker is not local' { - BeforeAll { - Mock -CommandName Import-RemoteDesktopModule - Mock -CommandName Get-RDConnectionBrokerHighAvailability -MockWith { - @{ - ConnectionBroker = 'RDCB1' - ActiveManagementServer = 'RDCB1' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - } - } - - It 'Should return the correct result' { - InModuleScope -ScriptBlock { - Set-StrictMode -Version 1.0 - - $testParams = @{ - ConnectionBroker = 'RDCB1' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - - $result = Get-TargetResource @testParams - - $result.ConnectionBroker | Should -Be $testParams.ConnectionBroker - $result.ActiveManagementServer | Should -Be 'RDCB1' - $result.ClientAccessName | Should -Be $testParams.ClientAccessName - $result.DatabaseConnectionString | Should -Be $testParams.DatabaseConnectionString - $result.DatabaseSecondaryConnectionString | Should -Be $testParams.DatabaseSecondaryConnectionString - $result.DatabaseFilePath | Should -Be $testParams.DatabaseFilePath - } - - Should -Invoke -CommandName Import-RemoteDesktopModule -Exactly -Times 1 -Scope It - Should -Invoke -CommandName Get-RDConnectionBrokerHighAvailability -Exactly -Times 1 -Scope It - } - } - - Context 'When the connection broker is local' { - BeforeAll { - Mock -CommandName Import-RemoteDesktopModule - Mock -CommandName Get-RDConnectionBrokerHighAvailability -MockWith { - @{ - ConnectionBroker = Get-ComputerName - ActiveManagementServer = 'RDCB1' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - } - } - - It 'Should return the correct result' { - InModuleScope -ScriptBlock { - Set-StrictMode -Version 1.0 - - $testParams = @{ - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - - $result = Get-TargetResource @testParams - - $result.ConnectionBroker | Should -Be (Get-ComputerName) - $result.ActiveManagementServer | Should -Be 'RDCB1' - $result.ClientAccessName | Should -Be $testParams.ClientAccessName - $result.DatabaseConnectionString | Should -Be $testParams.DatabaseConnectionString - $result.DatabaseSecondaryConnectionString | Should -Be $testParams.DatabaseSecondaryConnectionString - $result.DatabaseFilePath | Should -Be $testParams.DatabaseFilePath - } - - Should -Invoke -CommandName Import-RemoteDesktopModule -Exactly -Times 1 -Scope It - Should -Invoke -CommandName Get-RDConnectionBrokerHighAvailability -Exactly -Times 1 -Scope It - } - } - } - - Context 'When the resource is not in the desired state' { - BeforeAll { - Mock -CommandName Import-RemoteDesktopModule - Mock -CommandName Get-RDConnectionBrokerHighAvailability - } - - It 'Should return the correct result' { - InModuleScope -ScriptBlock { - Set-StrictMode -Version 1.0 - - $testParams = @{ - ConnectionBroker = 'RDCB1' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - - $result = Get-TargetResource @testParams - - $result.ConnectionBroker | Should -BeNullOrEmpty - $result.ActiveManagementServer | Should -BeNullOrEmpty - $result.ClientAccessName | Should -BeNullOrEmpty - $result.DatabaseConnectionString | Should -BeNullOrEmpty - $result.DatabaseSecondaryConnectionString | Should -Be $testParams.DatabaseSecondaryConnectionString - $result.DatabaseFilePath | Should -BeNullOrEmpty - } - - Should -Invoke -CommandName Import-RemoteDesktopModule -Exactly -Times 1 -Scope It - Should -Invoke -CommandName Get-RDConnectionBrokerHighAvailability -Exactly -Times 1 -Scope It - } - } -} - -Describe 'DSC_RDConnectionBrokerHAMode\Test-TargetResource' -Tag 'Test' { - Context 'When the resource is in the desired state' { - BeforeAll { - Mock -CommandName Get-TargetResource -MockWith { - @{ - ConnectionBroker = 'RDCB1' - ActiveManagementServer = 'RDCB1' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - } - } - - It 'Should return true' { - InModuleScope -ScriptBlock { - Set-StrictMode -Version 1.0 - - $testParams = @{ - ConnectionBroker = 'RDCB1' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - ClientAccessName = 'rdsfarm.contoso.com' - } - - Test-TargetResource @testParams | Should -BeTrue - } - - Should -Invoke -CommandName Get-TargetResource -Exactly -Times 1 -Scope It - } - } - - Context 'When the resource is not in the desired state' { - BeforeAll { - Mock -CommandName Get-TargetResource -MockWith { - @{ - ConnectionBroker = 'RDCB1' - ActiveManagementServer = '' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - } - } - - It 'Should return false' { - InModuleScope -ScriptBlock { - Set-StrictMode -Version 1.0 - - $testParams = @{ - ConnectionBroker = 'RDCB1' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - ClientAccessName = 'rdsfarm.contoso.com' - } - - Test-TargetResource @testParams | Should -BeFalse - } - - Should -Invoke -CommandName Get-TargetResource -Exactly -Times 1 -Scope It - } - } -} - -Describe 'DSC_RDConnectionBrokerHAMode\Set-TargetResource' -Tag 'Set' { - Context 'When Set-RDConnectionBrokerHighAvailability runs successfully' { - BeforeAll { - Mock -CommandName Import-RemoteDesktopModule - Mock -CommandName Set-RDConnectionBrokerHighAvailability - } - - It 'Should run Set-RDConnectionBrokerHighAvailability' { - InModuleScope -ScriptBlock { - Set-StrictMode -Version 1.0 - - $testParams = @{ - ConnectionBroker = '' - DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' - ClientAccessName = 'rdsfarm.contoso.com' - DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' - } - - $null = Set-TargetResource @testParams - } - - Should -Invoke -CommandName Import-RemoteDesktopModule -Exactly -Times 1 -Scope It - Should -Invoke -CommandName Set-RDConnectionBrokerHighAvailability -Exactly -Times 1 -Scope It - } - } -} From 480977120c7279ba216361fa3010d9169e0e3dc8 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Fri, 15 May 2026 11:17:49 +0100 Subject: [PATCH 02/11] Add class resource items --- .../Classes/020.RDConnectionBrokerHAMode.ps1 | 155 +++++ .../RDConnectionBrokerHAMode.strings.psd1 | 6 + .../RDConnectionBrokerHAMode.Tests.ps1 | 592 ++++++++++++++++++ 3 files changed, 753 insertions(+) create mode 100644 source/Classes/020.RDConnectionBrokerHAMode.ps1 create mode 100644 source/en-US/RDConnectionBrokerHAMode.strings.psd1 create mode 100644 tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 diff --git a/source/Classes/020.RDConnectionBrokerHAMode.ps1 b/source/Classes/020.RDConnectionBrokerHAMode.ps1 new file mode 100644 index 0000000..e655cb7 --- /dev/null +++ b/source/Classes/020.RDConnectionBrokerHAMode.ps1 @@ -0,0 +1,155 @@ +<# + .SYNOPSIS + The `RDConnectionBrokerHAMode` DSC resource is used to configure the Remote Desktop Connection Broker HA. + + .DESCRIPTION + This resource is used to configure the Remote Desktop Connection Broker HA. + + ## Requirements + + - Target machine must be running Windows Server 2012 or later. + + ## Known issues + + All issues are not listed here, see [all open issues](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+RDConnectionBrokerHAMode). + + .PARAMETER ClientAccessName + Specifies the Client Access Name for the RD Connection Broker HA deployment. + + .PARAMETER DatabaseConnectionString + Specifies the primary database connection string for the RD Connection Broker HA deployment. + + .PARAMETER DatabaseSecondaryConnectionString + Specifies the secondary database connection string for the RD Connection Broker HA deployment. + + .PARAMETER DatabaseFilePath + Specifies the file path for the RD Connection Broker HA database. + + .PARAMETER ConnectionBroker + Specifies the FQDN of a server to host the RD Connection Broker role service. + + .PARAMETER Reasons + Returns the reason a property is not in desired state. +#> + +[DscResource()] +class RDConnectionBrokerHAMode : ResourceBase +{ + [DscProperty(Key)] + [ValidateLength(1, 256)] + [System.String] + $ClientAccessName + + [DscProperty()] + [System.String] + $ConnectionBroker + + [DscProperty(Mandatory)] + [System.String] + $DatabaseConnectionString + + [DscProperty()] + [System.String] + $DatabaseSecondaryConnectionString + + [DscProperty()] + [System.String] + $DatabaseFilePath + + [DscProperty(NotConfigurable)] + [System.String] + $ActiveManagementServer + + [DscProperty(NotConfigurable)] + [RDSReason[]] + $Reasons + + RDConnectionBrokerHAMode () : base ($PSScriptRoot) + { + $this.ExcludeDscProperties = @( + 'ConnectionBroker' + 'DatabaseSecondaryConnectionString' + 'DatabaseFilePath' + ) + } + + [RDConnectionBrokerHAMode] Get() + { + # Call the base method to return the properties. + return ([ResourceBase] $this).Get() + } + + [void] Set() + { + # Call the base method to enforce the properties. + ([ResourceBase] $this).Set() + } + + [System.Boolean] Test() + { + # Call the base method to test all of the properties that should be enforced. + return ([ResourceBase] $this).Test() + } + + # Base method Get() call this method to get the current state as a Hashtable. + hidden [System.Collections.Hashtable] GetCurrentState([System.Collections.Hashtable] $properties) + { + $getParameters = @{ + ConnectionBroker = $this.ConnectionBroker + ErrorAction = 'SilentlyContinue' + } + + if ([string]::IsNullOrWhiteSpace($this.ConnectionBroker)) + { + $getParameters.ConnectionBroker = (Get-ComputerName -FullyQualifiedDomainName) + } + + $currentStateResult = Get-RDConnectionBrokerHighAvailability @getParameters + + return @{ + DatabaseConnectionString = $currentStateResult.DatabaseConnectionString + DatabaseSecondaryConnectionString = $currentStateResult.DatabaseSecondaryConnectionString + DatabaseFilePath = $currentStateResult.DatabaseFilePath + ActiveManagementServer = $currentStateResult.ActiveManagementServer + } + } + + <# + Base method Set() call this method with the properties that should be + enforced and that are not in desired state. + #> + hidden [void] Modify([System.Collections.Hashtable] $properties) + { + if (-not [string]::IsNullOrEmpty($this.ActiveManagementServer)) + { + New-InvalidOperationException -Message $this.localizedData.RDConnectionBrokerHAMode_ConfigurationCannotBeModified + } + + $setParameters = @{ + ClientAccessName = $this.ClientAccessName + ConnectionBroker = $this.ConnectionBroker + } + + if ([string]::IsNullOrWhiteSpace($this.ConnectionBroker)) + { + $setParameters.ConnectionBroker = (Get-ComputerName -FullyQualifiedDomainName) + } + + Set-RDConnectionBrokerHighAvailability @setParameters @properties + } + + <# + Base method Assert() call this method with the properties that was assigned + a value. + #> + hidden [void] AssertProperties([System.Collections.Hashtable] $properties) + { + if (-not (Test-RemoteDesktopServicesDscOsRequirement)) + { + New-InvalidOperationException -Message $this.localizedData.RDConnectionBrokerHAMode_OSRequirementNotMet + } + + # Module Import in verbose mode outputs lots of data, so redirecting to null. + Import-RemoteDesktopModule 4>&1 > $null + } +} diff --git a/source/en-US/RDConnectionBrokerHAMode.strings.psd1 b/source/en-US/RDConnectionBrokerHAMode.strings.psd1 new file mode 100644 index 0000000..740c48b --- /dev/null +++ b/source/en-US/RDConnectionBrokerHAMode.strings.psd1 @@ -0,0 +1,6 @@ +# Localized resources for RDConnectionBrokerHAMode + +ConvertFrom-StringData @' + RDConnectionBrokerHAMode_OSRequirementNotMet = The minimum OS requirement was not met. (RDSHA0001) + RDConnectionBrokerHAMode_ConfigurationCannotBeModified = The configuration of the Connection Broker High Availability mode cannot be modified once configured. (RDSHA0002) +'@ diff --git a/tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 b/tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 new file mode 100644 index 0000000..3c9a401 --- /dev/null +++ b/tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 @@ -0,0 +1,592 @@ +# Suppressing this rule because Script Analyzer does not understand Pester's syntax. +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +param () + +BeforeDiscovery { + try + { + if (-not (Get-Module -Name 'DscResource.Test')) + { + # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) + { + # Redirect all streams to $null, except the error stream (stream 2) + & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null + } + + # If the dependencies has not been resolved, this will throw an error. + Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' + } + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.' + } +} + +BeforeAll { + $script:dscModuleName = 'RemoteDesktopServicesDsc' + + Import-Module -Name $script:dscModuleName -ErrorAction Stop + + # Load stub cmdlets and classes. + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\Stubs\RemoteDesktop.stubs.psm1') + + $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:dscModuleName + $PSDefaultParameterValues['Mock:ModuleName'] = $script:dscModuleName + $PSDefaultParameterValues['Should:ModuleName'] = $script:dscModuleName +} + +AfterAll { + $PSDefaultParameterValues.Remove('InModuleScope:ModuleName') + $PSDefaultParameterValues.Remove('Mock:ModuleName') + $PSDefaultParameterValues.Remove('Should:ModuleName') + + # Unload stub module + Remove-Module -Name RemoteDesktop.stubs -Force + + # Unload the module being tested so that it doesn't impact any other tests. + Get-Module -Name $script:dscModuleName -All | Remove-Module -Force +} + +Describe 'RDConnectionBrokerHAMode' { + Context 'When class is instantiated' { + It 'Should not throw an exception' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + { [RDConnectionBrokerHAMode]::new() } | Should -Not -Throw + } + } + + It 'Should have a default or empty constructor' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $instance = [RDConnectionBrokerHAMode]::new() + $instance | Should -Not -BeNullOrEmpty + } + } + + It 'Should be the correct type' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $instance = [RDConnectionBrokerHAMode]::new() + $instance.GetType().Name | Should -Be 'RDConnectionBrokerHAMode' + } + } + } +} + +Describe 'RDConnectionBrokerHAMode\Get()' -Tag 'Get' { + Context 'When the system is in the desired state' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ConnectionBroker = 'connectionbroker.lan' + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + + <# + This mocks the method GetCurrentState(). + This mocks the method Assert(). + This mocks the method Normalize(). + + Method Get() will call the base method Get() which will + call back to the derived class methods. + #> + $script:mockInstance | + Add-Member -Force -MemberType 'ScriptMethod' -Name 'GetCurrentState' -Value { + return @{ + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + ActiveManagementServer = 'connectionbroker.lan' + } + } -PassThru | + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Assert' -Value { + return + } -PassThru | + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Normalize' -Value { + return + } -PassThru + } + } + + It 'Should return the correct values' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $currentState = $script:mockInstance.Get() + + $currentState.ClientAccessName | Should -Be 'rdsfarm.contoso.com' + + $currentState.DatabaseConnectionString | Should -Be 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + $currentState.DatabaseSecondaryConnectionString | Should -Be 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + $currentState.DatabaseFilePath | Should -Be 'C:\RDFiles\RemoteDesktopDeployment.mdf' + + $currentState.ActiveManagementServer | Should -Be 'connectionbroker.lan' + + $currentState.Reasons | Should -BeNullOrEmpty + } + } + } + + Context 'When the system is not in the desired state' { + Context 'When property ''DatabaseFilePath'' has the wrong value' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ConnectionBroker = 'connectionbroker.lan' + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + + <# + This mocks the method GetCurrentState(). + This mocks the method Assert(). + This mocks the method Normalize(). + + Method Get() will call the base method Get() which will + call back to the derived class methods. + #> + $script:mockInstance | + Add-Member -Force -MemberType 'ScriptMethod' -Name 'GetCurrentState' -Value { + return @{ + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment1.mdf' + ActiveManagementServer = 'connectionbroker.lan' + } + } -PassThru | + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Assert' -Value { + return + } -PassThru | + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Normalize' -Value { + return + } -PassThru + } + } + + It 'Should return the correct values' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $currentState = $script:mockInstance.Get() + + $currentState.ClientAccessName | Should -Be 'rdsfarm.contoso.com' + + $currentState.DatabaseConnectionString | Should -Be 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + $currentState.DatabaseSecondaryConnectionString | Should -Be 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + $currentState.DatabaseFilePath | Should -Be 'C:\RDFiles\RemoteDesktopDeployment1.mdf' + + $currentState.ActiveManagementServer | Should -Be 'connectionbroker.lan' + + $currentState.Reasons | Should -HaveCount 0 # Resource cannot 'update' it's either configured or not. + } + } + } + } +} + +Describe 'RDConnectionBrokerHAMode\Set()' -Tag 'Set' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ConnectionBroker = 'connectionbroker.lan' + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } | + # Mock method Modify which is called by the case method Set(). + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Modify' -Value { + $script:methodModifyCallCount += 1 + } -PassThru + } + } + + BeforeEach { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:methodTestCallCount = 0 + $script:methodModifyCallCount = 0 + } + } + + Context 'When the system is in the desired state' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance | + # Mock method Test() which is called by the base method Set() + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Test' -Value { + $script:methodTestCallCount += 1 + return $true + } + } + } + + It 'Should not call method Modify()' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance.Set() + + $script:methodTestCallCount | Should -Be 1 + $script:methodModifyCallCount | Should -Be 0 + } + } + } + + Context 'When the system is not in the desired state' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance | + # Mock method Test() which is called by the base method Set() + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Test' -Value { + $script:methodTestCallCount += 1 + return $false + } + + $script:mockInstance.PropertiesNotInDesiredState = @( + @{ + Property = 'DatabaseFilePath' + ExpectedValue = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + ActualValue = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + ) + } + } + + It 'Should call method Modify()' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance.Set() + + $script:methodTestCallCount | Should -Be 1 + $script:methodModifyCallCount | Should -Be 1 + } + } + } +} + +Describe 'RDConnectionBrokerHAMode\Test()' -Tag 'Test' { + BeforeEach { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:getMethodCallCount = 0 + } + } + + BeforeDiscovery { + $testCases = @( + @{ + Property = 'DatabaseConnectionString' + Current = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + Desired = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1A;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + }, + @{ + Property = 'DatabaseSecondaryConnectionString' + Current = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + Desired = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2A;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + }, + @{ + Property = 'DatabaseFilePath' + Current = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + Desired = 'C:\RDFiles\RemoteDesktopDeployment1.mdf' + } + ) + } + + Context 'When the system is in the desired state' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ConnectionBroker = 'connectionbroker.lan' + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + + $script:mockInstance | + # Mock method Get() which is called by the base method Test() + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Get' -Value { + $script:getMethodCallCount += 1 + } + } + } + + It 'Should return $true' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance.Test() | Should -BeTrue + + $script:getMethodCallCount | Should -Be 1 + } + } + } + + Context 'When the system is not in the desired state' { + Context 'When the property '''' is not correct' -ForEach $testCases { + BeforeAll { + InModuleScope -Parameters $_ -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ConnectionBroker = 'connectionbroker.lan' + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + + $script:mockInstance | + # Mock method Get() which is called by the base method Test() + Add-Member -Force -MemberType 'ScriptMethod' -Name 'Get' -Value { + $script:getMethodCallCount += 1 + } + + $script:mockInstance.PropertiesNotInDesiredState = @( + @{ + Property = $Property + ExpectedValue = $Desired + ActualValue = $Current + } + ) + } + } + + It 'Should return $false' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance.Test() | Should -BeFalse + + $script:getMethodCallCount | Should -Be 1 + } + } + } + } +} + +Describe 'RDConnectionBrokerHAMode\GetCurrentState()' -Tag 'HiddenMember' { + Context 'When the resource is not present' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + } + + Mock -CommandName Get-RDConnectionBrokerHighAvailability + Mock -CommandName Get-ComputerName -MockWith { 'connectionbroker.lan' } + } + + It 'Should return the correct values' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $currentState = $script:mockInstance.GetCurrentState( + @{ + ClientAccessName = 'rdsfarm.contoso.com' + } + ) + + $currentState.DatabaseConnectionString | Should -BeNullOrEmpty + $currentState.DatabaseSecondaryConnectionString | Should -BeNullOrEmpty + $currentState.DatabaseFilePath | Should -BeNullOrEmpty + $currentState.ActiveManagementServer | Should -BeNullOrEmpty + } + + Should -Invoke -CommandName Get-RDConnectionBrokerHighAvailability -Exactly -Times 1 -Scope It + Should -Invoke -CommandName Get-ComputerName -Exactly -Times 1 -Scope It + } + } + + Context 'When the resource is present' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + } + + Mock -CommandName Get-RDConnectionBrokerHighAvailability -MockWith { + [PSCustomObject] @{ + ConnectionBroker = 'connectionbroker.lan', 'connectionbroker1.lan' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + ActiveManagementServer = 'connectionbroker.lan' + } + } + + Mock -CommandName Get-ComputerName -MockWith { 'connectionbroker.lan' } + } + + It 'Should return the correct values' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $currentState = $script:mockInstance.GetCurrentState( + @{ + ClientAccessName = 'rdsfarm.contoso.com' + } + ) + + $currentState.DatabaseConnectionString | Should -Be 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + $currentState.DatabaseSecondaryConnectionString | Should -Be 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + $currentState.DatabaseFilePath | Should -Be 'C:\RDFiles\RemoteDesktopDeployment.mdf' + $currentState.ActiveManagementServer | Should -Be 'connectionbroker.lan' + } + + Should -Invoke -CommandName Get-RDConnectionBrokerHighAvailability -Exactly -Times 1 -Scope It + Should -Invoke -CommandName Get-ComputerName -Exactly -Times 1 -Scope It + } + } +} + +Describe 'RDConnectionBrokerHAMode\Modify()' -Tag 'HiddenMember' { + Context 'When the system is not in the desired state' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{ + ClientAccessName = 'rdsfarm.contoso.com' + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + } + } + + Context 'When the configuration should be updated' { + BeforeAll { + Mock -CommandName Set-RDConnectionBrokerHighAvailability + Mock -CommandName Get-ComputerName -MockWith { 'connectionbroker.lan' } + } + + It 'Should call the correct mocks' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $mockProperties = @{ + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + + $null = $script:mockInstance.Modify($mockProperties) + } + + Should -Invoke -CommandName Set-RDConnectionBrokerHighAvailability -Exactly -Times 1 -Scope It + Should -Invoke -CommandName Get-ComputerName -Exactly -Times 1 -Scope It + } + } + + Context 'When the configuration is already set' { + It 'Should throw the correct exception' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance.ActiveManagementServer = 'connectionbroker.lan' + + $mockProperties = @{ + DatabaseConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB1;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseSecondaryConnectionString = 'DRIVER=SQL Server Native Client 11.0;SERVER=RDDB2;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDS' + DatabaseFilePath = 'C:\RDFiles\RemoteDesktopDeployment.mdf' + } + + $errorRecord = Get-InvalidOperationRecord -Message $script:mockInstance.localizedData.RDConnectionBrokerHAMode_ConfigurationCannotBeModified + + { $script:mockInstance.Modify($mockProperties) } | Should -Throw -ExpectedMessage $errorRecord.Exception.Message + } + } + } + } +} + +Describe 'RDConnectionBrokerHAMode\AssertProperties()' -Tag 'AssertProperties' { + BeforeAll { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $script:mockInstance = [RDConnectionBrokerHAMode] @{} + } + } + + Context 'When the OS Requirement is not met' { + BeforeAll { + Mock -CommandName Test-RemoteDesktopServicesDscOsRequirement -MockWith { + return $false + } + } + + It 'Should throw the correct exception' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $errorRecord = Get-InvalidOperationRecord -Message $script:mockInstance.localizedData.RDConnectionBrokerHAMode_OSRequirementNotMet + + { $script:mockInstance.AssertProperties(@{}) } | Should -Throw -ExpectedMessage $errorRecord.Exception.Message + } + + Should -Invoke -CommandName Test-RemoteDesktopServicesDscOsRequirement -Exactly -Times 1 -Scope It + } + } + + Context 'When the OS Requirement is met' { + BeforeAll { + Mock -CommandName Test-RemoteDesktopServicesDscOsRequirement -MockWith { + return $true + } + + Mock -CommandName Import-RemoteDesktopModule + } + + It 'Should not throw an exception' { + InModuleScope -ScriptBlock { + Set-StrictMode -Version 1.0 + + $null = $script:mockInstance.AssertProperties(@{}) + } + + Should -Invoke -CommandName Test-RemoteDesktopServicesDscOsRequirement -Exactly -Times 1 -Scope It + Should -Invoke -CommandName Import-RemoteDesktopModule -Exactly -Times 1 -Scope It + } + } +} From be6a03c3c3665fffb82fcbfdeba0df021062ba15 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Fri, 15 May 2026 11:18:14 +0100 Subject: [PATCH 03/11] ModuleBuilder looks for AliasesToExport in manifest --- source/RemoteDesktopServicesDsc.psd1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/RemoteDesktopServicesDsc.psd1 b/source/RemoteDesktopServicesDsc.psd1 index e3db3db..8feea39 100644 --- a/source/RemoteDesktopServicesDsc.psd1 +++ b/source/RemoteDesktopServicesDsc.psd1 @@ -26,6 +26,9 @@ # Minimum version of the common language runtime (CLR) required by this module CLRVersion = '4.0' + # Aliases to export from this module + AliasesToExport = @() + # Functions to export from this module FunctionsToExport = @() From 0500a9618cc28fead8838088e8cb74072d36139f Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Fri, 15 May 2026 13:35:36 +0100 Subject: [PATCH 04/11] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d11338..da2b4fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Converted to class-based resource [Issue #151](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/151). - WebAccessServer is now NOT a required parameter, mirroring the use of the underlying cmdlet. +- `RDConnectionBrokerHAMode` + - Converted to class-based resource [Issue #144](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/144). ### Fixed From 707b8890b0121d2ab3fbd3844c5a5ef963bb2bd4 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Fri, 15 May 2026 13:43:48 +0100 Subject: [PATCH 05/11] Add missing parameter description --- source/Classes/020.RDConnectionBrokerHAMode.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/Classes/020.RDConnectionBrokerHAMode.ps1 b/source/Classes/020.RDConnectionBrokerHAMode.ps1 index e655cb7..7cb9afe 100644 --- a/source/Classes/020.RDConnectionBrokerHAMode.ps1 +++ b/source/Classes/020.RDConnectionBrokerHAMode.ps1 @@ -28,6 +28,9 @@ .PARAMETER ConnectionBroker Specifies the FQDN of a server to host the RD Connection Broker role service. + .PARAMETER ActiveManagementServer + Returns the FQDN of the server that is currently active for management tasks. + .PARAMETER Reasons Returns the reason a property is not in desired state. #> From 65cbccea7d90c451518239a7952e9cf9b7167ca0 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Fri, 15 May 2026 13:44:24 +0100 Subject: [PATCH 06/11] Add comment --- source/Classes/020.RDConnectionBrokerHAMode.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Classes/020.RDConnectionBrokerHAMode.ps1 b/source/Classes/020.RDConnectionBrokerHAMode.ps1 index 7cb9afe..dc3c9df 100644 --- a/source/Classes/020.RDConnectionBrokerHAMode.ps1 +++ b/source/Classes/020.RDConnectionBrokerHAMode.ps1 @@ -123,6 +123,7 @@ class RDConnectionBrokerHAMode : ResourceBase #> hidden [void] Modify([System.Collections.Hashtable] $properties) { + # If the ActiveManagementServer property is not empty, then the configuration is currently active and cannot be modified. if (-not [string]::IsNullOrEmpty($this.ActiveManagementServer)) { New-InvalidOperationException -Message $this.localizedData.RDConnectionBrokerHAMode_ConfigurationCannotBeModified From 83935412073bbef74600930b188848245bd61e4d Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Wed, 20 May 2026 10:30:12 +0100 Subject: [PATCH 07/11] Use PSResourceGet --- Resolve-Dependency.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 index 27a91e3..f85c8c9 100644 --- a/Resolve-Dependency.psd1 +++ b/Resolve-Dependency.psd1 @@ -3,7 +3,7 @@ AllowPrerelease = $false WithYAML = $true - UseModuleFast = $true + # UseModuleFast = $true #ModuleFastVersion = '0.1.2' #ModuleFastBleedingEdge = $true From 4881fd4d716b4e1abc01bd8effc9b198aa24f90e Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Thu, 21 May 2026 16:57:14 +0100 Subject: [PATCH 08/11] Update issue --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da2b4fb..a5c1b79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,16 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - `RDSessionDeployment` - - Converted to class-based resource [Issue #151](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/151). + - Converted to class-based resource [issue #151](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/151). - WebAccessServer is now NOT a required parameter, mirroring the use of the underlying cmdlet. - `RDConnectionBrokerHAMode` - - Converted to class-based resource [Issue #144](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/144). + - Converted to class-based resource [issue #144](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/144). ### Fixed - `RDSessionDeployment` - - Let base class add the key properties [Issue #153](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/153). + - Let base class add the key properties [issue #153](https://github.com/dsccommunity/RemoteDesktopServicesDsc/issues/153). ## [4.1.0] - 2026-03-23 From 7d0bc5dc1c0b661359136b2af9f1d6628397f664 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Thu, 21 May 2026 16:57:43 +0100 Subject: [PATCH 09/11] Temporarily add Configuration until ModuleBuilder PSGallery is fixed --- RequiredModules.psd1 | 1 + 1 file changed, 1 insertion(+) diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index 8e634ee..24591f4 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -12,6 +12,7 @@ Pester = 'latest' Plaster = 'latest' ModuleBuilder = 'latest' + Configuration = 'latest' # temporary until PSGallery upload is fixed ChangelogManagement = 'latest' Sampler = 'latest' 'Sampler.GitHubTasks' = 'latest' From 78cffa77c39fafbb7ec8c0f99c9e7474ff6bb228 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Thu, 21 May 2026 16:58:26 +0100 Subject: [PATCH 10/11] Does stream 1 need to be hidden --- source/Classes/020.RDConnectionBrokerHAMode.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Classes/020.RDConnectionBrokerHAMode.ps1 b/source/Classes/020.RDConnectionBrokerHAMode.ps1 index dc3c9df..f97628d 100644 --- a/source/Classes/020.RDConnectionBrokerHAMode.ps1 +++ b/source/Classes/020.RDConnectionBrokerHAMode.ps1 @@ -154,6 +154,6 @@ class RDConnectionBrokerHAMode : ResourceBase } # Module Import in verbose mode outputs lots of data, so redirecting to null. - Import-RemoteDesktopModule 4>&1 > $null + Import-RemoteDesktopModule 4> $null } } From 8813b44ce345fb0412bb31a8921dbf55b6edb3fc Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Thu, 21 May 2026 17:03:29 +0100 Subject: [PATCH 11/11] Fix typo and missing justification --- tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 | 6 +++--- tests/Unit/Classes/RDSReason.Tests.ps1 | 6 +++--- tests/Unit/Classes/RDSessionDeployment.Tests.ps1 | 6 +++--- tests/Unit/DSC_RDCertificateConfiguration.Tests.ps1 | 6 +++--- tests/Unit/DSC_RDGatewayConfiguration.Tests.ps1 | 6 +++--- tests/Unit/DSC_RDLicenseConfiguration.Tests.ps1 | 6 +++--- tests/Unit/DSC_RDRemoteApp.Tests.ps1 | 6 +++--- tests/Unit/DSC_RDServer.Tests.ps1 | 6 +++--- tests/Unit/DSC_RDSessionCollection.Tests.ps1 | 6 +++--- tests/Unit/DSC_RDSessionCollectionConfiguration.Tests.ps1 | 6 +++--- .../Public/Import-RemoteDesktopModule.Tests.ps1 | 6 +++--- .../Test-RemoteDesktopServicesDscOsRequirement.Tests.ps1 | 6 +++--- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 b/tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 index 3c9a401..4640e78 100644 --- a/tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 +++ b/tests/Unit/Classes/RDConnectionBrokerHAMode.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/Classes/RDSReason.Tests.ps1 b/tests/Unit/Classes/RDSReason.Tests.ps1 index 2cc1516..706a07d 100644 --- a/tests/Unit/Classes/RDSReason.Tests.ps1 +++ b/tests/Unit/Classes/RDSReason.Tests.ps1 @@ -1,4 +1,4 @@ -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -6,14 +6,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/Classes/RDSessionDeployment.Tests.ps1 b/tests/Unit/Classes/RDSessionDeployment.Tests.ps1 index 9f41f2c..ff83d3e 100644 --- a/tests/Unit/Classes/RDSessionDeployment.Tests.ps1 +++ b/tests/Unit/Classes/RDSessionDeployment.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/DSC_RDCertificateConfiguration.Tests.ps1 b/tests/Unit/DSC_RDCertificateConfiguration.Tests.ps1 index 22cf203..6d385c0 100644 --- a/tests/Unit/DSC_RDCertificateConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_RDCertificateConfiguration.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () @@ -8,14 +8,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/DSC_RDGatewayConfiguration.Tests.ps1 b/tests/Unit/DSC_RDGatewayConfiguration.Tests.ps1 index baf9d7f..86a31c8 100644 --- a/tests/Unit/DSC_RDGatewayConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_RDGatewayConfiguration.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/DSC_RDLicenseConfiguration.Tests.ps1 b/tests/Unit/DSC_RDLicenseConfiguration.Tests.ps1 index dc24b7a..3d16315 100644 --- a/tests/Unit/DSC_RDLicenseConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_RDLicenseConfiguration.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/DSC_RDRemoteApp.Tests.ps1 b/tests/Unit/DSC_RDRemoteApp.Tests.ps1 index c6616a4..09bf138 100644 --- a/tests/Unit/DSC_RDRemoteApp.Tests.ps1 +++ b/tests/Unit/DSC_RDRemoteApp.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/DSC_RDServer.Tests.ps1 b/tests/Unit/DSC_RDServer.Tests.ps1 index da88cd7..cbe789e 100644 --- a/tests/Unit/DSC_RDServer.Tests.ps1 +++ b/tests/Unit/DSC_RDServer.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/DSC_RDSessionCollection.Tests.ps1 b/tests/Unit/DSC_RDSessionCollection.Tests.ps1 index f9b43d3..71b12a7 100644 --- a/tests/Unit/DSC_RDSessionCollection.Tests.ps1 +++ b/tests/Unit/DSC_RDSessionCollection.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/DSC_RDSessionCollectionConfiguration.Tests.ps1 b/tests/Unit/DSC_RDSessionCollectionConfiguration.Tests.ps1 index cbcad35..32aded4 100644 --- a/tests/Unit/DSC_RDSessionCollectionConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_RDSessionCollectionConfiguration.Tests.ps1 @@ -1,5 +1,5 @@ # Suppressing this rule because Script Analyzer does not understand Pester's syntax. -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -7,14 +7,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Import-RemoteDesktopModule.Tests.ps1 b/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Import-RemoteDesktopModule.Tests.ps1 index b902401..e9b4aed 100644 --- a/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Import-RemoteDesktopModule.Tests.ps1 +++ b/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Import-RemoteDesktopModule.Tests.ps1 @@ -1,4 +1,4 @@ -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Required setup block per project template')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -6,14 +6,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } diff --git a/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Test-RemoteDesktopServicesDscOsRequirement.Tests.ps1 b/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Test-RemoteDesktopServicesDscOsRequirement.Tests.ps1 index 7825ae5..efba207 100644 --- a/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Test-RemoteDesktopServicesDscOsRequirement.Tests.ps1 +++ b/tests/Unit/RemoteDesktopServicesDsc.Common/Public/Test-RemoteDesktopServicesDscOsRequirement.Tests.ps1 @@ -1,4 +1,4 @@ -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { @@ -6,14 +6,14 @@ BeforeDiscovery { { if (-not (Get-Module -Name 'DscResource.Test')) { - # Assumes dependencies has been resolved, so if this module is not available, run 'noop' task. + # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } - # If the dependencies has not been resolved, this will throw an error. + # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } }