From a235aa317f6c93106a5d073e06327ed003b921d6 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 27 Apr 2020 15:41:28 +0200 Subject: [PATCH] SqlServerDsc: All resources using DscResource.Common (#1512) - SqlServerDsc - All resources are now using the common module DscResource.Common. --- CHANGELOG.md | 1 + RequiredModules.psd1 | 3 +- build.yaml | 13 + source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1 | 10 +- .../DSC_SqlAGDatabase/DSC_SqlAGDatabase.psm1 | 10 +- .../DSC_SqlAGListener/DSC_SqlAGListener.psm1 | 10 +- .../DSC_SqlAGReplica/DSC_SqlAGReplica.psm1 | 10 +- .../DSC_SqlAgentAlert/DSC_SqlAgentAlert.psm1 | 10 +- .../DSC_SqlAgentFailsafe.psm1 | 10 +- .../DSC_SqlAgentOperator.psm1 | 10 +- .../DSC_SqlAlias/DSC_SqlAlias.psm1 | 10 +- .../DSC_SqlAlwaysOnService.psm1 | 10 +- .../DSC_SqlDatabase/DSC_SqlDatabase.psm1 | 10 +- .../DSC_SqlDatabaseDefaultLocation.psm1 | 10 +- .../DSC_SqlDatabaseOwner.psm1 | 10 +- .../DSC_SqlDatabasePermission.psm1 | 10 +- .../DSC_SqlDatabaseRecoveryModel.psm1 | 10 +- .../DSC_SqlDatabaseRole.psm1 | 10 +- .../DSC_SqlDatabaseUser.psm1 | 10 +- source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 | 10 +- .../DSC_SqlRSSetup/DSC_SqlRSSetup.psm1 | 10 +- .../DSC_SqlScript/DSC_SqlScript.psm1 | 10 +- .../DSC_SqlScriptQuery.psm1 | 10 +- .../DSC_SqlServerConfiguration.psm1 | 10 +- .../DSC_SqlServerDatabaseMail.psm1 | 10 +- .../DSC_SqlServerEndpoint.psm1 | 10 +- .../DSC_SqlServerEndpointPermission.psm1 | 10 +- .../DSC_SqlServerEndpointState.psm1 | 10 +- .../DSC_SqlServerLogin.psm1 | 10 +- .../DSC_SqlServerMaxDop.psm1 | 10 +- .../DSC_SqlServerMemory.psm1 | 10 +- .../DSC_SqlServerNetwork.psm1 | 11 +- .../DSC_SqlServerPermission.psm1 | 10 +- .../DSC_SqlServerReplication.psm1 | 10 +- .../DSC_SqlServerRole/DSC_SqlServerRole.psm1 | 10 +- .../DSC_SqlServerSecureConnection.psm1 | 10 +- .../DSC_SqlServiceAccount.psm1 | 10 +- .../DSC_SqlSetup/DSC_SqlSetup.psm1 | 10 +- .../DSC_SqlWaitForAG/DSC_SqlWaitForAG.psm1 | 10 +- .../DSC_SqlWindowsFirewall.psm1 | 10 +- .../SqlServerDsc.Common.psd1 | 9 - .../SqlServerDsc.Common.psm1 | 511 +-------------- .../en-US/SqlServerDsc.Common.strings.psd1 | 7 - .../sv-SE/SqlServerDsc.Common.strings.psd1 | 7 - tests/Unit/SqlServerDsc.Common.Tests.ps1 | 607 ------------------ 45 files changed, 204 insertions(+), 1325 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1a356885..364f3cc36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md) - SqlServerDsc - Changed all resource prefixes from `MSFT_` to `DSC_` ([issue #1496](https://github.com/dsccommunity/SqlServerDsc/issues/1496)). + - All resources are now using the common module DscResource.Common. - SqlAlwaysOnService - BREAKING CHANGE: The parameter `ServerName` is now non-mandatory and defaults to `$env:COMPUTERNAME` ([issue #319](https://github.com/dsccommunity/SqlServerDsc/issues/319)). diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index 2071f2cf3..d1ea4c64c 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -11,7 +11,7 @@ PSScriptAnalyzer = 'latest' Pester = '4.10.1' Plaster = 'latest' - ModuleBuilder = '1.0.0' + ModuleBuilder = 'latest' ChangelogManagement = 'latest' Sampler = 'latest' MarkdownLinkCheck = 'latest' @@ -19,6 +19,7 @@ 'DscResource.AnalyzerRules' = 'latest' xDscResourceDesigner = 'latest' 'DscResource.DocGenerator' = 'latest' + 'DscResource.Common' = 'latest' # Dependency for integration tests LoopbackAdapter = 'latest' diff --git a/build.yaml b/build.yaml index df5fedb70..ed5db91db 100644 --- a/build.yaml +++ b/build.yaml @@ -9,6 +9,17 @@ CopyDirectories: Encoding: UTF8 VersionedOutputDirectory: true +#################################################### +# ModuleBuilder Dependent Modules Configuration # +#################################################### + +NestedModule: + DscResource.Common: + CopyOnly: true + Path: ./output/RequiredModules/DscResource.Common + AddToManifest: false + Exclude: PSGetModuleInfo.xml + #################################################### # Pipeline Configuration # #################################################### @@ -47,6 +58,7 @@ BuildWorkflow: Pester: OutputFormat: NUnitXML ExcludeFromCodeCoverage: + - Modules/DscResource.Common Script: - tests/Unit ExcludeTag: @@ -62,6 +74,7 @@ DscTest: ExcludeSourceFile: - output ExcludeModuleFile: + - Modules/DscResource.Common Resolve-Dependency: Gallery: 'PSGallery' diff --git a/source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1 b/source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1 index 72b041e75..e775414aa 100644 --- a/source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1 +++ b/source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAG' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlAGDatabase/DSC_SqlAGDatabase.psm1 b/source/DSCResources/DSC_SqlAGDatabase/DSC_SqlAGDatabase.psm1 index 28faacbdc..f1b322d2a 100644 --- a/source/DSCResources/DSC_SqlAGDatabase/DSC_SqlAGDatabase.psm1 +++ b/source/DSCResources/DSC_SqlAGDatabase/DSC_SqlAGDatabase.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAGDatabase' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlAGListener/DSC_SqlAGListener.psm1 b/source/DSCResources/DSC_SqlAGListener/DSC_SqlAGListener.psm1 index 320b25b89..798a550ea 100644 --- a/source/DSCResources/DSC_SqlAGListener/DSC_SqlAGListener.psm1 +++ b/source/DSCResources/DSC_SqlAGListener/DSC_SqlAGListener.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAGListener' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlAGReplica/DSC_SqlAGReplica.psm1 b/source/DSCResources/DSC_SqlAGReplica/DSC_SqlAGReplica.psm1 index c6a877fdc..561e55f36 100644 --- a/source/DSCResources/DSC_SqlAGReplica/DSC_SqlAGReplica.psm1 +++ b/source/DSCResources/DSC_SqlAGReplica/DSC_SqlAGReplica.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAGReplica' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS Gets the specified Availability Group Replica from the specified Availability Group. diff --git a/source/DSCResources/DSC_SqlAgentAlert/DSC_SqlAgentAlert.psm1 b/source/DSCResources/DSC_SqlAgentAlert/DSC_SqlAgentAlert.psm1 index a11c5f287..ba35720f9 100644 --- a/source/DSCResources/DSC_SqlAgentAlert/DSC_SqlAgentAlert.psm1 +++ b/source/DSCResources/DSC_SqlAgentAlert/DSC_SqlAgentAlert.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAgentAlert' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlAgentFailsafe/DSC_SqlAgentFailsafe.psm1 b/source/DSCResources/DSC_SqlAgentFailsafe/DSC_SqlAgentFailsafe.psm1 index 61e2726f2..53c8e87cc 100644 --- a/source/DSCResources/DSC_SqlAgentFailsafe/DSC_SqlAgentFailsafe.psm1 +++ b/source/DSCResources/DSC_SqlAgentFailsafe/DSC_SqlAgentFailsafe.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAgentFailsafe' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlAgentOperator/DSC_SqlAgentOperator.psm1 b/source/DSCResources/DSC_SqlAgentOperator/DSC_SqlAgentOperator.psm1 index f38dc8206..f5b73768b 100644 --- a/source/DSCResources/DSC_SqlAgentOperator/DSC_SqlAgentOperator.psm1 +++ b/source/DSCResources/DSC_SqlAgentOperator/DSC_SqlAgentOperator.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAgentOperator' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlAlias/DSC_SqlAlias.psm1 b/source/DSCResources/DSC_SqlAlias/DSC_SqlAlias.psm1 index e9244489e..c8df640c3 100644 --- a/source/DSCResources/DSC_SqlAlias/DSC_SqlAlias.psm1 +++ b/source/DSCResources/DSC_SqlAlias/DSC_SqlAlias.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAlias' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' function Get-TargetResource { diff --git a/source/DSCResources/DSC_SqlAlwaysOnService/DSC_SqlAlwaysOnService.psm1 b/source/DSCResources/DSC_SqlAlwaysOnService/DSC_SqlAlwaysOnService.psm1 index 84f02e400..b83ae9e9d 100644 --- a/source/DSCResources/DSC_SqlAlwaysOnService/DSC_SqlAlwaysOnService.psm1 +++ b/source/DSCResources/DSC_SqlAlwaysOnService/DSC_SqlAlwaysOnService.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlAlwaysOnService' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlDatabase/DSC_SqlDatabase.psm1 b/source/DSCResources/DSC_SqlDatabase/DSC_SqlDatabase.psm1 index 9017c9732..b4b62c428 100644 --- a/source/DSCResources/DSC_SqlDatabase/DSC_SqlDatabase.psm1 +++ b/source/DSCResources/DSC_SqlDatabase/DSC_SqlDatabase.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlDatabase' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $script:supportedCompatibilityLevels = @{ 8 = @('Version80') diff --git a/source/DSCResources/DSC_SqlDatabaseDefaultLocation/DSC_SqlDatabaseDefaultLocation.psm1 b/source/DSCResources/DSC_SqlDatabaseDefaultLocation/DSC_SqlDatabaseDefaultLocation.psm1 index b3dd58e36..f1aecf30f 100644 --- a/source/DSCResources/DSC_SqlDatabaseDefaultLocation/DSC_SqlDatabaseDefaultLocation.psm1 +++ b/source/DSCResources/DSC_SqlDatabaseDefaultLocation/DSC_SqlDatabaseDefaultLocation.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlDatabaseDefaultLocation' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlDatabaseOwner/DSC_SqlDatabaseOwner.psm1 b/source/DSCResources/DSC_SqlDatabaseOwner/DSC_SqlDatabaseOwner.psm1 index dae5a0495..80d683168 100644 --- a/source/DSCResources/DSC_SqlDatabaseOwner/DSC_SqlDatabaseOwner.psm1 +++ b/source/DSCResources/DSC_SqlDatabaseOwner/DSC_SqlDatabaseOwner.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlDatabaseOwner' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlDatabasePermission/DSC_SqlDatabasePermission.psm1 b/source/DSCResources/DSC_SqlDatabasePermission/DSC_SqlDatabasePermission.psm1 index bdddc32ab..0d56f89e4 100644 --- a/source/DSCResources/DSC_SqlDatabasePermission/DSC_SqlDatabasePermission.psm1 +++ b/source/DSCResources/DSC_SqlDatabasePermission/DSC_SqlDatabasePermission.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlDatabasePermission' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 b/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 index 03d86185a..773ba812d 100644 --- a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 +++ b/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlDatabaseRecoveryModel' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlDatabaseRole/DSC_SqlDatabaseRole.psm1 b/source/DSCResources/DSC_SqlDatabaseRole/DSC_SqlDatabaseRole.psm1 index 16ef80593..7e7af2eb9 100644 --- a/source/DSCResources/DSC_SqlDatabaseRole/DSC_SqlDatabaseRole.psm1 +++ b/source/DSCResources/DSC_SqlDatabaseRole/DSC_SqlDatabaseRole.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlDatabaseRole' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlDatabaseUser/DSC_SqlDatabaseUser.psm1 b/source/DSCResources/DSC_SqlDatabaseUser/DSC_SqlDatabaseUser.psm1 index 0b6650f2d..de75d5968 100644 --- a/source/DSCResources/DSC_SqlDatabaseUser/DSC_SqlDatabaseUser.psm1 +++ b/source/DSCResources/DSC_SqlDatabaseUser/DSC_SqlDatabaseUser.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlDatabaseUser' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 b/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 index 971c023cd..434c6e091 100644 --- a/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 +++ b/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlRS' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlRSSetup/DSC_SqlRSSetup.psm1 b/source/DSCResources/DSC_SqlRSSetup/DSC_SqlRSSetup.psm1 index 20986625f..67d740d13 100644 --- a/source/DSCResources/DSC_SqlRSSetup/DSC_SqlRSSetup.psm1 +++ b/source/DSCResources/DSC_SqlRSSetup/DSC_SqlRSSetup.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlRSSetup' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlScript/DSC_SqlScript.psm1 b/source/DSCResources/DSC_SqlScript/DSC_SqlScript.psm1 index 2c7ac285d..8e36ac6a7 100644 --- a/source/DSCResources/DSC_SqlScript/DSC_SqlScript.psm1 +++ b/source/DSCResources/DSC_SqlScript/DSC_SqlScript.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlScript' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlScriptQuery/DSC_SqlScriptQuery.psm1 b/source/DSCResources/DSC_SqlScriptQuery/DSC_SqlScriptQuery.psm1 index b53e04212..f59eb9eb5 100644 --- a/source/DSCResources/DSC_SqlScriptQuery/DSC_SqlScriptQuery.psm1 +++ b/source/DSCResources/DSC_SqlScriptQuery/DSC_SqlScriptQuery.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlScriptQuery' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerConfiguration/DSC_SqlServerConfiguration.psm1 b/source/DSCResources/DSC_SqlServerConfiguration/DSC_SqlServerConfiguration.psm1 index cd25a178a..ee779ca41 100644 --- a/source/DSCResources/DSC_SqlServerConfiguration/DSC_SqlServerConfiguration.psm1 +++ b/source/DSCResources/DSC_SqlServerConfiguration/DSC_SqlServerConfiguration.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerConfiguration' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerDatabaseMail/DSC_SqlServerDatabaseMail.psm1 b/source/DSCResources/DSC_SqlServerDatabaseMail/DSC_SqlServerDatabaseMail.psm1 index fdd99989f..55578c5ec 100644 --- a/source/DSCResources/DSC_SqlServerDatabaseMail/DSC_SqlServerDatabaseMail.psm1 +++ b/source/DSCResources/DSC_SqlServerDatabaseMail/DSC_SqlServerDatabaseMail.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerDatabaseMail' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerEndpoint/DSC_SqlServerEndpoint.psm1 b/source/DSCResources/DSC_SqlServerEndpoint/DSC_SqlServerEndpoint.psm1 index 06b5712aa..09b81d379 100644 --- a/source/DSCResources/DSC_SqlServerEndpoint/DSC_SqlServerEndpoint.psm1 +++ b/source/DSCResources/DSC_SqlServerEndpoint/DSC_SqlServerEndpoint.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerEndpoint' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerEndpointPermission/DSC_SqlServerEndpointPermission.psm1 b/source/DSCResources/DSC_SqlServerEndpointPermission/DSC_SqlServerEndpointPermission.psm1 index ce3e50457..0030ddf77 100644 --- a/source/DSCResources/DSC_SqlServerEndpointPermission/DSC_SqlServerEndpointPermission.psm1 +++ b/source/DSCResources/DSC_SqlServerEndpointPermission/DSC_SqlServerEndpointPermission.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerEndpointPermission' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerEndpointState/DSC_SqlServerEndpointState.psm1 b/source/DSCResources/DSC_SqlServerEndpointState/DSC_SqlServerEndpointState.psm1 index af8dd01cb..59a1a27f1 100644 --- a/source/DSCResources/DSC_SqlServerEndpointState/DSC_SqlServerEndpointState.psm1 +++ b/source/DSCResources/DSC_SqlServerEndpointState/DSC_SqlServerEndpointState.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerEndpointState' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerLogin/DSC_SqlServerLogin.psm1 b/source/DSCResources/DSC_SqlServerLogin/DSC_SqlServerLogin.psm1 index 25795e602..6e4aba515 100644 --- a/source/DSCResources/DSC_SqlServerLogin/DSC_SqlServerLogin.psm1 +++ b/source/DSCResources/DSC_SqlServerLogin/DSC_SqlServerLogin.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerLogin' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerMaxDop/DSC_SqlServerMaxDop.psm1 b/source/DSCResources/DSC_SqlServerMaxDop/DSC_SqlServerMaxDop.psm1 index 137597458..e1aa040ec 100644 --- a/source/DSCResources/DSC_SqlServerMaxDop/DSC_SqlServerMaxDop.psm1 +++ b/source/DSCResources/DSC_SqlServerMaxDop/DSC_SqlServerMaxDop.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerMaxDop' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerMemory/DSC_SqlServerMemory.psm1 b/source/DSCResources/DSC_SqlServerMemory/DSC_SqlServerMemory.psm1 index ce3ee41e9..bd490c01a 100644 --- a/source/DSCResources/DSC_SqlServerMemory/DSC_SqlServerMemory.psm1 +++ b/source/DSCResources/DSC_SqlServerMemory/DSC_SqlServerMemory.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerMemory' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerNetwork/DSC_SqlServerNetwork.psm1 b/source/DSCResources/DSC_SqlServerNetwork/DSC_SqlServerNetwork.psm1 index 0b9418355..f40b70c71 100644 --- a/source/DSCResources/DSC_SqlServerNetwork/DSC_SqlServerNetwork.psm1 +++ b/source/DSCResources/DSC_SqlServerNetwork/DSC_SqlServerNetwork.psm1 @@ -1,11 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -# Load localized string data -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerNetwork' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerPermission/DSC_SqlServerPermission.psm1 b/source/DSCResources/DSC_SqlServerPermission/DSC_SqlServerPermission.psm1 index 7002e8020..bbbc9572f 100644 --- a/source/DSCResources/DSC_SqlServerPermission/DSC_SqlServerPermission.psm1 +++ b/source/DSCResources/DSC_SqlServerPermission/DSC_SqlServerPermission.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerPermission' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerReplication/DSC_SqlServerReplication.psm1 b/source/DSCResources/DSC_SqlServerReplication/DSC_SqlServerReplication.psm1 index 12e5dca09..00d8df7f1 100644 --- a/source/DSCResources/DSC_SqlServerReplication/DSC_SqlServerReplication.psm1 +++ b/source/DSCResources/DSC_SqlServerReplication/DSC_SqlServerReplication.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerReplication' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $dom = [AppDomain]::CreateDomain('SqlServerReplication') diff --git a/source/DSCResources/DSC_SqlServerRole/DSC_SqlServerRole.psm1 b/source/DSCResources/DSC_SqlServerRole/DSC_SqlServerRole.psm1 index 60b5606cc..66cd72df0 100644 --- a/source/DSCResources/DSC_SqlServerRole/DSC_SqlServerRole.psm1 +++ b/source/DSCResources/DSC_SqlServerRole/DSC_SqlServerRole.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerRole' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServerSecureConnection/DSC_SqlServerSecureConnection.psm1 b/source/DSCResources/DSC_SqlServerSecureConnection/DSC_SqlServerSecureConnection.psm1 index 5d57264c6..af6f17e53 100644 --- a/source/DSCResources/DSC_SqlServerSecureConnection/DSC_SqlServerSecureConnection.psm1 +++ b/source/DSCResources/DSC_SqlServerSecureConnection/DSC_SqlServerSecureConnection.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServerSecureConnection' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlServiceAccount/DSC_SqlServiceAccount.psm1 b/source/DSCResources/DSC_SqlServiceAccount/DSC_SqlServiceAccount.psm1 index 40924543a..57930dae2 100644 --- a/source/DSCResources/DSC_SqlServiceAccount/DSC_SqlServiceAccount.psm1 +++ b/source/DSCResources/DSC_SqlServiceAccount/DSC_SqlServiceAccount.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlServiceAccount' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index a2bfa05ba..18bc11665 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlSetup' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlWaitForAG/DSC_SqlWaitForAG.psm1 b/source/DSCResources/DSC_SqlWaitForAG/DSC_SqlWaitForAG.psm1 index 721a67c72..131cb2721 100644 --- a/source/DSCResources/DSC_SqlWaitForAG/DSC_SqlWaitForAG.psm1 +++ b/source/DSCResources/DSC_SqlWaitForAG/DSC_SqlWaitForAG.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlWaitForAG' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/DSCResources/DSC_SqlWindowsFirewall/DSC_SqlWindowsFirewall.psm1 b/source/DSCResources/DSC_SqlWindowsFirewall/DSC_SqlWindowsFirewall.psm1 index b50687c49..454d63c67 100644 --- a/source/DSCResources/DSC_SqlWindowsFirewall/DSC_SqlWindowsFirewall.psm1 +++ b/source/DSCResources/DSC_SqlWindowsFirewall/DSC_SqlWindowsFirewall.psm1 @@ -1,10 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' +$script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'SqlServerDsc.Common.psm1') +Import-Module -Name $script:sqlServerDscHelperModulePath +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SqlWindowsFirewall' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 index 0f759bc0c..1e4048365 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 @@ -21,17 +21,9 @@ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. FunctionsToExport = @( - 'New-InvalidArgumentException' - 'New-InvalidOperationException' - 'New-ObjectNotFoundException' - 'New-InvalidResultException' - 'New-NotImplementedException' - 'Get-LocalizedData' - 'Test-DscParameterState' 'Get-RegistryPropertyValue' 'Format-Path' 'Copy-ItemWithRobocopy' - 'Get-TemporaryFolder' 'Invoke-InstallationMediaCopy' 'Connect-UncPath' 'Disconnect-UncPath' @@ -55,7 +47,6 @@ 'Invoke-SqlScript' 'Get-ServiceAccount' 'Find-ExceptionByNumber' - ) # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 77a04bb2b..43943eef2 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -1,498 +1,8 @@ -$script:modulesFolderPath = Split-Path -Path $PSScriptRoot -Parent +$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' -<# - .SYNOPSIS - Retrieves the localized string data based on the machine's culture. - Falls back to en-US strings if the machine's culture is not supported. - - .PARAMETER ResourceName - The name of the resource as it appears before '.strings.psd1' of the localized string file. - For example: - For WindowsOptionalFeature: MSFT_WindowsOptionalFeature - For Service: MSFT_ServiceResource - For Registry: MSFT_RegistryResource - For Helper: SqlServerDscHelper - - .PARAMETER ScriptRoot - Optional. The root path where to expect to find the culture folder. This is only needed - for localization in helper modules. This should not normally be used for resources. - - .NOTES - To be able to use localization in the helper function, this function must - be first in the file, before Get-LocalizedData is used by itself to load - localized data for this helper module (see directly after this function). -#> -function Get-LocalizedData -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $ResourceName, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [System.String] - $ScriptRoot - ) - - if (-not $ScriptRoot) - { - $dscResourcesFolder = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'DSCResources' - $resourceDirectory = Join-Path -Path $dscResourcesFolder -ChildPath $ResourceName - } - else - { - $resourceDirectory = $ScriptRoot - } - - $localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath $PSUICulture - - if (-not (Test-Path -Path $localizedStringFileLocation)) - { - # Fallback to en-US - $localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath 'en-US' - } +Import-Module -Name $script:resourceHelperModulePath - Import-LocalizedData ` - -BindingVariable 'localizedData' ` - -FileName "$ResourceName.strings.psd1" ` - -BaseDirectory $localizedStringFileLocation - - return $localizedData -} - -<# - .SYNOPSIS - Creates and throws an invalid argument exception. - - .PARAMETER Message - The message explaining why this error is being thrown. - - .PARAMETER ArgumentName - The name of the invalid argument that is causing this error to be thrown. -#> -function New-InvalidArgumentException -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $Message, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $ArgumentName - ) - - $argumentException = New-Object -TypeName 'ArgumentException' ` - -ArgumentList @($Message, $ArgumentName) - - $newObjectParameters = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @($argumentException, $ArgumentName, 'InvalidArgument', $null) - } - - $errorRecord = New-Object @newObjectParameters - - throw $errorRecord -} - -<# - .SYNOPSIS - Creates and throws an invalid operation exception. - - .PARAMETER Message - The message explaining why this error is being thrown. - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating error. -#> -function New-InvalidOperationException -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $Message, - - [Parameter()] - [ValidateNotNull()] - [System.Management.Automation.ErrorRecord] - $ErrorRecord - ) - - if ($null -eq $ErrorRecord) - { - $invalidOperationException = New-Object -TypeName 'InvalidOperationException' ` - -ArgumentList @($Message) - } - else - { - $invalidOperationException = New-Object -TypeName 'InvalidOperationException' ` - -ArgumentList @($Message, $ErrorRecord.Exception) - } - - $newObjectParameters = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( - $invalidOperationException.ToString(), - 'MachineStateIncorrect', - 'InvalidOperation', - $null - ) - } - - $errorRecordToThrow = New-Object @newObjectParameters - - throw $errorRecordToThrow -} - -<# - .SYNOPSIS - Creates and throws an object not found exception. - - .PARAMETER Message - The message explaining why this error is being thrown. - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating error. -#> -function New-ObjectNotFoundException -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $Message, - - [Parameter()] - [ValidateNotNull()] - [System.Management.Automation.ErrorRecord] - $ErrorRecord - ) - - if ($null -eq $ErrorRecord) - { - $exception = New-Object -TypeName 'System.Exception' ` - -ArgumentList @($Message) - } - else - { - $exception = New-Object -TypeName 'System.Exception' ` - -ArgumentList @($Message, $ErrorRecord.Exception) - } - - $newObjectParameters = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( - $exception.ToString(), - 'MachineStateIncorrect', - 'ObjectNotFound', - $null - ) - } - - $errorRecordToThrow = New-Object @newObjectParameters - - throw $errorRecordToThrow -} - -<# - .SYNOPSIS - Creates and throws an invalid result exception. - - .PARAMETER Message - The message explaining why this error is being thrown. - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating error. -#> -function New-InvalidResultException -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $Message, - - [Parameter()] - [ValidateNotNull()] - [System.Management.Automation.ErrorRecord] - $ErrorRecord - ) - - if ($null -eq $ErrorRecord) - { - $exception = New-Object -TypeName 'System.Exception' ` - -ArgumentList @($Message) - } - else - { - $exception = New-Object -TypeName 'System.Exception' ` - -ArgumentList @($Message, $ErrorRecord.Exception) - } - - $newObjectParameters = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( - $exception.ToString(), - 'MachineStateIncorrect', - 'InvalidResult', - $null - ) - } - - $errorRecordToThrow = New-Object @newObjectParameters - - throw $errorRecordToThrow -} - -<# - .SYNOPSIS - Creates and throws an not implemented exception. - - .PARAMETER Message - The message explaining why this error is being thrown. - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating error. - ' - .NOTES - The error categories can be found here: - https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.errorcategory -#> -function New-NotImplementedException -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $Message, - - [Parameter()] - [ValidateNotNull()] - [System.Management.Automation.ErrorRecord] - $ErrorRecord - ) - - if ($null -eq $ErrorRecord) - { - $invalidOperationException = New-Object -TypeName 'NotImplementedException' ` - -ArgumentList @($Message) - } - else - { - $invalidOperationException = New-Object -TypeName 'NotImplementedException' ` - -ArgumentList @($Message, $ErrorRecord.Exception) - } - - $newObjectParameters = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( - $invalidOperationException.ToString(), - 'MachineStateIncorrect', - 'NotImplemented', - $null - ) - } - - $errorRecordToThrow = New-Object @newObjectParameters - - throw $errorRecordToThrow -} - -<# - .SYNOPSIS - This method is used to compare current and desired values for any DSC resource. - - .PARAMETER CurrentValues - This is hash table of the current values that are applied to the resource. - - .PARAMETER DesiredValues - This is a PSBoundParametersDictionary of the desired values for the resource. - - .PARAMETER ValuesToCheck - This is a list of which properties in the desired values list should be checked. - If this is empty then all values in DesiredValues are checked. -#> -function Test-DscParameterState -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [System.Collections.Hashtable] - $CurrentValues, - - [Parameter(Mandatory = $true)] - [System.Object] - $DesiredValues, - - [Parameter()] - [System.Array] - $ValuesToCheck - ) - - $returnValue = $true - - if (($DesiredValues.GetType().Name -ne 'HashTable') ` - -and ($DesiredValues.GetType().Name -ne 'CimInstance') ` - -and ($DesiredValues.GetType().Name -ne 'PSBoundParametersDictionary')) - { - $errorMessage = $script:localizedData.PropertyTypeInvalidForDesiredValues -f $($DesiredValues.GetType().Name) - New-InvalidArgumentException -ArgumentName 'DesiredValues' -Message $errorMessage - } - - if (($DesiredValues.GetType().Name -eq 'CimInstance') -and ($null -eq $ValuesToCheck)) - { - $errorMessage = $script:localizedData.PropertyTypeInvalidForValuesToCheck - New-InvalidArgumentException -ArgumentName 'ValuesToCheck' -Message $errorMessage - } - - if (($null -eq $ValuesToCheck) -or ($ValuesToCheck.Count -lt 1)) - { - $keyList = $DesiredValues.Keys - } - else - { - $keyList = $ValuesToCheck - } - - $keyList | ForEach-Object -Process { - if (($_ -ne 'Verbose')) - { - if (($CurrentValues.ContainsKey($_) -eq $false) ` - -or ($CurrentValues.$_ -ne $DesiredValues.$_) ` - -or (($DesiredValues.GetType().Name -ne 'CimInstance' -and $DesiredValues.ContainsKey($_) -eq $true) -and ($null -ne $DesiredValues.$_ -and $DesiredValues.$_.GetType().IsArray))) - { - if ($DesiredValues.GetType().Name -eq 'HashTable' -or ` - $DesiredValues.GetType().Name -eq 'PSBoundParametersDictionary') - { - $checkDesiredValue = $DesiredValues.ContainsKey($_) - } - else - { - # If DesiredValue is a CimInstance. - $checkDesiredValue = $false - if (([System.Boolean]($DesiredValues.PSObject.Properties.Name -contains $_)) -eq $true) - { - if ($null -ne $DesiredValues.$_) - { - $checkDesiredValue = $true - } - } - } - - if ($checkDesiredValue) - { - $desiredType = $DesiredValues.$_.GetType() - $fieldName = $_ - if ($desiredType.IsArray -eq $true) - { - if (($CurrentValues.ContainsKey($fieldName) -eq $false) ` - -or ($null -eq $CurrentValues.$fieldName)) - { - Write-Verbose -Message ($script:localizedData.PropertyValidationError -f $fieldName) -Verbose - - $returnValue = $false - } - else - { - $arrayCompare = Compare-Object -ReferenceObject $CurrentValues.$fieldName ` - -DifferenceObject $DesiredValues.$fieldName - if ($null -ne $arrayCompare) - { - Write-Verbose -Message ($script:localizedData.PropertiesDoesNotMatch -f $fieldName) -Verbose - - $arrayCompare | ForEach-Object -Process { - Write-Verbose -Message ($script:localizedData.PropertyThatDoesNotMatch -f $_.InputObject, $_.SideIndicator) -Verbose - } - - $returnValue = $false - } - } - } - else - { - switch ($desiredType.Name) - { - 'String' - { - if (-not [System.String]::IsNullOrEmpty($CurrentValues.$fieldName) -or ` - -not [System.String]::IsNullOrEmpty($DesiredValues.$fieldName)) - { - Write-Verbose -Message ($script:localizedData.ValueOfTypeDoesNotMatch ` - -f $desiredType.Name, $fieldName, $($CurrentValues.$fieldName), $($DesiredValues.$fieldName)) -Verbose - - $returnValue = $false - } - } - - 'Int32' - { - if (-not ($DesiredValues.$fieldName -eq 0) -or ` - -not ($null -eq $CurrentValues.$fieldName)) - { - Write-Verbose -Message ($script:localizedData.ValueOfTypeDoesNotMatch ` - -f $desiredType.Name, $fieldName, $($CurrentValues.$fieldName), $($DesiredValues.$fieldName)) -Verbose - - $returnValue = $false - } - } - - { $_ -eq 'Int16' -or $_ -eq 'UInt16' -or $_ -eq 'Single' } - { - if (-not ($DesiredValues.$fieldName -eq 0) -or ` - -not ($null -eq $CurrentValues.$fieldName)) - { - Write-Verbose -Message ($script:localizedData.ValueOfTypeDoesNotMatch ` - -f $desiredType.Name, $fieldName, $($CurrentValues.$fieldName), $($DesiredValues.$fieldName)) -Verbose - - $returnValue = $false - } - } - - 'Boolean' - { - if ($CurrentValues.$fieldName -ne $DesiredValues.$fieldName) - { - Write-Verbose -Message ($script:localizedData.ValueOfTypeDoesNotMatch ` - -f $desiredType.Name, $fieldName, $($CurrentValues.$fieldName), $($DesiredValues.$fieldName)) -Verbose - - $returnValue = $false - } - } - - default - { - Write-Warning -Message ($script:localizedData.UnableToCompareProperty ` - -f $fieldName, $desiredType.Name) - - $returnValue = $false - } - } - } - } - } - } - } - - return $returnValue -} +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -690,19 +200,6 @@ function Copy-ItemWithRobocopy } } -<# - .SYNOPSIS - Returns the path of the current user's temporary folder. -#> -function Get-TemporaryFolder -{ - [CmdletBinding()] - [OutputType([System.String])] - param () - - return [IO.Path]::GetTempPath() -} - <# .SYNOPSIS Connects to the source using the provided credentials and then uses @@ -2495,5 +1992,3 @@ function Find-ExceptionByNumber # Return return $errorFound } - -$script:localizedData = Get-LocalizedData -ResourceName 'SqlServerDsc.Common' -ScriptRoot $PSScriptRoot diff --git a/source/Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 b/source/Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 index 7ada50485..ec4226cfb 100644 --- a/source/Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 +++ b/source/Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 @@ -1,13 +1,6 @@ # Localized resources for helper module SqlServerDsc.Common. ConvertFrom-StringData @' - PropertyTypeInvalidForDesiredValues = Property 'DesiredValues' must be either a [System.Collections.Hashtable], [CimInstance] or [PSBoundParametersDictionary]. The type detected was {0}. (SQLCOMMON0001) - PropertyTypeInvalidForValuesToCheck = If 'DesiredValues' is a CimInstance, then property 'ValuesToCheck' must contain a value. (SQLCOMMON0002) - PropertyValidationError = Expected to find an array value for property {0} in the current values, but it was either not present or was null. This has caused the test method to return false. (SQLCOMMON0003) - PropertiesDoesNotMatch = Found an array for property {0} in the current values, but this array does not match the desired state. Details of the changes are below. (SQLCOMMON0004) - PropertyThatDoesNotMatch = {0} - {1} (SQLCOMMON0005) - ValueOfTypeDoesNotMatch = {0} value for property {1} does not match. Current state is '{2}' and desired state is '{3}'. (SQLCOMMON0006) - UnableToCompareProperty = Unable to compare property {0} as the type {1} is not handled by the Test-DscParameterState cmdlet. (SQLCOMMON0007) RobocopyIsCopying = Robocopy is copying media from source '{0}' to destination '{1}'. (SQLCOMMON0008) RobocopyUsingUnbufferedIo = Robocopy is using unbuffered I/O. (SQLCOMMON0009) RobocopyNotUsingUnbufferedIo = Unbuffered I/O cannot be used due to incompatible version of Robocopy. (SQLCOMMON0010) diff --git a/source/Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 b/source/Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 index f4aa0093f..580fec86e 100644 --- a/source/Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 +++ b/source/Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 @@ -7,13 +7,6 @@ #> ConvertFrom-StringData @' - PropertyTypeInvalidForDesiredValues = Egenskapen 'DesiredValues' måste vara endera en [System.Collections.Hashtable], [CimInstance] eller [PSBoundParametersDictionary]. Den typ som hittades var {0}. (SQLCOMMON0001) - PropertyTypeInvalidForValuesToCheck = Om 'DesiredValues' är av typ CimInstance, då måste egenskapen 'ValuesToCheck' sättas till ett värde. (SQLCOMMON0002) - PropertyValidationError = Förväntades hitta ett värde av typen matris för egenskapen {0} för nuvarande värden, men den var endera inte tillgänglig eller så var den satt till Null. Detta har medfört att test metoden har retunerat falskt. (SQLCOMMON0003) - PropertiesDoesNotMatch = Hittade en matris för egenskapen {0} för nuvarande värden, men denna matris matchar inte önskat läge. Detaljer för ändringarna finns nedan. (SQLCOMMON0004) - PropertyThatDoesNotMatch = {0} - {1} (SQLCOMMON0005) - ValueOfTypeDoesNotMatch = {0} värde för egenskapen {1} matchar inte. Nuvarande läge är '{2}' och önskat läge är '{3}'. (SQLCOMMON0006) - UnableToCompareProperty = Inte möjligt att jämföra egenskapen {0} som typen {1}. {1} hanteras inte av Test-DscParameterState cmdlet. (SQLCOMMON0007) RobocopyIsCopying = Robocopy kopierar media från källan '{0}' till destinationen '{1}'. (SQLCOMMON0008) RobocopyUsingUnbufferedIo = Robocopy använder sig av obuffrad I/O. (SQLCOMMON0009) RobocopyNotUsingUnbufferedIo = Obuffrad I/O kan inte användas på grund av versionen av Robocopy inte är kompatibel. (SQLCOMMON0010) diff --git a/tests/Unit/SqlServerDsc.Common.Tests.ps1 b/tests/Unit/SqlServerDsc.Common.Tests.ps1 index 65e8b140c..45be9dfaa 100644 --- a/tests/Unit/SqlServerDsc.Common.Tests.ps1 +++ b/tests/Unit/SqlServerDsc.Common.Tests.ps1 @@ -40,398 +40,6 @@ Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs Import-SQLModuleStub InModuleScope $script:subModuleName { - Describe 'SqlServerDsc.Common\Test-DscParameterState' -Tag 'TestDscParameterState' { - Context -Name 'When passing values' -Fixture { - It 'Should return true for two identical tables' { - $mockDesiredValues = @{ - Example = 'test' - } - - $testParameters = @{ - CurrentValues = $mockDesiredValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $true - } - - It 'Should return false when a value is different for [System.String]' { - $mockCurrentValues = @{ - Example = [System.String] 'something' - } - - $mockDesiredValues = @{ - Example = [System.String] 'test' - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when a value is different for [System.Int32]' { - $mockCurrentValues = @{ - Example = [System.Int32] 1 - } - - $mockDesiredValues = @{ - Example = [System.Int32] 2 - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when a value is different for [Int16]' { - $mockCurrentValues = @{ - Example = [System.Int16] 1 - } - - $mockDesiredValues = @{ - Example = [System.Int16] 2 - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when a value is different for [UInt16]' { - $mockCurrentValues = @{ - Example = [System.UInt16] 1 - } - - $mockDesiredValues = @{ - Example = [System.UInt16] 2 - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when a value is different for [Boolean]' { - $mockCurrentValues = @{ - Example = [System.Boolean] $true - } - - $mockDesiredValues = @{ - Example = [System.Boolean] $false - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when a value is missing' { - $mockCurrentValues = @{} - $mockDesiredValues = @{ - Example = 'test' - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return true when only a specified value matches, but other non-listed values do not' { - $mockCurrentValues = @{ - Example = 'test' - SecondExample = 'true' - } - - $mockDesiredValues = @{ - Example = 'test' - SecondExample = 'false' - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - ValuesToCheck = @('Example') - } - - Test-DscParameterState @testParameters | Should -Be $true - } - - It 'Should return false when only specified values do not match, but other non-listed values do ' { - $mockCurrentValues = @{ - Example = 'test' - SecondExample = 'true' - } - - $mockDesiredValues = @{ - Example = 'test' - SecondExample = 'false' - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - ValuesToCheck = @('SecondExample') - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when an empty hash table is used in the current values' { - $mockCurrentValues = @{} - $mockDesiredValues = @{ - Example = 'test' - SecondExample = 'false' - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return true when evaluating a table against a CimInstance' { - $mockCurrentValues = @{ - Handle = '0' - ProcessId = '1000' - } - - $mockWin32ProcessProperties = @{ - Handle = 0 - ProcessId = 1000 - } - - $mockNewCimInstanceParameters = @{ - ClassName = 'Win32_Process' - Property = $mockWin32ProcessProperties - Key = 'Handle' - ClientOnly = $true - } - - $mockDesiredValues = New-CimInstance @mockNewCimInstanceParameters - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - ValuesToCheck = @('Handle','ProcessId') - } - - Test-DscParameterState @testParameters | Should -Be $true - } - - It 'Should return false when evaluating a table against a CimInstance and a value is wrong' { - $mockCurrentValues = @{ - Handle = '1' - ProcessId = '1000' - } - - $mockWin32ProcessProperties = @{ - Handle = 0 - ProcessId = 1000 - } - - $mockNewCimInstanceParameters = @{ - ClassName = 'Win32_Process' - Property = $mockWin32ProcessProperties - Key = 'Handle' - ClientOnly = $true - } - - $mockDesiredValues = New-CimInstance @mockNewCimInstanceParameters - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - ValuesToCheck = @('Handle','ProcessId') - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return true when evaluating a hash table containing an array' { - $mockCurrentValues = @{ - Example = 'test' - SecondExample = @('1','2') - } - - $mockDesiredValues = @{ - Example = 'test' - SecondExample = @('1','2') - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $true - } - - It 'Should return false when evaluating a hash table containing an array with wrong values' { - $mockCurrentValues = @{ - Example = 'test' - SecondExample = @('A','B') - } - - $mockDesiredValues = @{ - Example = 'test' - SecondExample = @('1','2') - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when evaluating a hash table containing an array, but the CurrentValues are missing an array' { - $mockCurrentValues = @{ - Example = 'test' - } - - $mockDesiredValues = @{ - Example = 'test' - SecondExample = @('1','2') - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - - It 'Should return false when evaluating a hash table containing an array, but the property i CurrentValues is $null' { - $mockCurrentValues = @{ - Example = 'test' - SecondExample = $null - } - - $mockDesiredValues = @{ - Example = 'test' - SecondExample = @('1','2') - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - } - } - - Context -Name 'When passing invalid types for DesiredValues' -Fixture { - It 'Should throw the correct error when DesiredValues is of wrong type' { - $mockCurrentValues = @{ - Example = 'something' - } - - $mockDesiredValues = 'NotHashTable' - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - $mockCorrectErrorMessage = ($script:localizedData.PropertyTypeInvalidForDesiredValues -f $testParameters.DesiredValues.GetType().Name) - { Test-DscParameterState @testParameters } | Should -Throw $mockCorrectErrorMessage - } - - It 'Should write a warning when DesiredValues contain an unsupported type' { - Mock -CommandName Write-Warning -Verifiable - - # This is a dummy type to test with a type that could never be a correct one. - class MockUnknownType - { - [ValidateNotNullOrEmpty()] - [System.String] - $Property1 - - [ValidateNotNullOrEmpty()] - [System.String] - $Property2 - - MockUnknownType() - { - } - } - - $mockCurrentValues = @{ - Example = New-Object -TypeName MockUnknownType - } - - $mockDesiredValues = @{ - Example = New-Object -TypeName MockUnknownType - } - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - } - - Test-DscParameterState @testParameters | Should -Be $false - - Assert-MockCalled -CommandName Write-Warning -Exactly -Times 1 - } - } - - Context -Name 'When passing an CimInstance as DesiredValue and ValuesToCheck is $null' -Fixture { - It 'Should throw the correct error' { - $mockCurrentValues = @{ - Example = 'something' - } - - $mockWin32ProcessProperties = @{ - Handle = 0 - ProcessId = 1000 - } - - $mockNewCimInstanceParameters = @{ - ClassName = 'Win32_Process' - Property = $mockWin32ProcessProperties - Key = 'Handle' - ClientOnly = $true - } - - $mockDesiredValues = New-CimInstance @mockNewCimInstanceParameters - - $testParameters = @{ - CurrentValues = $mockCurrentValues - DesiredValues = $mockDesiredValues - ValuesToCheck = $null - } - - $mockCorrectErrorMessage = $script:localizedData.PropertyTypeInvalidForValuesToCheck - { Test-DscParameterState @testParameters } | Should -Throw $mockCorrectErrorMessage - } - } - - Assert-VerifiableMock - } - Describe 'SqlServerDsc.Common\Get-RegistryPropertyValue' -Tag 'GetRegistryPropertyValue' { BeforeAll { $mockWrongRegistryPath = 'HKLM:\SOFTWARE\AnyPath' @@ -793,18 +401,6 @@ InModuleScope $script:subModuleName { } } - Describe 'SqlServerDsc.Common\Get-TemporaryFolder' -Tag 'GetTemporaryFolder' { - BeforeAll { - $mockExpectedTempPath = [IO.Path]::GetTempPath() - } - - Context 'When using Get-TemporaryFolder' { - It 'Should return the correct temporary path' { - Get-TemporaryFolder | Should -BeExactly $mockExpectedTempPath - } - } - } - Describe 'SqlServerDsc.Common\Invoke-InstallationMediaCopy' -Tag 'InvokeInstallationMediaCopy' { BeforeAll { $mockSourcePathUNC = '\\server\share' @@ -3153,208 +2749,5 @@ InModuleScope $script:subModuleName { } } } - - Describe 'DscResource.LocalizationHelper\Get-LocalizedData' { - $mockTestPath = { - return $mockTestPathReturnValue - } - - $mockImportLocalizedData = { - $BaseDirectory | Should -Be $mockExpectedLanguagePath - } - - BeforeEach { - Mock -CommandName Test-Path -MockWith $mockTestPath -Verifiable - Mock -CommandName Import-LocalizedData -MockWith $mockImportLocalizedData -Verifiable - } - - Context 'When loading localized data for Swedish' { - $mockExpectedLanguagePath = 'sv-SE' - $mockTestPathReturnValue = $true - - It 'Should call Import-LocalizedData with sv-SE language' { - Mock -CommandName Join-Path -MockWith { - return 'sv-SE' - } -Verifiable - - { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw - - Assert-MockCalled -CommandName Join-Path -Exactly -Times 3 -Scope It - Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It - } - - $mockExpectedLanguagePath = 'en-US' - $mockTestPathReturnValue = $false - - It 'Should call Import-LocalizedData and fallback to en-US if sv-SE language does not exist' { - Mock -CommandName Join-Path -MockWith { - return $ChildPath - } -Verifiable - - { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw - - Assert-MockCalled -CommandName Join-Path -Exactly -Times 4 -Scope It - Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It - } - - Context 'When $ScriptRoot is set to a path' { - $mockExpectedLanguagePath = 'sv-SE' - $mockTestPathReturnValue = $true - - It 'Should call Import-LocalizedData with sv-SE language' { - Mock -CommandName Join-Path -MockWith { - return 'sv-SE' - } -Verifiable - - { Get-LocalizedData -ResourceName 'DummyResource' -ScriptRoot '.' } | Should -Not -Throw - - Assert-MockCalled -CommandName Join-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It - } - - $mockExpectedLanguagePath = 'en-US' - $mockTestPathReturnValue = $false - - It 'Should call Import-LocalizedData and fallback to en-US if sv-SE language does not exist' { - Mock -CommandName Join-Path -MockWith { - return $ChildPath - } -Verifiable - - { Get-LocalizedData -ResourceName 'DummyResource' -ScriptRoot '.' } | Should -Not -Throw - - Assert-MockCalled -CommandName Join-Path -Exactly -Times 2 -Scope It - Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It - } - } - } - - Context 'When loading localized data for English' { - Mock -CommandName Join-Path -MockWith { - return 'en-US' - } -Verifiable - - $mockExpectedLanguagePath = 'en-US' - $mockTestPathReturnValue = $true - - It 'Should call Import-LocalizedData with en-US language' { - { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw - } - } - - Assert-VerifiableMock - } - - Describe 'DscResource.LocalizationHelper\New-InvalidResultException' { - Context 'When calling with Message parameter only' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - - { New-InvalidResultException -Message $mockErrorMessage } | Should -Throw $mockErrorMessage - } - } - - Context 'When calling with both the Message and ErrorRecord parameter' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - $mockExceptionErrorMessage = 'Mocked exception error message' - - $mockException = New-Object -TypeName System.Exception -ArgumentList $mockExceptionErrorMessage - $mockErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $mockException, $null, 'InvalidResult', $null - - { New-InvalidResultException -Message $mockErrorMessage -ErrorRecord $mockErrorRecord } | Should -Throw ('System.Exception: {0} ---> System.Exception: {1}' -f $mockErrorMessage, $mockExceptionErrorMessage) - } - } - - Assert-VerifiableMock - } - - Describe 'DscResource.LocalizationHelper\New-ObjectNotFoundException' { - Context 'When calling with Message parameter only' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - - { New-ObjectNotFoundException -Message $mockErrorMessage } | Should -Throw $mockErrorMessage - } - } - - Context 'When calling with both the Message and ErrorRecord parameter' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - $mockExceptionErrorMessage = 'Mocked exception error message' - - $mockException = New-Object -TypeName System.Exception -ArgumentList $mockExceptionErrorMessage - $mockErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $mockException, $null, 'InvalidResult', $null - - { New-ObjectNotFoundException -Message $mockErrorMessage -ErrorRecord $mockErrorRecord } | Should -Throw ('System.Exception: {0} ---> System.Exception: {1}' -f $mockErrorMessage, $mockExceptionErrorMessage) - } - } - - Assert-VerifiableMock - } - - Describe 'DscResource.LocalizationHelper\New-InvalidOperationException' { - Context 'When calling with Message parameter only' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - - { New-InvalidOperationException -Message $mockErrorMessage } | Should -Throw $mockErrorMessage - } - } - - Context 'When calling with both the Message and ErrorRecord parameter' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - $mockExceptionErrorMessage = 'Mocked exception error message' - - $mockException = New-Object -TypeName System.Exception -ArgumentList $mockExceptionErrorMessage - $mockErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $mockException, $null, 'InvalidResult', $null - - { New-InvalidOperationException -Message $mockErrorMessage -ErrorRecord $mockErrorRecord } | Should -Throw ('System.InvalidOperationException: {0} ---> System.Exception: {1}' -f $mockErrorMessage, $mockExceptionErrorMessage) - } - } - - Assert-VerifiableMock - } - - Describe 'DscResource.LocalizationHelper\New-NotImplementedException' { - Context 'When calling with Message parameter only' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - - { New-NotImplementedException -Message $mockErrorMessage } | Should -Throw $mockErrorMessage - } - } - - Context 'When calling with both the Message and ErrorRecord parameter' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - $mockExceptionErrorMessage = 'Mocked exception error message' - - $mockException = New-Object -TypeName System.Exception -ArgumentList $mockExceptionErrorMessage - $mockErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $mockException, $null, 'InvalidResult', $null - - { New-NotImplementedException -Message $mockErrorMessage -ErrorRecord $mockErrorRecord } | Should -Throw ('System.NotImplementedException: {0} ---> System.Exception: {1}' -f $mockErrorMessage, $mockExceptionErrorMessage) - } - } - - Assert-VerifiableMock - } - - Describe 'DscResource.LocalizationHelper\New-InvalidArgumentException' { - Context 'When calling with both the Message and ArgumentName parameter' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - $mockArgumentName = 'MockArgument' - - { New-InvalidArgumentException -Message $mockErrorMessage -ArgumentName $mockArgumentName } | Should -Throw ('Parameter name: {0}' -f $mockArgumentName) - } - } - - Assert-VerifiableMock - } }