diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 0c13825d3..337ea35d0 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,10 +1,10 @@ **Details of the scenario you tried and the problem that is occurring:** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 57f54638e..7b84ac775 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,13 +3,13 @@ Thanks for submitting a Pull Request (PR) to this project. Your contribution to this project is greatly appreciated! Please make sure you have read the contributing section -at https://github.com/PowerShell/xSQLServer#contributing. +at https://github.com/PowerShell/SqlServerDsc#contributing. Please prefix the PR title with the resource name, -i.e. 'xSQLServerSetup: My short description' +i.e. 'SqlSetup: My short description' If this is a breaking change, then also prefix the PR title with 'BREAKING CHANGE:', -i.e. 'BREAKING CHANGE: xSQLServerSetup: My short description' +i.e. 'BREAKING CHANGE: SqlSetup: My short description' --> **Pull Request (PR) description** diff --git a/CHANGELOG.md b/CHANGELOG.md index 5955ccd51..1bf7713f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ -# Change log for xSQLServer +# Change log for SqlServerDsc ## Unreleased +- BREAKING CHANGE: Significant rename to reduce length of Resource names + - See [issue #851](https://github.com/PowerShell/xSQLServer/issues/851) for a + complete table mapping rename changes. + - Impact to all resources + ## 9.0.0.0 - Changes to xSQLServer diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c21594bcc..d377c2e33 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# Contributing to xSQLServer +# Contributing to SqlServerDsc -If you are keen to make xSQLServer better, why not consider contributing your work +If you are keen to make SqlServerDsc better, why not consider contributing your work to the project? Every little change helps us make a better resource for everyone to use, and we would love to have contributions from the community. @@ -10,7 +10,7 @@ We follow all of the standard contribution guidelines for DSC resources [outlined in DscResources repository](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md), so please review these as a baseline for contributing. -## xSQLServer specific guidelines +## SqlServerDsc specific guidelines ### Automatic formatting with VS Code @@ -34,10 +34,14 @@ Those SQL Server products that are still supported can be listed at the ### Naming convention +```naming +[][]{ | } +``` + #### mof-based resource All mof-based resource (with Get/Set/Test-TargetResource) should be prefixed with -'MSFT\_xSQLServer'. I.e. MSFT\_xSQLServerConfiguration +'MSFT\_SqlServer'. I.e. MSFT\_SqlServerConfiguration Please note that not all places should contain the prefix 'MSFT\_'. @@ -49,14 +53,14 @@ This is to make those folders more user friendly, to resemble the name the user would use in the configuration file. ```Text -DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.psm1 -DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.schema.mof -DSCResources/MSFT_xSQLServerConfiguration/en-US/MSFT_xSQLServerConfiguration.strings.psd1 +DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 +DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof +DSCResources/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1 -Tests/Unit/MSFT_xSQLServerConfiguration.Tests.ps1 +Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 -Examples/Resources/xSQLServerConfiguration/1-AddConfigurationOption.ps1 -Examples/Resources/xSQLServerConfiguration/2-RemoveConfigurationOption.ps1 +Examples/Resources/SqlServerConfiguration/1-AddConfigurationOption.ps1 +Examples/Resources/SqlServerConfiguration/2-RemoveConfigurationOption.ps1 ``` ##### Schema mof file @@ -65,8 +69,8 @@ Please note that the `FriendlyName` in the schema mof file should not contain th prefix `MSFT\_`. ```powershell -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerConfiguration")] -class MSFT_xSQLServerConfiguration : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerConfiguration")] +class MSFT_SqlServerConfiguration : OMI_BaseResource { # Properties removed for readability. }; @@ -75,7 +79,7 @@ class MSFT_xSQLServerConfiguration : OMI_BaseResource #### Composite or class-based resource Any composite (with a Configuration) or class-based resources should be prefixed -with just 'xSQLServer' +with just 'Sql' ### Localization @@ -87,7 +91,7 @@ In each resource folder there should be, at least, a localization folder for english language 'en-US'. In the 'en-US' (and any other language folder) there should be a file named 'MSFT_ResourceName.strings.psd1', i.e. -'MSFT_xSQLServerSetup.strings.psd1'. +'MSFT_SqlSetup.strings.psd1'. At the top of each resource the localized strings should be loaded, see the helper function `Get-LocalizedData` for more information on how this is done. @@ -95,7 +99,7 @@ The localized string file should contain the following (beside the localization strings) ```powershell -# Localized resources for xSQLServerSetup +# Localized resources for SqlSetup ConvertFrom-StringData @' InstallingUsingPathMessage = Installing using path '{0}'. @@ -272,7 +276,7 @@ This should be used at the top of each resource like this. Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) ` -ChildPath 'CommonResourceHelper.psm1') -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerSetup' +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlSetup' ``` #### Old localization helper function @@ -280,9 +284,9 @@ $script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerSetup' To be able to support localization we have added wrappers for the cmdlets `Write-Verbose` and `Write-Warning`, and also for creating a terminating error message. -The localized strings are placed in a file named 'xSQLServerHelper.strings.psd1' +The localized strings are placed in a file named 'SqlServerDscHelper.strings.psd1' which are located in each language folder in the root of the module. For English -language strings the folder is ['en-US'](https://github.com/PowerShell/xSQLServer/blob/dev/en-US). +language strings the folder is ['en-US'](https://github.com/PowerShell/SqlServerDsc/blob/dev/en-US). ##### New-TerminatingError @@ -305,7 +309,7 @@ Helper functions or wrapper functions that are used by the resource can preferab be placed in the resource module file. If the functions are of a type that could be used by more than one resource, then the functions can also be placed in the common -[xSQLServerHelper.psm1](https://github.com/PowerShell/xSQLServer/blob/dev/xSQLServerHelper.psm1) +[SqlServerDscHelper.psm1](https://github.com/PowerShell/SqlServerDsc/blob/dev/SqlServerDscHelper.psm1) module file. ### Tests @@ -340,12 +344,13 @@ When sending in a Pull Request (PR) all example files will be tested so they can be compiled to a .mof file. If the tests find any errors the build will fail. Before the test runs in AppVeyor the module will be copied to the first path of `$env:PSModulePath`. -To run this test locally, make sure you have the xSQLServer module deployed to a -path where it can be used. See `$env:PSModulePath` to view the existing paths. +To run this test locally, make sure you have the SqlServerDsc module +deployed to a path where it can be used. +See `$env:PSModulePath` to view the existing paths. #### Using SMO stub classes -There are [stub classes](https://github.com/PowerShell/xSQLServer/blob/dev/Tests/Unit/Stubs/SMO.cs) +There are [stub classes](https://github.com/PowerShell/SqlServerDsc/blob/dev/Tests/Unit/Stubs/SMO.cs) for the SMO classes which can be used and improved on when creating tests where SMO classes are used in the code being tested. diff --git a/DSCResources/CommonResourceHelper.psm1 b/DSCResources/CommonResourceHelper.psm1 index 61e4f7676..bf18d83b8 100644 --- a/DSCResources/CommonResourceHelper.psm1 +++ b/DSCResources/CommonResourceHelper.psm1 @@ -204,7 +204,7 @@ function New-InvalidResultException For WindowsOptionalFeature: MSFT_WindowsOptionalFeature For Service: MSFT_ServiceResource For Registry: MSFT_RegistryResource - For Helper: xSQLServerHelper + For Helper: SqlServerDscHelper .PARAMETER ScriptRoot Optional. The root path where to expect to find the culture folder. This is only needed diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroup/MSFT_xSQLServerAlwaysOnAvailabilityGroup.psm1 b/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroup/MSFT_xSQLServerAlwaysOnAvailabilityGroup.psm1 rename to DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 index 1c87a2bb6..e5154e69f 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroup/MSFT_xSQLServerAlwaysOnAvailabilityGroup.psm1 +++ b/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroup/MSFT_xSQLServerAlwaysOnAvailabilityGroup.schema.mof b/DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof similarity index 96% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroup/MSFT_xSQLServerAlwaysOnAvailabilityGroup.schema.mof rename to DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof index 7cf156426..487516fd8 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroup/MSFT_xSQLServerAlwaysOnAvailabilityGroup.schema.mof +++ b/DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnAvailabilityGroup")] -class MSFT_xSQLServerAlwaysOnAvailabilityGroup : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlAG")] +class MSFT_SqlAG : OMI_BaseResource { [Key, Description("The name of the availability group.")] String Name; [Required, Description("Hostname of the SQL Server to be configured.")] String SQLServer; diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.psm1 b/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.psm1 rename to DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 index 5e4cc5283..85023b245 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.psm1 +++ b/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 @@ -1,11 +1,11 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) ` -ChildPath 'CommonResourceHelper.psm1') -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership' +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlAGDatabase' <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.schema.mof b/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof similarity index 92% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.schema.mof rename to DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof index 0df29e907..c22733e05 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.schema.mof +++ b/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership")] -class MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlAGDatabase")] +class MSFT_SqlAGDatabase : OMI_BaseResource { [Required, Description("The name of the database(s) to add to the availability group. This accepts wildcards.")] String DatabaseName[]; [Key, Description("Hostname of the SQL Server where the primary replica of the availability group lives. If the availability group is not currently on this server, the resource will attempt to connect to the server where the primary replica lives.")] String SQLServer; diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/en-US/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.strings.psd1 b/DSCResources/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 similarity index 92% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/en-US/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.strings.psd1 rename to DSCResources/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 index 4a29519a9..112cf9e1e 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/en-US/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.strings.psd1 +++ b/DSCResources/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 @@ -1,4 +1,4 @@ -# Localized resources for xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership +# Localized resources for SqlAGDatabase ConvertFrom-StringData @' AddingDatabasesToAvailabilityGroup = Adding the following databases to the '{0}' availability group: {1}. diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/en-US/about_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.help.txt b/DSCResources/MSFT_SqlAGDatabase/en-US/about_SqlAGDatabase.help.txt similarity index 100% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/en-US/about_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.help.txt rename to DSCResources/MSFT_SqlAGDatabase/en-US/about_SqlAGDatabase.help.txt diff --git a/DSCResources/MSFT_xSQLServerAvailabilityGroupListener/MSFT_xSQLServerAvailabilityGroupListener.psm1 b/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerAvailabilityGroupListener/MSFT_xSQLServerAvailabilityGroupListener.psm1 rename to DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 index fd0b2e382..020f304c1 100644 --- a/DSCResources/MSFT_xSQLServerAvailabilityGroupListener/MSFT_xSQLServerAvailabilityGroupListener.psm1 +++ b/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerAvailabilityGroupListener/MSFT_xSQLServerAvailabilityGroupListener.schema.mof b/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof similarity index 89% rename from DSCResources/MSFT_xSQLServerAvailabilityGroupListener/MSFT_xSQLServerAvailabilityGroupListener.schema.mof rename to DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof index 29c9c83df..43c13e8fe 100644 --- a/DSCResources/MSFT_xSQLServerAvailabilityGroupListener/MSFT_xSQLServerAvailabilityGroupListener.schema.mof +++ b/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof @@ -1,6 +1,6 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAvailabilityGroupListener")] -class MSFT_xSQLServerAvailabilityGroupListener : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlAGListener")] +class MSFT_SqlAGListener : OMI_BaseResource { [Key, Description("The SQL Server instance name of the primary replica.")] String InstanceName; [Required, Description("The host name or FQDN of the primary replica.")] String NodeName; diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.psm1 b/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.psm1 rename to DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 index 1aba2bbf2..2117f87b2 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.psm1 +++ b/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.schema.mof b/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof similarity index 96% rename from DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.schema.mof rename to DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof index d6aba9b0b..46127e6eb 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.schema.mof +++ b/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnAvailabilityGroupReplica")] -class MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlAGReplica")] +class MSFT_SqlAGReplica : OMI_BaseResource { [Key, Description("The name of the availability group replica. For named instances this must be in the following format SQLServer\\InstanceName.")] String Name; [Key, Description("The name of the availability group.")] String AvailabilityGroupName; diff --git a/DSCResources/MSFT_xSQLServerAlias/MSFT_xSQLServerAlias.psm1 b/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerAlias/MSFT_xSQLServerAlias.psm1 rename to DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1 index 4f7aac8f4..dd4f15bc5 100644 --- a/DSCResources/MSFT_xSQLServerAlias/MSFT_xSQLServerAlias.psm1 +++ b/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1 @@ -1,4 +1,4 @@ -Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -ChildPath 'xSQLServerHelper.psm1') -Force +Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -ChildPath 'SqlServerDscHelper.psm1') -Force function Get-TargetResource { diff --git a/DSCResources/MSFT_xSQLServerAlias/MSFT_xSQLServerAlias.schema.mof b/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof similarity index 90% rename from DSCResources/MSFT_xSQLServerAlias/MSFT_xSQLServerAlias.schema.mof rename to DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof index 241daec8e..2878dc822 100644 --- a/DSCResources/MSFT_xSQLServerAlias/MSFT_xSQLServerAlias.schema.mof +++ b/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlias")] -class MSFT_xSQLServerAlias : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlAlias")] +class MSFT_SqlAlias : OMI_BaseResource { [Key, Description("The name of Alias (e.g. svr01\\inst01).")] String Name; [Write, Description("Protocol to use when connecting. Valid values are 'TCP' or 'NP' (Named Pipes). Default value is 'TCP'."), ValueMap{"TCP","NP"}, Values{"TCP","NP"}] String Protocol; diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnService/MSFT_xSQLServerAlwaysOnService.psm1 b/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerAlwaysOnService/MSFT_xSQLServerAlwaysOnService.psm1 rename to DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 index 1e1b509de..268366074 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnService/MSFT_xSQLServerAlwaysOnService.psm1 +++ b/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# diff --git a/DSCResources/MSFT_xSQLServerAlwaysOnService/MSFT_xSQLServerAlwaysOnService.schema.mof b/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof similarity index 84% rename from DSCResources/MSFT_xSQLServerAlwaysOnService/MSFT_xSQLServerAlwaysOnService.schema.mof rename to DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof index 6c46028ee..831fd4b7d 100644 --- a/DSCResources/MSFT_xSQLServerAlwaysOnService/MSFT_xSQLServerAlwaysOnService.schema.mof +++ b/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof @@ -1,9 +1,9 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnService")] -class MSFT_xSQLServerAlwaysOnService : OMI_BaseResource -{ - [Required, Description("An enumerated value that describes if the SQL Server should have Always On high availability and disaster recovery (HADR) property enabled ('Present') or disabled ('Absent')."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; - [Key, Description("The hostname of the SQL Server to be configured.")] String SQLServer; - [Key, Description("The name of the SQL instance to be configured.")] String SQLInstanceName; - [Write, Description("The length of time, in seconds, to wait for the service to restart. Default is 120 seconds.")] Uint32 RestartTimeout; - [Read, Description("Returns the status of AlwaysOn high availability and disaster recovery (HADR).")] Boolean IsHadrEnabled; -}; +[ClassVersion("1.0.0.0"), FriendlyName("SqlAlwaysOnService")] +class MSFT_SqlAlwaysOnService : OMI_BaseResource +{ + [Required, Description("An enumerated value that describes if the SQL Server should have Always On high availability and disaster recovery (HADR) property enabled ('Present') or disabled ('Absent')."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; + [Key, Description("The hostname of the SQL Server to be configured.")] String SQLServer; + [Key, Description("The name of the SQL instance to be configured.")] String SQLInstanceName; + [Write, Description("The length of time, in seconds, to wait for the service to restart. Default is 120 seconds.")] Uint32 RestartTimeout; + [Read, Description("Returns the status of AlwaysOn high availability and disaster recovery (HADR).")] Boolean IsHadrEnabled; +}; diff --git a/DSCResources/MSFT_xSQLServerDatabase/MSFT_xSQLServerDatabase.psm1 b/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerDatabase/MSFT_xSQLServerDatabase.psm1 rename to DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 index c57be31e7..48a6e37ab 100644 --- a/DSCResources/MSFT_xSQLServerDatabase/MSFT_xSQLServerDatabase.psm1 +++ b/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerDatabase/MSFT_xSQLServerDatabase.schema.mof b/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof similarity index 85% rename from DSCResources/MSFT_xSQLServerDatabase/MSFT_xSQLServerDatabase.schema.mof rename to DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof index 67b6e6f29..4539ea4cc 100644 --- a/DSCResources/MSFT_xSQLServerDatabase/MSFT_xSQLServerDatabase.schema.mof +++ b/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabase")] -class MSFT_xSQLServerDatabase : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabase")] +class MSFT_SqlDatabase : OMI_BaseResource { [Key, Description("The name of the SQL database.")] String Name; [Write, Description("An enumerated value that describes if the database is added (Present) or dropped (Absent). Valid values are 'Present' or 'Absent'. Default Value is 'Present'."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; diff --git a/DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/MSFT_xSQLServerDatabaseDefaultLocation.psm1 b/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 similarity index 98% rename from DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/MSFT_xSQLServerDatabaseDefaultLocation.psm1 rename to DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 index 1327685ca..9dfed06a0 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/MSFT_xSQLServerDatabaseDefaultLocation.psm1 +++ b/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 @@ -1,11 +1,11 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) ` -ChildPath 'CommonResourceHelper.psm1') -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerDatabaseDefaultLocation' +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlDatabaseDefaultLocation' <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/MSFT_xSQLServerDatabaseDefaultLocation.schema.mof b/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof similarity index 87% rename from DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/MSFT_xSQLServerDatabaseDefaultLocation.schema.mof rename to DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof index 5d78b6822..3b909829f 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/MSFT_xSQLServerDatabaseDefaultLocation.schema.mof +++ b/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabaseDefaultLocation")] -class MSFT_xSQLServerDatabaseDefaultLocation : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabaseDefaultLocation")] +class MSFT_SqlDatabaseDefaultLocation : OMI_BaseResource { [Key, Description("The host name of the SQL Server to be configured.")] String SQLServer; [Key, Description("The name of the SQL instance to be configured.")] String SQLInstanceName; diff --git a/DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/en-US/MSFT_xSQLServerDatabaseDefaultLocation.strings.psd1 b/DSCResources/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 similarity index 91% rename from DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/en-US/MSFT_xSQLServerDatabaseDefaultLocation.strings.psd1 rename to DSCResources/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 index ac3fdf9ce..ee9cf93cd 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseDefaultLocation/en-US/MSFT_xSQLServerDatabaseDefaultLocation.strings.psd1 +++ b/DSCResources/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 @@ -1,4 +1,4 @@ -# Localized resources for MSFT_xSQLServerDatabaseDefaultLocation +# Localized resources for MSFT_SqlDatabaseDefaultLocation ConvertFrom-StringData @' GetCurrentPath = Getting default path for '{0}' for instance '{1}'. diff --git a/DSCResources/MSFT_xSQLServerDatabaseOwner/MSFT_xSQLServerDatabaseOwner.psm1 b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerDatabaseOwner/MSFT_xSQLServerDatabaseOwner.psm1 rename to DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 index 271e4a836..a947278d4 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseOwner/MSFT_xSQLServerDatabaseOwner.psm1 +++ b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerDatabaseOwner/MSFT_xSQLServerDatabaseOwner.schema.mof b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof similarity index 76% rename from DSCResources/MSFT_xSQLServerDatabaseOwner/MSFT_xSQLServerDatabaseOwner.schema.mof rename to DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof index 552d22629..1d970c749 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseOwner/MSFT_xSQLServerDatabaseOwner.schema.mof +++ b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabaseOwner")] -class MSFT_xSQLServerDatabaseOwner : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabaseOwner")] +class MSFT_SqlDatabaseOwner : OMI_BaseResource { [Key, Description("The name of database to be configured.")] String Database; [Required, Description("The name of the login that will become a owner of the desired sql database.")] String Name; diff --git a/DSCResources/MSFT_xSQLServerDatabasePermission/MSFT_xSQLServerDatabasePermission.psm1 b/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerDatabasePermission/MSFT_xSQLServerDatabasePermission.psm1 rename to DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 index 684fe53ef..3f3bc4124 100644 --- a/DSCResources/MSFT_xSQLServerDatabasePermission/MSFT_xSQLServerDatabasePermission.psm1 +++ b/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerDatabasePermission/MSFT_xSQLServerDatabasePermission.schema.mof b/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof similarity index 86% rename from DSCResources/MSFT_xSQLServerDatabasePermission/MSFT_xSQLServerDatabasePermission.schema.mof rename to DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof index 01c4b8cb8..03547b21a 100644 --- a/DSCResources/MSFT_xSQLServerDatabasePermission/MSFT_xSQLServerDatabasePermission.schema.mof +++ b/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabasePermission")] -class MSFT_xSQLServerDatabasePermission : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabasePermission")] +class MSFT_SqlDatabasePermission : OMI_BaseResource { [Write, Description("If the values should be present or absent. Valid values are 'Present' or 'Absent'."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Key, Description("The name of the database.")] String Database; diff --git a/DSCResources/MSFT_xSQLServerDatabaseRecoveryModel/MSFT_xSQLServerDatabaseRecoveryModel.psm1 b/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerDatabaseRecoveryModel/MSFT_xSQLServerDatabaseRecoveryModel.psm1 rename to DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 index 74f084cef..d24d89555 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseRecoveryModel/MSFT_xSQLServerDatabaseRecoveryModel.psm1 +++ b/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerDatabaseRecoveryModel/MSFT_xSQLServerDatabaseRecoveryModel.schema.mof b/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof similarity index 76% rename from DSCResources/MSFT_xSQLServerDatabaseRecoveryModel/MSFT_xSQLServerDatabaseRecoveryModel.schema.mof rename to DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof index 0ffb09a92..51614519b 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseRecoveryModel/MSFT_xSQLServerDatabaseRecoveryModel.schema.mof +++ b/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0"), FriendlyName("xSQLServerDatabaseRecoveryModel")] -class MSFT_xSQLServerDatabaseRecoveryModel : OMI_BaseResource +[ClassVersion("1.0"), FriendlyName("SqlDatabaseRecoveryModel")] +class MSFT_SqlDatabaseRecoveryModel : OMI_BaseResource { [Key, Description("The SQL database name")] String Name; [Required, Description("The recovery model to use for the database."), ValueMap{"Full","Simple","BulkLogged"}, Values{"Full","Simple","BulkLogged"}] String RecoveryModel; diff --git a/DSCResources/MSFT_xSQLServerDatabaseRole/MSFT_xSQLServerDatabaseRole.psm1 b/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerDatabaseRole/MSFT_xSQLServerDatabaseRole.psm1 rename to DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 index 61f7f3f6b..5460ec7d3 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseRole/MSFT_xSQLServerDatabaseRole.psm1 +++ b/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# diff --git a/DSCResources/MSFT_xSQLServerDatabaseRole/MSFT_xSQLServerDatabaseRole.schema.mof b/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof similarity index 86% rename from DSCResources/MSFT_xSQLServerDatabaseRole/MSFT_xSQLServerDatabaseRole.schema.mof rename to DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof index ef07952f9..2baf77dfc 100644 --- a/DSCResources/MSFT_xSQLServerDatabaseRole/MSFT_xSQLServerDatabaseRole.schema.mof +++ b/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabaseRole")] -class MSFT_xSQLServerDatabaseRole : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabaseRole")] +class MSFT_SqlDatabaseRole : OMI_BaseResource { [Write, Description("If 'Present' (the default value) then the login (user) will be added to the role(s). If 'Absent' then the login (user) will be removed from the role(s)."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Key, Description("The name of the login that will become a member, or removed as a member, of the role(s).")] String Name; diff --git a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 rename to DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 index 10e37433e..49a24f184 100644 --- a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 +++ b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# diff --git a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.schema.mof b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof similarity index 90% rename from DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.schema.mof rename to DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof index ff03fb317..4f4ae8b99 100644 --- a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.schema.mof +++ b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerRSConfig")] -class MSFT_xSQLServerRSConfig : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlRS")] +class MSFT_SqlRS : OMI_BaseResource { [Key, Description("Name of the SQL Server Reporting Services instance to be configured.")] String InstanceName; [Required, Description("Name of the SQL Server to host the Reporting Service database.")] String RSSQLServer; diff --git a/DSCResources/MSFT_xSQLServerRSSecureConnectionLevel/MSFT_xSQLServerRSSecureConnectionLevel.psm1 b/DSCResources/MSFT_SqlRSSecureConnectionLevel/MSFT_SqlRSSecureConnectionLevel.psm1 similarity index 97% rename from DSCResources/MSFT_xSQLServerRSSecureConnectionLevel/MSFT_xSQLServerRSSecureConnectionLevel.psm1 rename to DSCResources/MSFT_SqlRSSecureConnectionLevel/MSFT_SqlRSSecureConnectionLevel.psm1 index e6319223c..e20d298f3 100644 --- a/DSCResources/MSFT_xSQLServerRSSecureConnectionLevel/MSFT_xSQLServerRSSecureConnectionLevel.psm1 +++ b/DSCResources/MSFT_SqlRSSecureConnectionLevel/MSFT_SqlRSSecureConnectionLevel.psm1 @@ -2,7 +2,7 @@ $currentPath = Split-Path -Parent $MyInvocation.MyCommand.Path Write-Debug -Message "CurrentPath: $currentPath" # Load Common Code -Import-Module $currentPath\..\..\xSQLServerHelper.psm1 -Verbose:$false -ErrorAction Stop +Import-Module $currentPath\..\..\SqlServerDscHelper.psm1 -Verbose:$false -ErrorAction Stop function Get-TargetResource { diff --git a/DSCResources/MSFT_xSQLServerRSSecureConnectionLevel/MSFT_xSQLServerRSSecureConnectionLevel.schema.mof b/DSCResources/MSFT_SqlRSSecureConnectionLevel/MSFT_SqlRSSecureConnectionLevel.schema.mof similarity index 72% rename from DSCResources/MSFT_xSQLServerRSSecureConnectionLevel/MSFT_xSQLServerRSSecureConnectionLevel.schema.mof rename to DSCResources/MSFT_SqlRSSecureConnectionLevel/MSFT_SqlRSSecureConnectionLevel.schema.mof index 9539097ed..370766edf 100644 --- a/DSCResources/MSFT_xSQLServerRSSecureConnectionLevel/MSFT_xSQLServerRSSecureConnectionLevel.schema.mof +++ b/DSCResources/MSFT_SqlRSSecureConnectionLevel/MSFT_SqlRSSecureConnectionLevel.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerRSSecureConnectionLevel")] -class MSFT_xSQLServerRSSecureConnectionLevel : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlRSSecureConnectionLevel")] +class MSFT_SqlRSSecureConnectionLevel : OMI_BaseResource { [Key, Description("SQL instance to set secure connection level for.")] String InstanceName; [Key, Description("SQL Server Reporting Service secure connection level.")] Uint16 SecureConnectionLevel; diff --git a/DSCResources/MSFT_xSQLServerScript/MSFT_xSQLServerScript.psm1 b/DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerScript/MSFT_xSQLServerScript.psm1 rename to DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1 index bb31a336d..2b0cf0b70 100644 --- a/DSCResources/MSFT_xSQLServerScript/MSFT_xSQLServerScript.psm1 +++ b/DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1 @@ -1,5 +1,5 @@ $script:currentPath = Split-Path -Path $MyInvocation.MyCommand.Path -Parent -Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $script:currentPath -Parent) -Parent) -ChildPath 'xSQLServerHelper.psm1') +Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $script:currentPath -Parent) -Parent) -ChildPath 'SqlServerDscHelper.psm1') <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerScript/MSFT_xSQLServerScript.schema.mof b/DSCResources/MSFT_SqlScript/MSFT_SqlScript.schema.mof similarity index 95% rename from DSCResources/MSFT_xSQLServerScript/MSFT_xSQLServerScript.schema.mof rename to DSCResources/MSFT_SqlScript/MSFT_SqlScript.schema.mof index e827564e6..3627db5b2 100644 --- a/DSCResources/MSFT_xSQLServerScript/MSFT_xSQLServerScript.schema.mof +++ b/DSCResources/MSFT_SqlScript/MSFT_SqlScript.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerScript")] -class MSFT_xSQLServerScript : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlScript")] +class MSFT_SqlScript : OMI_BaseResource { [Key, Description("The name of an instance of the Database Engine. For a default instance, only specify the computer name. For a named instance, use the format ComputerName\\InstanceName")] String ServerInstance; [Key, Description("Path to the T-SQL file that will perform Set action.")] String SetFilePath; diff --git a/DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.psm1 b/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.psm1 rename to DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 index 1cb38ac73..feb90ed26 100644 --- a/DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.psm1 +++ b/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 @@ -1,6 +1,6 @@ # Load Common Code Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.schema.mof b/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof similarity index 84% rename from DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.schema.mof rename to DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof index e90976a76..f7af2c7b4 100644 --- a/DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.schema.mof +++ b/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerConfiguration")] -class MSFT_xSQLServerConfiguration : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerConfiguration")] +class MSFT_SqlServerConfiguration : OMI_BaseResource { [Key, Description("The hostname of the SQL Server to be configured.")] String SQLServer; [Key, Description("Name of the SQL instance to be configured.")] String SQLInstanceName; diff --git a/DSCResources/MSFT_xSQLServerEndpoint/MSFT_xSQLServerEndpoint.psm1 b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerEndpoint/MSFT_xSQLServerEndpoint.psm1 rename to DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 index 0e33fc9f5..ce716358c 100644 --- a/DSCResources/MSFT_xSQLServerEndpoint/MSFT_xSQLServerEndpoint.psm1 +++ b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerEndpoint/MSFT_xSQLServerEndpoint.schema.mof b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof similarity index 87% rename from DSCResources/MSFT_xSQLServerEndpoint/MSFT_xSQLServerEndpoint.schema.mof rename to DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof index 737bb8dbf..c0a894107 100644 --- a/DSCResources/MSFT_xSQLServerEndpoint/MSFT_xSQLServerEndpoint.schema.mof +++ b/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerEndpoint")] -class MSFT_xSQLServerEndpoint : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerEndpoint")] +class MSFT_SqlServerEndpoint : OMI_BaseResource { [Key, Description("The name of the endpoint.")] String EndpointName; [Write, Description("If the endpoint should be present or absent. Default values is 'Present'."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; diff --git a/DSCResources/MSFT_xSQLServerEndpointPermission/MSFT_xSQLServerEndpointPermission.psm1 b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerEndpointPermission/MSFT_xSQLServerEndpointPermission.psm1 rename to DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 index 94c538a5f..3e9df85f0 100644 --- a/DSCResources/MSFT_xSQLServerEndpointPermission/MSFT_xSQLServerEndpointPermission.psm1 +++ b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerEndpointPermission/MSFT_xSQLServerEndpointPermission.schema.mof b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof similarity index 84% rename from DSCResources/MSFT_xSQLServerEndpointPermission/MSFT_xSQLServerEndpointPermission.schema.mof rename to DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof index d50707093..24accc596 100644 --- a/DSCResources/MSFT_xSQLServerEndpointPermission/MSFT_xSQLServerEndpointPermission.schema.mof +++ b/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof @@ -1,6 +1,6 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerEndpointPermission")] -class MSFT_xSQLServerEndpointPermission : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerEndpointPermission")] +class MSFT_SqlServerEndpointPermission : OMI_BaseResource { [Key, Description("The name of the SQL instance to be configured.")] String InstanceName; [Required, Description("The host name of the SQL Server to be configured.")] String NodeName; diff --git a/DSCResources/MSFT_xSQLServerEndpointState/MSFT_xSQLServerEndpointState.psm1 b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerEndpointState/MSFT_xSQLServerEndpointState.psm1 rename to DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 index 1ba8d3232..9e81c222a 100644 --- a/DSCResources/MSFT_xSQLServerEndpointState/MSFT_xSQLServerEndpointState.psm1 +++ b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerEndpointState/MSFT_xSQLServerEndpointState.schema.mof b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof similarity index 81% rename from DSCResources/MSFT_xSQLServerEndpointState/MSFT_xSQLServerEndpointState.schema.mof rename to DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof index 14edfab02..5e4bd5fc5 100644 --- a/DSCResources/MSFT_xSQLServerEndpointState/MSFT_xSQLServerEndpointState.schema.mof +++ b/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerEndpointState")] -class MSFT_xSQLServerEndpointState : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerEndpointState")] +class MSFT_SqlServerEndpointState : OMI_BaseResource { [Key, Description("The name of the SQL instance to be configured.")] String InstanceName; [Write, Description("The host name of the SQL Server to be configured. Default value is $env:COMPUTERNAME.")] String NodeName; diff --git a/DSCResources/MSFT_xSQLServerLogin/MSFT_xSQLServerLogin.psm1 b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerLogin/MSFT_xSQLServerLogin.psm1 rename to DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 index c968c945b..11f3ae3f1 100644 --- a/DSCResources/MSFT_xSQLServerLogin/MSFT_xSQLServerLogin.psm1 +++ b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# diff --git a/DSCResources/MSFT_xSQLServerLogin/MSFT_xSQLServerLogin.schema.mof b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof similarity index 94% rename from DSCResources/MSFT_xSQLServerLogin/MSFT_xSQLServerLogin.schema.mof rename to DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof index 51f15fc66..63b88af46 100644 --- a/DSCResources/MSFT_xSQLServerLogin/MSFT_xSQLServerLogin.schema.mof +++ b/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerLogin")] -class MSFT_xSQLServerLogin : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerLogin")] +class MSFT_SqlServerLogin : OMI_BaseResource { [Write, Description("The specified login is Present or Absent. Default is Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Key, Description("The name of the login.")] String Name; diff --git a/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1 b/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 similarity index 96% rename from DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1 rename to DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 index 1eb7d49f7..e43239203 100644 --- a/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1 +++ b/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.schema.mof b/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof similarity index 92% rename from DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.schema.mof rename to DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof index 91efe692c..c7730aa1e 100644 --- a/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.schema.mof +++ b/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerMaxDop")] -class MSFT_xSQLServerMaxDop : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerMaxDop")] +class MSFT_SqlServerMaxDop : OMI_BaseResource { [Write, Description("When set to 'Present' then max degree of parallelism will be set to either the value in parameter MaxDop or dynamically configured when parameter DynamicAlloc is set to $true. When set to 'Absent' max degree of parallelism will be set to 0 which means no limit in number of processors used in parallel plan execution."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Write, Description("If set to $true then max degree of parallelism will be dynamically configured. When this is set parameter is set to $true, the parameter MaxDop must be set to $null or not be configured.")] Boolean DynamicAlloc; diff --git a/DSCResources/MSFT_xSQLServerMemory/MSFT_xSQLServerMemory.psm1 b/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerMemory/MSFT_xSQLServerMemory.psm1 rename to DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 index db6ac74b7..53446ea21 100644 --- a/DSCResources/MSFT_xSQLServerMemory/MSFT_xSQLServerMemory.psm1 +++ b/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 @@ -1,4 +1,4 @@ -Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -ChildPath 'xSQLServerHelper.psm1') -Force +Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -ChildPath 'SqlServerDscHelper.psm1') -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerMemory/MSFT_xSQLServerMemory.schema.mof b/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof similarity index 93% rename from DSCResources/MSFT_xSQLServerMemory/MSFT_xSQLServerMemory.schema.mof rename to DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof index 4f6bbb202..9ee925d2f 100644 --- a/DSCResources/MSFT_xSQLServerMemory/MSFT_xSQLServerMemory.schema.mof +++ b/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerMemory")] -class MSFT_xSQLServerMemory : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerMemory")] +class MSFT_SqlServerMemory : OMI_BaseResource { [Key, Description("The name of the SQL instance to be configured.")] String SQLInstanceName; [Write, Description("The host name of the SQL Server to be configured. Default value is $env:COMPUTERNAME.")] String SQLServer; diff --git a/DSCResources/MSFT_xSQLServerNetwork/MSFT_xSQLServerNetwork.psm1 b/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 similarity index 98% rename from DSCResources/MSFT_xSQLServerNetwork/MSFT_xSQLServerNetwork.psm1 rename to DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 index 23309fd95..589b22d29 100644 --- a/DSCResources/MSFT_xSQLServerNetwork/MSFT_xSQLServerNetwork.psm1 +++ b/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 @@ -1,10 +1,10 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') -Force + -ChildPath 'SqlServerDscHelper.psm1') -Force Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) ` -ChildPath 'CommonResourceHelper.psm1') # Load localized string data -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerNetwork' +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlServerNetwork' <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerNetwork/MSFT_xSQLServerNetwork.schema.mof b/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof similarity index 92% rename from DSCResources/MSFT_xSQLServerNetwork/MSFT_xSQLServerNetwork.schema.mof rename to DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof index 7f21b4f58..58624e795 100644 --- a/DSCResources/MSFT_xSQLServerNetwork/MSFT_xSQLServerNetwork.schema.mof +++ b/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerNetwork")] -class MSFT_xSQLServerNetwork : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerNetwork")] +class MSFT_SqlServerNetwork : OMI_BaseResource { [Key, Description("The name of the SQL instance to be configured.")] String InstanceName; [Required, Description("The name of network protocol to be configured. Only tcp is currently supported."), ValueMap{"Tcp"}, Values{"Tcp"}] String ProtocolName; diff --git a/DSCResources/MSFT_xSQLServerNetwork/en-US/MSFT_xSQLServerNetwork.strings.psd1 b/DSCResources/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 similarity index 93% rename from DSCResources/MSFT_xSQLServerNetwork/en-US/MSFT_xSQLServerNetwork.strings.psd1 rename to DSCResources/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 index d19f1e234..2454c12de 100644 --- a/DSCResources/MSFT_xSQLServerNetwork/en-US/MSFT_xSQLServerNetwork.strings.psd1 +++ b/DSCResources/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 @@ -1,4 +1,4 @@ -# Localized resources for xSQLServerNetwork +# Localized resources for SqlServerNetwork ConvertFrom-StringData @' GetNetworkProtocol = Getting network protocol [{0}] for SQL instance [{1}]. diff --git a/DSCResources/MSFT_xSQLServerPermission/MSFT_xSQLServerPermission.psm1 b/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerPermission/MSFT_xSQLServerPermission.psm1 rename to DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 index c0c0f1e62..f6c572c14 100644 --- a/DSCResources/MSFT_xSQLServerPermission/MSFT_xSQLServerPermission.psm1 +++ b/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerPermission/MSFT_xSQLServerPermission.schema.mof b/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof similarity index 88% rename from DSCResources/MSFT_xSQLServerPermission/MSFT_xSQLServerPermission.schema.mof rename to DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof index d67969841..b1e1bb639 100644 --- a/DSCResources/MSFT_xSQLServerPermission/MSFT_xSQLServerPermission.schema.mof +++ b/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerPermission")] -class MSFT_xSQLServerPermission : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerPermission")] +class MSFT_SqlServerPermission : OMI_BaseResource { [Key, Description("The name of the SQL instance to be configured.")] String InstanceName; [Write, Description("The host name of the SQL Server to be configured. Default value is $env:COMPUTERNAME.")] String NodeName; diff --git a/DSCResources/MSFT_xSQLServerReplication/MSFT_xSQLServerReplication.psm1 b/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerReplication/MSFT_xSQLServerReplication.psm1 rename to DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 index 482653263..a7f09403c 100644 --- a/DSCResources/MSFT_xSQLServerReplication/MSFT_xSQLServerReplication.psm1 +++ b/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 @@ -1,4 +1,4 @@ -$dom = [AppDomain]::CreateDomain('xSQLServerReplication') +$dom = [AppDomain]::CreateDomain('SqlServerReplication') function Get-TargetResource { diff --git a/DSCResources/MSFT_xSQLServerReplication/MSFT_xSQLServerReplication.schema.mof b/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof similarity index 88% rename from DSCResources/MSFT_xSQLServerReplication/MSFT_xSQLServerReplication.schema.mof rename to DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof index 609bc1aaf..1e4332e8d 100644 --- a/DSCResources/MSFT_xSQLServerReplication/MSFT_xSQLServerReplication.schema.mof +++ b/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerReplication")] -class MSFT_xSQLServerReplication : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerReplication")] +class MSFT_SqlServerReplication : OMI_BaseResource { [Key, Description("SQL Server instance name where replication distribution will be configured")] String InstanceName; [Write, ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure; diff --git a/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1 b/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1 rename to DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 index 8c01065db..78552114c 100644 --- a/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1 +++ b/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.schema.mof b/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof similarity index 91% rename from DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.schema.mof rename to DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof index d7c1a397b..3cd0100e3 100644 --- a/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.schema.mof +++ b/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerRole")] -class MSFT_xSQLServerRole : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServerRole")] +class MSFT_SqlServerRole : OMI_BaseResource { [Key, Description("The name of of SQL role to add or remove.")] String ServerRoleName; [Key, Description("The host name of the SQL Server to be configured.")] String SQLServer; diff --git a/DSCResources/MSFT_xSQLServerServiceAccount/MSFT_xSQLServerServiceAccount.psm1 b/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 similarity index 98% rename from DSCResources/MSFT_xSQLServerServiceAccount/MSFT_xSQLServerServiceAccount.psm1 rename to DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 index db2f4b304..0b3f90b90 100644 --- a/DSCResources/MSFT_xSQLServerServiceAccount/MSFT_xSQLServerServiceAccount.psm1 +++ b/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 @@ -1,10 +1,10 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') + -ChildPath 'SqlServerDscHelper.psm1') Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) ` -ChildPath 'CommonResourceHelper.psm1') -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerServiceAccount' +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlServiceAccount' <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerServiceAccount/MSFT_xSQLServerServiceAccount.schema.mof b/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof similarity index 88% rename from DSCResources/MSFT_xSQLServerServiceAccount/MSFT_xSQLServerServiceAccount.schema.mof rename to DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof index feb42c03f..bc99cacc8 100644 --- a/DSCResources/MSFT_xSQLServerServiceAccount/MSFT_xSQLServerServiceAccount.schema.mof +++ b/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerServiceAccount")] -class MSFT_xSQLServerServiceAccount : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlServiceAccount")] +class MSFT_SqlServiceAccount : OMI_BaseResource { [Key, Description("Hostname of the SQL Server.")] String SQLServer; [Key, Description("Name of the SQL instance.")] String SQLInstanceName; diff --git a/DSCResources/MSFT_xSQLServerServiceAccount/en-US/MSFT_xSQLServerServiceAccount.strings.psd1 b/DSCResources/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 similarity index 92% rename from DSCResources/MSFT_xSQLServerServiceAccount/en-US/MSFT_xSQLServerServiceAccount.strings.psd1 rename to DSCResources/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 index c18e0b70e..f7929ba27 100644 --- a/DSCResources/MSFT_xSQLServerServiceAccount/en-US/MSFT_xSQLServerServiceAccount.strings.psd1 +++ b/DSCResources/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 @@ -1,4 +1,4 @@ -# Localized resources for xSQLServerServiceAccount +# Localized resources for SqlServiceAccount ConvertFrom-StringData @' ForceServiceAccountUpdate = Force specified, skipping tests. With this configuration, Test-TargetResource will always return 'False'. diff --git a/DSCResources/MSFT_xSQLServerSetup/MSFT_xSQLServerSetup.psm1 b/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerSetup/MSFT_xSQLServerSetup.psm1 rename to DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 index 7f9cbbf2b..6685b9c03 100644 --- a/DSCResources/MSFT_xSQLServerSetup/MSFT_xSQLServerSetup.psm1 +++ b/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 @@ -1,10 +1,10 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') + -ChildPath 'SqlServerDscHelper.psm1') Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) ` -ChildPath 'CommonResourceHelper.psm1') -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerSetup' +$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlSetup' <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerSetup/MSFT_xSQLServerSetup.schema.mof b/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof similarity index 98% rename from DSCResources/MSFT_xSQLServerSetup/MSFT_xSQLServerSetup.schema.mof rename to DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof index 18ae419a0..b937d47af 100644 --- a/DSCResources/MSFT_xSQLServerSetup/MSFT_xSQLServerSetup.schema.mof +++ b/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerSetup")] -class MSFT_xSQLServerSetup : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlSetup")] +class MSFT_SqlSetup : OMI_BaseResource { [Write, Description("The action to be performed. Default value is 'Install'."), ValueMap{"Install","InstallFailoverCluster","AddNode","PrepareFailoverCluster","CompleteFailoverCluster"}, Values{"Install","InstallFailoverCluster","AddNode","PrepareFailoverCluster","CompleteFailoverCluster"}] String Action; [Write, Description("The path to the root of the source files for installation. I.e and UNC path to a shared resource. Environment variables can be used in the path.")] String SourcePath; diff --git a/DSCResources/MSFT_xSQLServerSetup/en-US/MSFT_xSQLServerSetup.strings.psd1 b/DSCResources/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 similarity index 99% rename from DSCResources/MSFT_xSQLServerSetup/en-US/MSFT_xSQLServerSetup.strings.psd1 rename to DSCResources/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 index 98a2174af..9530fcfbf 100644 --- a/DSCResources/MSFT_xSQLServerSetup/en-US/MSFT_xSQLServerSetup.strings.psd1 +++ b/DSCResources/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 @@ -1,4 +1,4 @@ -# Localized resources for xSQLServerSetup +# Localized resources for SqlSetup ConvertFrom-StringData @' UsingPath = Using path '{0}'. diff --git a/DSCResources/MSFT_xSQLServerSetup/sv-SE/MSFT_xSQLServerSetup.strings.psd1 b/DSCResources/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 similarity index 99% rename from DSCResources/MSFT_xSQLServerSetup/sv-SE/MSFT_xSQLServerSetup.strings.psd1 rename to DSCResources/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 index 2011dec31..ed61272c7 100644 --- a/DSCResources/MSFT_xSQLServerSetup/sv-SE/MSFT_xSQLServerSetup.strings.psd1 +++ b/DSCResources/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 @@ -1,4 +1,4 @@ -# Swedish localized resources for xSQLServerSetup +# Swedish localized resources for SqlSetup ConvertFrom-StringData @' UsingPath = Använder sökväg '{0}'. diff --git a/DSCResources/MSFT_xWaitForAvailabilityGroup/MSFT_xWaitForAvailabilityGroup.psm1 b/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 similarity index 99% rename from DSCResources/MSFT_xWaitForAvailabilityGroup/MSFT_xWaitForAvailabilityGroup.psm1 rename to DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 index e69cd82b6..253dd405e 100644 --- a/DSCResources/MSFT_xWaitForAvailabilityGroup/MSFT_xWaitForAvailabilityGroup.psm1 +++ b/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 @@ -1,5 +1,5 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) ` - -ChildPath 'xSQLServerHelper.psm1') ` + -ChildPath 'SqlServerDscHelper.psm1') ` -Force <# diff --git a/DSCResources/MSFT_xWaitForAvailabilityGroup/MSFT_xWaitForAvailabilityGroup.schema.mof b/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof similarity index 85% rename from DSCResources/MSFT_xWaitForAvailabilityGroup/MSFT_xWaitForAvailabilityGroup.schema.mof rename to DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof index 1562c36ef..759e43071 100644 --- a/DSCResources/MSFT_xWaitForAvailabilityGroup/MSFT_xWaitForAvailabilityGroup.schema.mof +++ b/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xWaitForAvailabilityGroup")] -class MSFT_xWaitForAvailabilityGroup : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlWaitForAG")] +class MSFT_SqlWaitForAG : OMI_BaseResource { [Key, Description("Name of the cluster role/group to look for (normally the same as the Availability Group name).")] String Name; [Write, Description("The interval, in seconds, to check for the presence of the cluster role/group. Default value is 20 seconds. When the cluster role/group has been found the resource will wait for this amount of time once more before returning.")] Uint64 RetryIntervalSec; diff --git a/DSCResources/MSFT_xSQLServerFirewall/MSFT_xSQLServerFirewall.psm1 b/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 similarity index 99% rename from DSCResources/MSFT_xSQLServerFirewall/MSFT_xSQLServerFirewall.psm1 rename to DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 index 4f47d5100..bdd0037a3 100644 --- a/DSCResources/MSFT_xSQLServerFirewall/MSFT_xSQLServerFirewall.psm1 +++ b/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 @@ -1,5 +1,5 @@ $script:currentPath = Split-Path -Path $MyInvocation.MyCommand.Path -Parent -Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $script:currentPath -Parent) -Parent) -ChildPath 'xSQLServerHelper.psm1') +Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $script:currentPath -Parent) -Parent) -ChildPath 'SqlServerDscHelper.psm1') <# .SYNOPSIS diff --git a/DSCResources/MSFT_xSQLServerFirewall/MSFT_xSQLServerFirewall.schema.mof b/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof similarity index 91% rename from DSCResources/MSFT_xSQLServerFirewall/MSFT_xSQLServerFirewall.schema.mof rename to DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof index 8879b0459..3a189fb47 100644 --- a/DSCResources/MSFT_xSQLServerFirewall/MSFT_xSQLServerFirewall.schema.mof +++ b/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof @@ -1,5 +1,5 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerFirewall")] -class MSFT_xSQLServerFirewall : OMI_BaseResource +[ClassVersion("1.0.0.0"), FriendlyName("SqlWindowsFirewall")] +class MSFT_SqlWindowsFirewall : OMI_BaseResource { [Write, Description("An enumerated value that describes if the SQL firewall rules are is expected to be enabled on the machine.\nPresent {default} \nAbsent \n"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Write, Description("UNC path to the root of the source files for installation.")] String SourcePath; diff --git a/Examples/DSCClusterSqlBuild.ps1 b/Examples/DSCClusterSqlBuild.ps1 index 68510a11e..367b55a09 100644 --- a/Examples/DSCClusterSqlBuild.ps1 +++ b/Examples/DSCClusterSqlBuild.ps1 @@ -36,7 +36,7 @@ foreach ($computer in $computers) Configuration AlwaysOnCluster { Import-DscResource –Module PSDesiredStateConfiguration - Import-DscResource -Module xSQLServer + Import-DscResource -Module SqlServerDSC Import-DscResource -Module xFailoverCluster Node $AllNodes.Where{$_.Role -eq "PrimaryClusterNode" }.NodeName @@ -88,7 +88,7 @@ Configuration AlwaysOnCluster DependsOn = '[WindowsFeature]NET' } - xSqlServerFirewall ($Node.NodeName) + SqlWindowsFirewall ($Node.NodeName) { SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName @@ -97,7 +97,7 @@ Configuration AlwaysOnCluster DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMemory ($Node.Nodename) + SqlServerMemory ($Node.Nodename) { Ensure = "Present" DynamicAlloc = $True @@ -105,7 +105,7 @@ Configuration AlwaysOnCluster DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMaxDop($Node.Nodename) + SqlServerMaxDop($Node.Nodename) { Ensure = "Present" DynamicAlloc = $true @@ -154,14 +154,14 @@ Configuration AlwaysOnCluster DependsOn = “[WindowsFeature]RSATClusteringCmdInterface” } - xSQLServerAlwaysOnService($Node.Nodename) + SqlAlwaysOnService($Node.Nodename) { Ensure = "Present" DependsOn = ("[xCluster]ensureCreated"),("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerEndpoint($Node.Nodename) + SqlServerEndpoint($Node.Nodename) { Ensure = "Present" Port = 5022 @@ -179,7 +179,7 @@ Configuration AlwaysOnCluster AvailabilityGroupSubMask ="255.255.255.0" SetupCredential = $Node.InstallerServiceAccount PsDscRunAsCredential = $Node.InstallerServiceAccount - DependsOn = ("[xSQLServerEndpoint]" + $Node.NodeName),("[xSQLServerAlwaysOnService]" + $Node.NodeName),("[WindowsFeature]ADTools") + DependsOn = ("[SqlServerEndpoint]" + $Node.NodeName),("[SqlAlwaysOnService]" + $Node.NodeName),("[WindowsFeature]ADTools") } } Node $AllNodes.Where{$_.Role -eq "ReplicaServerNode" }.NodeName @@ -224,7 +224,7 @@ Configuration AlwaysOnCluster DependsOn = '[WindowsFeature]NET' } - xSqlServerFirewall ($Node.NodeName) + SqlWindowsFirewall ($Node.NodeName) { SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName @@ -233,14 +233,14 @@ Configuration AlwaysOnCluster DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMemory ($Node.Nodename) + SqlServerMemory ($Node.Nodename) { Ensure = "Present" DynamicAlloc = $True DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMaxDop($Node.Nodename) + SqlServerMaxDop($Node.Nodename) { Ensure = "Present" DynamicAlloc = $true @@ -299,13 +299,13 @@ Configuration AlwaysOnCluster DependsOn = "[xWaitForCluster]waitForCluster" } - xSQLServerAlwaysOnService($Node.Nodename) + SqlAlwaysOnService($Node.Nodename) { Ensure = "Present" DependsOn = ("[xCluster]joinCluster"),("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerEndpoint($Node.Nodename) + SqlServerEndpoint($Node.Nodename) { Ensure = "Present" Port = 5022 @@ -314,13 +314,13 @@ Configuration AlwaysOnCluster DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xWaitForAvailabilityGroup waitforAG + SqlWaitForAG waitforAG { Name = "MyAG" RetryIntervalSec = 20 RetryCount = 6 - DependsOn = (“[xSQLServerEndpoint]" +$Node.Nodename),(“[xSQLServerAlwaysOnService]" +$Node.Nodename) + DependsOn = (“[SqlServerEndpoint]" +$Node.Nodename),(“[SqlServerAlwaysOnService]" +$Node.Nodename) } xSQLAOGroupJoin ($Node.Nodename) @@ -330,7 +330,7 @@ Configuration AlwaysOnCluster SetupCredential = $Node.InstallerServiceAccount PsDscRunAsCredential = $Node.InstallerServiceAccount - DependsOn = ("[xWaitForAvailabilityGroup]waitforAG") + DependsOn = ("[SqlWaitForAG]waitforAG") } } @@ -412,4 +412,3 @@ Workflow TestConfigs TestConfigs -computers $computers #> - diff --git a/Examples/DSCFCISqlBuild.ps1 b/Examples/DSCFCISqlBuild.ps1 index 928963efa..53802d33b 100644 --- a/Examples/DSCFCISqlBuild.ps1 +++ b/Examples/DSCFCISqlBuild.ps1 @@ -5,7 +5,7 @@ $OutputPath = 'F:\DSCConfig' Configuration FCISQL { Import-DscResource –Module PSDesiredStateConfiguration - Import-DscResource -Module xSQLServer + Import-DscResource -Module SqlServerDSC Import-DscResource -Module xFailoverCluster Node $AllNodes.NodeName @@ -64,7 +64,7 @@ Configuration FCISQL SQLSvcAccount = $Node.InstallerServiceAccount } - xSqlServerFirewall "FirewallMSSQLSERVER" + SqlWindowsFirewall "FirewallMSSQLSERVER" { DependsOn = "[xSQLServerFailoverClusterSetup]PrepareMSSQLSERVER" SourcePath = $Node.SourcePath @@ -212,4 +212,3 @@ Workflow StartConfigs } StartConfigs -Computers $computers -Path $OutputPath - diff --git a/Examples/DSCSQLBuildEncrypted.ps1 b/Examples/DSCSQLBuildEncrypted.ps1 index 2038c6e92..343b1e564 100644 --- a/Examples/DSCSQLBuildEncrypted.ps1 +++ b/Examples/DSCSQLBuildEncrypted.ps1 @@ -70,7 +70,7 @@ foreach ($computer in $computers) Configuration SQLBuild { Import-DscResource –Module PSDesiredStateConfiguration - Import-DscResource -Module xSQLServer + Import-DscResource -Module SqlServerDSC Node $AllNodes.NodeName { @@ -106,7 +106,7 @@ Configuration SQLBuild SQLTempDBLogDir = "L:\MSSQL\Data" SQLBackupDir = "G:\MSSQL\Backup" } - xSqlServerFirewall ($Node.NodeName) + SqlWindowsFirewall ($Node.NodeName) { SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName @@ -115,14 +115,14 @@ Configuration SQLBuild DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMemory ($Node.Nodename) + SqlServerMemory ($Node.Nodename) { Ensure = "Present" DynamicAlloc = $True DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMaxDop($Node.Nodename) + SqlServerMaxDop($Node.Nodename) { Ensure = "Present" DynamicAlloc = $true diff --git a/Examples/DSCSqlBuild.ps1 b/Examples/DSCSqlBuild.ps1 index 360db5c55..e90e07974 100644 --- a/Examples/DSCSqlBuild.ps1 +++ b/Examples/DSCSqlBuild.ps1 @@ -35,7 +35,7 @@ foreach ($computer in $computers) Configuration SQLBuild { Import-DscResource –ModuleName PSDesiredStateConfiguration - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDSC Node $AllNodes.NodeName @@ -88,7 +88,7 @@ Configuration SQLBuild DependsOn = '[WindowsFeature]NET' } - xSqlServerFirewall ($Node.NodeName) + SqlWindowsFirewall ($Node.NodeName) { SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName @@ -97,14 +97,14 @@ Configuration SQLBuild DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMemory ($Node.Nodename) + SqlServerMemory ($Node.Nodename) { Ensure = "Present" DynamicAlloc = $True DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - xSQLServerMaxDop($Node.Nodename) + SqlServerMaxDop($Node.Nodename) { Ensure = "Present" DynamicAlloc = $true @@ -113,7 +113,7 @@ Configuration SQLBuild } } - xSQLServerEndpoint($Node.Nodename) + SqlServerEndpoint($Node.Nodename) { Ensure = "Present" Port = 5022 diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/1-CreateAvailabilityGroup.ps1 b/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 similarity index 82% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/1-CreateAvailabilityGroup.ps1 rename to Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 index 033e5f312..7565b18aa 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/1-CreateAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 @@ -25,11 +25,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - xSQLServerLogin AddNTServiceClusSvc + SqlServerLogin AddNTServiceClusSvc { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' @@ -40,9 +40,9 @@ Configuration Example } # Add the required permissions to the cluster service login - xSQLServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission AddNTServiceClusSvcPermissions { - DependsOn = '[xSQLServerLogin]AddNTServiceClusSvc' + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' NodeName = $Node.NodeName InstanceName = $Node.SqlInstanceName @@ -52,7 +52,7 @@ Configuration Example } # Create a DatabaseMirroring endpoint - xSQLServerEndpoint HADREndpoint + SqlServerEndpoint HADREndpoint { EndPointName = 'HADR' Ensure = 'Present' @@ -65,13 +65,13 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup AddTestAG + SqlAG AddTestAG { Ensure = 'Present' Name = 'TestAG' SQLInstanceName = $Node.SQLInstanceName SQLServer = $Node.NodeName - DependsOn = '[xSQLServerEndpoint]HADREndpoint', '[xSQLServerPermission]AddNTServiceClusSvcPermissions' + DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SysAdminAccount } } diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/2-RemoveAvailabilityGroup.ps1 b/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 similarity index 90% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/2-RemoveAvailabilityGroup.ps1 rename to Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 index 719f450a9..8637df955 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/2-RemoveAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 @@ -25,13 +25,13 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup RemoveTestAG + SqlAG RemoveTestAG { Ensure = 'Absent' Name = 'TestAG' diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/3-CreateAvailabilityGroupDetailed.ps1 b/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 similarity index 89% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/3-CreateAvailabilityGroupDetailed.ps1 rename to Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 index 51ddbe8ee..01f7c504e 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/3-CreateAvailabilityGroupDetailed.ps1 +++ b/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 @@ -43,11 +43,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - xSQLServerLogin AddNTServiceClusSvc + SqlServerLogin AddNTServiceClusSvc { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' @@ -58,9 +58,9 @@ Configuration Example } # Add the required permissions to the cluster service login - xSQLServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission AddNTServiceClusSvcPermissions { - DependsOn = '[xSQLServerLogin]AddNTServiceClusSvc' + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' NodeName = $Node.NodeName InstanceName = $Node.SqlInstanceName @@ -70,7 +70,7 @@ Configuration Example } # Create a DatabaseMirroring endpoint - xSQLServerEndpoint HADREndpoint + SqlServerEndpoint HADREndpoint { EndPointName = 'HADR' Ensure = 'Present' @@ -83,7 +83,7 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup AddTestAG + SqlAG AddTestAG { Ensure = 'Present' Name = 'TestAG' @@ -104,7 +104,7 @@ Configuration Example DatabaseHealthTrigger = $Node.DatabaseHealthTrigger DtcSupportEnabled = $Node.DtcSupportEnabled - DependsOn = '[xSQLServerEndpoint]HADREndpoint', '[xSQLServerPermission]AddNTServiceClusSvcPermissions' + DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SysAdminAccount } } diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/1-AddDatabasesToAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 similarity index 86% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/1-AddDatabasesToAvailabilityGroup.ps1 rename to Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 index b2869c583..d6f28b2e2 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/1-AddDatabasesToAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 @@ -36,11 +36,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - xSQLServerLogin AddNTServiceClusSvc + SqlServerLogin AddNTServiceClusSvc { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' @@ -51,9 +51,9 @@ Configuration Example } # Add the required permissions to the cluster service login - xSQLServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission AddNTServiceClusSvcPermissions { - DependsOn = '[xSQLServerLogin]AddNTServiceClusSvc' + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' NodeName = $Node.NodeName InstanceName = $Node.SqlInstanceName @@ -63,7 +63,7 @@ Configuration Example } # Create a DatabaseMirroring endpoint - xSQLServerEndpoint HADREndpoint + SqlServerEndpoint HADREndpoint { EndPointName = 'HADR' Ensure = 'Present' @@ -76,13 +76,13 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup AddTestAG + SqlAG AddTestAG { Ensure = 'Present' Name = $Node.AvailabilityGroupName SQLInstanceName = $Node.SQLInstanceName SQLServer = $Node.NodeName - DependsOn = '[xSQLServerEndpoint]HADREndpoint', '[xSQLServerPermission]AddNTServiceClusSvcPermissions' + DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SysAdminAccount } } @@ -90,7 +90,7 @@ Configuration Example if ( $Node.Role -eq 'SecondaryReplica' ) { # Add the availability group replica to the availability group - xSQLServerAlwaysOnAvailabilityGroupReplica AddReplica + SqlAGReplica AddReplica { Ensure = 'Present' Name = $Node.NodeName @@ -104,7 +104,7 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { - xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership 'TestAGDatabaseMemberships' + SqlAGDatabase 'TestAGDatabaseMemberships' { AvailabilityGroupName = $Node.AvailabilityGroupName BackupPath = '\\SQL1\AgInitialize' diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/2-RemoveDatabasesFromAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 similarity index 85% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/2-RemoveDatabasesFromAvailabilityGroup.ps1 rename to Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 index 1af3cd0b7..2ef77e7e0 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/2-RemoveDatabasesFromAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 @@ -31,11 +31,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - xSQLServerLogin AddNTServiceClusSvc + SqlServerLogin AddNTServiceClusSvc { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' @@ -46,9 +46,9 @@ Configuration Example } # Add the required permissions to the cluster service login - xSQLServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission AddNTServiceClusSvcPermissions { - DependsOn = '[xSQLServerLogin]AddNTServiceClusSvc' + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' NodeName = $Node.NodeName InstanceName = $Node.SqlInstanceName @@ -58,7 +58,7 @@ Configuration Example } # Create a DatabaseMirroring endpoint - xSQLServerEndpoint HADREndpoint + SqlServerEndpoint HADREndpoint { EndPointName = 'HADR' Ensure = 'Present' @@ -71,13 +71,13 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup AddTestAG + SqlAG AddTestAG { Ensure = 'Present' Name = $Node.AvailabilityGroupName SQLInstanceName = $Node.SQLInstanceName SQLServer = $Node.NodeName - DependsOn = '[xSQLServerEndpoint]HADREndpoint', '[xSQLServerPermission]AddNTServiceClusSvcPermissions' + DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SysAdminAccount } } @@ -85,7 +85,7 @@ Configuration Example if ( $Node.Role -eq 'SecondaryReplica' ) { # Add the availability group replica to the availability group - xSQLServerAlwaysOnAvailabilityGroupReplica AddReplica + SqlAGReplica AddReplica { Ensure = 'Present' Name = $Node.NodeName @@ -99,7 +99,7 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { - xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership 'TestAGDatabaseMemberships' + SqlAGDatabase 'TestAGDatabaseMemberships' { AvailabilityGroupName = $Node.AvailabilityGroupName BackupPath = '\\SQL1\AgInitialize' diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/3-MatchDefinedDatabasesInAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 similarity index 85% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/3-MatchDefinedDatabasesInAvailabilityGroup.ps1 rename to Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 index a2039e006..7a79ad6a8 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership/3-MatchDefinedDatabasesInAvailabilityGroup.ps1 +++ b/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 @@ -31,11 +31,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - xSQLServerLogin AddNTServiceClusSvc + SqlServerLogin AddNTServiceClusSvc { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' @@ -46,9 +46,9 @@ Configuration Example } # Add the required permissions to the cluster service login - xSQLServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission AddNTServiceClusSvcPermissions { - DependsOn = '[xSQLServerLogin]AddNTServiceClusSvc' + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' NodeName = $Node.NodeName InstanceName = $Node.SqlInstanceName @@ -58,7 +58,7 @@ Configuration Example } # Create a DatabaseMirroring endpoint - xSQLServerEndpoint HADREndpoint + SqlServerEndpoint HADREndpoint { EndPointName = 'HADR' Ensure = 'Present' @@ -71,13 +71,13 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup AddTestAG + SqlAG AddTestAG { Ensure = 'Present' Name = $Node.AvailabilityGroupName SQLInstanceName = $Node.SQLInstanceName SQLServer = $Node.NodeName - DependsOn = '[xSQLServerEndpoint]HADREndpoint', '[xSQLServerPermission]AddNTServiceClusSvcPermissions' + DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SysAdminAccount } } @@ -85,7 +85,7 @@ Configuration Example if ( $Node.Role -eq 'SecondaryReplica' ) { # Add the availability group replica to the availability group - xSQLServerAlwaysOnAvailabilityGroupReplica AddReplica + SqlAGReplica AddReplica { Ensure = 'Present' Name = $Node.NodeName @@ -99,7 +99,7 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { - xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership 'TestAGDatabaseMemberships' + SqlAGDatabase 'TestAGDatabaseMemberships' { AvailabilityGroupName = $Node.AvailabilityGroupName BackupPath = '\\SQL1\AgInitialize' diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 b/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 similarity index 85% rename from Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 rename to Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 index d93ac05ee..5c255b90c 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 +++ b/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAvailabilityGroupListener AvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener AvailabilityGroupListenerWithSameNameAsVCO { Ensure = 'Present' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 b/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 similarity index 85% rename from Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 rename to Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 index 1d052e55d..9b07a7932 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 +++ b/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAvailabilityGroupListener AvailabilityGroupListenerWithDifferentNameAsVCO + SqlAGListener AvailabilityGroupListenerWithDifferentNameAsVCO { Ensure = 'Present' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 b/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 similarity index 82% rename from Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 rename to Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 index 712418e7e..fa7552124 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 +++ b/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAvailabilityGroupListener RemoveAvailabilityGroupListenerWithDifferentNameAsVCO + SqlAGListener RemoveAvailabilityGroupListenerWithDifferentNameAsVCO { Ensure = 'Absent' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 b/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 similarity index 83% rename from Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 rename to Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 index e20f3b591..8003f7832 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 +++ b/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAvailabilityGroupListener RemoveAvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener RemoveAvailabilityGroupListenerWithSameNameAsVCO { Ensure = 'Absent' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 b/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 similarity index 86% rename from Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 rename to Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 index 64fc72568..e8eb0365b 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 +++ b/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAvailabilityGroupListener AvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener AvailabilityGroupListenerWithSameNameAsVCO { Ensure = 'Present' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 b/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 similarity index 85% rename from Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 rename to Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 index b547ff066..ab5cffd9c 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 +++ b/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAvailabilityGroupListener AvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener AvailabilityGroupListenerWithSameNameAsVCO { Ensure = 'Present' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/1-CreateAvailabilityGroupReplica.ps1 b/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 similarity index 87% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/1-CreateAvailabilityGroupReplica.ps1 rename to Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 index 05805026e..e56bf0fdb 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/1-CreateAvailabilityGroupReplica.ps1 +++ b/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 @@ -38,11 +38,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - xSQLServerLogin AddNTServiceClusSvc + SqlServerLogin AddNTServiceClusSvc { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' @@ -53,9 +53,9 @@ Configuration Example } # Add the required permissions to the cluster service login - xSQLServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission AddNTServiceClusSvcPermissions { - DependsOn = '[xSQLServerLogin]AddNTServiceClusSvc' + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' NodeName = $Node.NodeName InstanceName = $Node.SqlInstanceName @@ -65,7 +65,7 @@ Configuration Example } # Create a DatabaseMirroring endpoint - xSQLServerEndpoint HADREndpoint + SqlServerEndpoint HADREndpoint { EndPointName = 'HADR' Ensure = 'Present' @@ -78,13 +78,13 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup AddTestAG + SqlAG AddTestAG { Ensure = 'Present' Name = $Node.AvailabilityGroupName SQLInstanceName = $Node.SQLInstanceName SQLServer = $Node.NodeName - DependsOn = '[xSQLServerEndpoint]HADREndpoint', '[xSQLServerPermission]AddNTServiceClusSvcPermissions' + DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SysAdminAccount } } @@ -92,7 +92,7 @@ Configuration Example if ( $Node.Role -eq 'SecondaryReplica' ) { # Add the availability group replica to the availability group - xSQLServerAlwaysOnAvailabilityGroupReplica AddReplica + SqlAGReplica AddReplica { Ensure = 'Present' Name = $Node.NodeName diff --git a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/2-RemoveAvailabilityGroupReplica.ps1 b/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 similarity index 85% rename from Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/2-RemoveAvailabilityGroupReplica.ps1 rename to Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 index 3634f7f50..463de22b9 100644 --- a/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/2-RemoveAvailabilityGroupReplica.ps1 +++ b/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 @@ -31,11 +31,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - xSQLServerLogin AddNTServiceClusSvc + SqlServerLogin AddNTServiceClusSvc { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' @@ -46,9 +46,9 @@ Configuration Example } # Add the required permissions to the cluster service login - xSQLServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission AddNTServiceClusSvcPermissions { - DependsOn = '[xSQLServerLogin]AddNTServiceClusSvc' + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' NodeName = $Node.NodeName InstanceName = $Node.SqlInstanceName @@ -58,7 +58,7 @@ Configuration Example } # Create a DatabaseMirroring endpoint - xSQLServerEndpoint HADREndpoint + SqlServerEndpoint HADREndpoint { EndPointName = 'HADR' Ensure = 'Present' @@ -71,13 +71,13 @@ Configuration Example if ( $Node.Role -eq 'PrimaryReplica' ) { # Create the availability group on the instance tagged as the primary replica - xSQLServerAlwaysOnAvailabilityGroup AddTestAG + SqlAG AddTestAG { Ensure = 'Present' Name = $Node.AvailabilityGroupName SQLInstanceName = $Node.SQLInstanceName SQLServer = $Node.NodeName - DependsOn = '[xSQLServerEndpoint]HADREndpoint', '[xSQLServerPermission]AddNTServiceClusSvcPermissions' + DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' PsDscRunAsCredential = $SysAdminAccount } } @@ -85,7 +85,7 @@ Configuration Example if ( $Node.Role -eq 'SecondaryReplica' ) { # Add the availability group replica to the availability group - xSQLServerAlwaysOnAvailabilityGroupReplica AddReplica + SqlAGReplica AddReplica { Ensure = 'Absent' Name = $Node.NodeName diff --git a/Examples/Resources/xSQLServerAlias/1-AddSQLServerAlias.ps1 b/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 similarity index 86% rename from Examples/Resources/xSQLServerAlias/1-AddSQLServerAlias.ps1 rename to Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 index 9654e65ec..f60b68573 100644 --- a/Examples/Resources/xSQLServerAlias/1-AddSQLServerAlias.ps1 +++ b/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 @@ -12,10 +12,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAlias Add_SqlAlias_TCP + SqlAlias Add_SqlAlias_TCP { Ensure = 'Present' Name = 'SQLDSC-TCP' @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerAlias Add_SqlAlias_TCPUseDynamicTcpPort + SqlAlias Add_SqlAlias_TCPUseDynamicTcpPort { Ensure = 'Present' Name = 'SQLDSC-DYN' @@ -35,7 +35,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerAlias Add_SqlAlias_NP + SqlAlias Add_SqlAlias_NP { Ensure = 'Present' Name = 'SQLDSC-NP' diff --git a/Examples/Resources/xSQLServerAlias/2-RemoveSQLServerAlias.ps1 b/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 similarity index 86% rename from Examples/Resources/xSQLServerAlias/2-RemoveSQLServerAlias.ps1 rename to Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 index 986105874..6ee659605 100644 --- a/Examples/Resources/xSQLServerAlias/2-RemoveSQLServerAlias.ps1 +++ b/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 @@ -12,10 +12,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAlias Remove_SqlAlias_TCP + SqlAlias Remove_SqlAlias_TCP { Ensure = 'Absent' Name = 'SQLDSC-TCP' @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerAlias Remove_SqlAlias_NP + SqlAlias Remove_SqlAlias_NP { Ensure = 'Absent' Name = 'SQLDSC-NP' diff --git a/Examples/Resources/xSQLServerAlwaysOnService/1-EnableAlwaysOn.ps1 b/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 similarity index 86% rename from Examples/Resources/xSQLServerAlwaysOnService/1-EnableAlwaysOn.ps1 rename to Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 index 9bc907218..686cf61c7 100644 --- a/Examples/Resources/xSQLServerAlwaysOnService/1-EnableAlwaysOn.ps1 +++ b/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAlwaysOnService 'EnableAlwaysOn' + SqlAlwaysOnService 'EnableAlwaysOn' { Ensure = 'Present' SQLServer = 'SP23-VM-SQL1' diff --git a/Examples/Resources/xSQLServerAlwaysOnService/2-DisableAlwaysOn.ps1 b/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 similarity index 86% rename from Examples/Resources/xSQLServerAlwaysOnService/2-DisableAlwaysOn.ps1 rename to Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 index 9d45fab51..a9b7cbbb2 100644 --- a/Examples/Resources/xSQLServerAlwaysOnService/2-DisableAlwaysOn.ps1 +++ b/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerAlwaysOnService 'DisableAlwaysOn' + SqlAlwaysOnService 'DisableAlwaysOn' { Ensure = 'Absent' SQLServer = 'SP23-VM-SQL1' diff --git a/Examples/Resources/xSQLServerDatabase/1-CreateDatabase.ps1 b/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 similarity index 84% rename from Examples/Resources/xSQLServerDatabase/1-CreateDatabase.ps1 rename to Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 index 0bd9e3c29..419cb6a61 100644 --- a/Examples/Resources/xSQLServerDatabase/1-CreateDatabase.ps1 +++ b/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 @@ -16,11 +16,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerDatabase Create_Database + SqlDatabase Create_Database { Ensure = 'Present' SQLServer = 'SQLServer' @@ -28,7 +28,7 @@ Configuration Example Name = 'Contoso' } - xSQLServerDatabase Create_Database_with_different_collation + SqlDatabase Create_Database_with_different_collation { Ensure = 'Present' SQLServer = 'SQLServer' diff --git a/Examples/Resources/xSQLServerDatabase/2-DeleteDatabase.ps1 b/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 similarity index 86% rename from Examples/Resources/xSQLServerDatabase/2-DeleteDatabase.ps1 rename to Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 index 34bbca64e..2d115d4f0 100644 --- a/Examples/Resources/xSQLServerDatabase/2-DeleteDatabase.ps1 +++ b/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerDatabase Delete_Database + SqlDatabase Delete_Database { Ensure = 'Absent' SQLServer = 'SQLServer' diff --git a/Examples/Resources/xSQLServerDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 b/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 similarity index 85% rename from Examples/Resources/xSQLServerDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 rename to Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 index 86e289a07..af3dfd695 100644 --- a/Examples/Resources/xSQLServerDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 +++ b/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 @@ -16,11 +16,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Data + SqlDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Data { SQLServer = 'SQLServer' SQLInstanceName = 'DSC' @@ -30,7 +30,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Log + SqlDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Log { SQLServer = 'SQLServer' SQLInstanceName = 'DSC' @@ -40,7 +40,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Backup + SqlDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Backup { SQLServer = 'SQLServer' SQLInstanceName = 'DSC' diff --git a/Examples/Resources/xSQLServerDatabaseOwner/1-SetDatabaseOwner.ps1 b/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 similarity index 85% rename from Examples/Resources/xSQLServerDatabaseOwner/1-SetDatabaseOwner.ps1 rename to Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 index 6b6e00794..6ad05fcfc 100644 --- a/Examples/Resources/xSQLServerDatabaseOwner/1-SetDatabaseOwner.ps1 +++ b/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerLogin Add_SqlServerLogin_SQLAdmin + SqlServerLogin Add_SqlServerLogin_SQLAdmin { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -27,7 +27,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabaseOwner Set_SqlDatabaseOwner_SQLAdmin + SqlDatabaseOwner Set_SqlDatabaseOwner_SQLAdmin { Name = 'CONTOSO\SQLAdmin' Database = 'AdventureWorks' diff --git a/Examples/Resources/xSQLServerDatabasePermission/1-GrantDatabasePermissions.ps1 b/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 similarity index 84% rename from Examples/Resources/xSQLServerDatabasePermission/1-GrantDatabasePermissions.ps1 rename to Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 index 209b22059..7c59b5cee 100644 --- a/Examples/Resources/xSQLServerDatabasePermission/1-GrantDatabasePermissions.ps1 +++ b/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 @@ -12,10 +12,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerLogin Add_SqlServerLogin_SQLAdmin + SqlServerLogin Add_SqlServerLogin_SQLAdmin { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerLogin Add_SqlServerLogin_SQLUser + SqlServerLogin Add_SqlServerLogin_SQLUser { Ensure = 'Present' Name = 'CONTOSO\SQLUser' @@ -35,7 +35,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabasePermission Grant_SqlDatabasePermissions_SQLAdmin_Db01 + SqlDatabasePermission Grant_SqlDatabasePermissions_SQLAdmin_Db01 { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -47,7 +47,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabasePermission Grant_SqlDatabasePermissions_SQLUser_Db01 + SqlDatabasePermission Grant_SqlDatabasePermissions_SQLUser_Db01 { Ensure = 'Present' Name = 'CONTOSO\SQLUser' @@ -59,7 +59,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabasePermission Grant_SqlDatabasePermissions_SQLAdmin_Db02 + SqlDatabasePermission Grant_SqlDatabasePermissions_SQLAdmin_Db02 { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' diff --git a/Examples/Resources/xSQLServerDatabasePermission/2-RevokeDatabasePermissions.ps1 b/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 similarity index 84% rename from Examples/Resources/xSQLServerDatabasePermission/2-RevokeDatabasePermissions.ps1 rename to Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 index 701fed79e..f3149b3ea 100644 --- a/Examples/Resources/xSQLServerDatabasePermission/2-RevokeDatabasePermissions.ps1 +++ b/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 @@ -12,10 +12,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerDatabasePermission RevokeGrant_SqlDatabasePermissions_SQLAdmin + SqlDatabasePermission RevokeGrant_SqlDatabasePermissions_SQLAdmin { Ensure = 'Absent' Name = 'CONTOSO\SQLAdmin' @@ -27,7 +27,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabasePermission RevokeDeny_SqlDatabasePermissions_SQLAdmin + SqlDatabasePermission RevokeDeny_SqlDatabasePermissions_SQLAdmin { Ensure = 'Absent' Name = 'CONTOSO\SQLAdmin' diff --git a/Examples/Resources/xSQLServerDatabasePermission/3-DenyDatabasePermissions.ps1 b/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 similarity index 85% rename from Examples/Resources/xSQLServerDatabasePermission/3-DenyDatabasePermissions.ps1 rename to Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 index 940826148..8128ffde9 100644 --- a/Examples/Resources/xSQLServerDatabasePermission/3-DenyDatabasePermissions.ps1 +++ b/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 @@ -12,10 +12,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerLogin Add_SqlServerLogin_SQLAdmin + SqlServerLogin Add_SqlServerLogin_SQLAdmin { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerLogin Add_SqlServerLogin_SQLUser + SqlServerLogin Add_SqlServerLogin_SQLUser { Ensure = 'Present' Name = 'CONTOSO\SQLUser' @@ -35,7 +35,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabasePermission Deny_SqlDatabasePermissions_SQLAdmin_Db01 + SqlDatabasePermission Deny_SqlDatabasePermissions_SQLAdmin_Db01 { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -47,7 +47,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabasePermission Deny_SqlDatabasePermissions_SQLUser_Db01 + SqlDatabasePermission Deny_SqlDatabasePermissions_SQLUser_Db01 { Ensure = 'Present' Name = 'CONTOSO\SQLUser' @@ -59,7 +59,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabasePermission Deny_SqlDatabasePermissions_SQLAdmin_Db02 + SqlDatabasePermission Deny_SqlDatabasePermissions_SQLAdmin_Db02 { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' diff --git a/Examples/Resources/xSQLServerDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 b/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 similarity index 80% rename from Examples/Resources/xSQLServerDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 rename to Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 index d8682edfc..982e74617 100644 --- a/Examples/Resources/xSQLServerDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 +++ b/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 @@ -14,11 +14,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerDatabase Add_SqlDatabaseAdventureworks + SqlDatabase Add_SqlDatabaseAdventureworks { Ensure = 'Present' Name = 'Adventureworks' @@ -27,7 +27,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabase Add_SqlDatabaseAdventureWorks2012 + SqlDatabase Add_SqlDatabaseAdventureWorks2012 { Ensure = 'Present' Name = 'AdventureWorks2012' @@ -36,7 +36,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabaseRecoveryModel Set_SqlDatabaseRecoveryModel_Adventureworks + SqlDatabaseRecoveryModel Set_SqlDatabaseRecoveryModel_Adventureworks { Name = 'Adventureworks' RecoveryModel = 'Full' @@ -45,7 +45,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerDatabaseRecoveryModel Set_SqlDatabaseRecoveryModel_AdventureWorks2012 + SqlDatabaseRecoveryModel Set_SqlDatabaseRecoveryModel_AdventureWorks2012 { Name = 'AdventureWorks2012' RecoveryModel = 'Simple' diff --git a/Examples/Resources/xSQLServerDatabaseRole/1-AddDatabaseRole.ps1 b/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 similarity index 88% rename from Examples/Resources/xSQLServerDatabaseRole/1-AddDatabaseRole.ps1 rename to Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 index b461a5bf2..31d6eea2a 100644 --- a/Examples/Resources/xSQLServerDatabaseRole/1-AddDatabaseRole.ps1 +++ b/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerDatabaseRole Add_Database_Role + SqlDatabaseRole Add_Database_Role { Ensure = 'Present' SQLServer = 'SQLServer' diff --git a/Examples/Resources/xSQLServerDatabaseRole/2-RemoveDatabaseRole.ps1 b/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 similarity index 88% rename from Examples/Resources/xSQLServerDatabaseRole/2-RemoveDatabaseRole.ps1 rename to Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 index 97e6a769a..0bcd510bd 100644 --- a/Examples/Resources/xSQLServerDatabaseRole/2-RemoveDatabaseRole.ps1 +++ b/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerDatabaseRole Remove_Database_Role + SqlDatabaseRole Remove_Database_Role { Ensure = 'Absent' SQLServer = 'SQLServer' diff --git a/Examples/Resources/xSQLServerRSConfig/1-DefaultConfiguration.ps1 b/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 similarity index 80% rename from Examples/Resources/xSQLServerRSConfig/1-DefaultConfiguration.ps1 rename to Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 index b780ed6b8..a14acec08 100644 --- a/Examples/Resources/xSQLServerRSConfig/1-DefaultConfiguration.ps1 +++ b/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 @@ -1,22 +1,22 @@ -<# -.EXAMPLE - This example performs a default SSRS configuration. It will initialize SSRS - and register default Report Server Web Service and Report Manager URLs: - - http://localhost:80/ReportServer (Report Server Web Service) - - http://localhost:80/Reports (Report Manager) -#> -Configuration Example -{ - Import-DscResource -ModuleName xSqlServer - - node localhost { - xSQLServerRSConfig DefaultConfiguration - { - InstanceName = 'MSSQLSERVER' - RSSQLServer = 'localhost' - RSSQLInstanceName = 'MSSQLSERVER' - } - } -} +<# +.EXAMPLE + This example performs a default SSRS configuration. It will initialize SSRS + and register default Report Server Web Service and Report Manager URLs: + + http://localhost:80/ReportServer (Report Server Web Service) + + http://localhost:80/Reports (Report Manager) +#> +Configuration Example +{ + Import-DscResource -ModuleName SqlServerDsc + + node localhost { + SqlRS DefaultConfiguration + { + InstanceName = 'MSSQLSERVER' + RSSQLServer = 'localhost' + RSSQLInstanceName = 'MSSQLSERVER' + } + } +} diff --git a/Examples/Resources/xSQLServerRSConfig/2-CustomConfiguration.ps1 b/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 similarity index 87% rename from Examples/Resources/xSQLServerRSConfig/2-CustomConfiguration.ps1 rename to Examples/Resources/SqlRS/2-CustomConfiguration.ps1 index 2c616b763..d1a872ff3 100644 --- a/Examples/Resources/xSQLServerRSConfig/2-CustomConfiguration.ps1 +++ b/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 @@ -1,31 +1,31 @@ -<# -.EXAMPLE - This example performs a custom SSRS configuration. It will initialize SSRS - and register custom Report Server Web Service and Report Manager URLs: - - http://localhost:80/MyReportServer - https://localhost:443/MyReportServer (Report Server Web Service) - - http://localhost:80/MyReports - https://localhost:443/MyReports (Report Manager) - - Please note: this resource does not currently handle SSL bindings for HTTPS - endpoints. -#> -Configuration Example -{ - Import-DscResource -ModuleName xSqlServer - - node localhost { - xSQLServerRSConfig DefaultConfiguration - { - InstanceName = 'MSSQLSERVER' - RSSQLServer = 'localhost' - RSSQLInstanceName = 'MSSQLSERVER' - ReportServerVirtualDirectory = 'MyReportServer' - ReportsVirtualDirectory = 'MyReports' - ReportServerReservedUrl = @('http://+:80', 'https://+:443') - ReportsReservedUrl = @('http://+:80', 'https://+:443') - } - } -} +<# +.EXAMPLE + This example performs a custom SSRS configuration. It will initialize SSRS + and register custom Report Server Web Service and Report Manager URLs: + + http://localhost:80/MyReportServer + https://localhost:443/MyReportServer (Report Server Web Service) + + http://localhost:80/MyReports + https://localhost:443/MyReports (Report Manager) + + Please note: this resource does not currently handle SSL bindings for HTTPS + endpoints. +#> +Configuration Example +{ + Import-DscResource -ModuleName SqlServerDsc + + node localhost { + SqlRS DefaultConfiguration + { + InstanceName = 'MSSQLSERVER' + RSSQLServer = 'localhost' + RSSQLInstanceName = 'MSSQLSERVER' + ReportServerVirtualDirectory = 'MyReportServer' + ReportsVirtualDirectory = 'MyReports' + ReportServerReservedUrl = @('http://+:80', 'https://+:443') + ReportsReservedUrl = @('http://+:80', 'https://+:443') + } + } +} diff --git a/Examples/Resources/xSQLServerScript/1-RunScriptUsingSQLAuthentication.ps1 b/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 similarity index 88% rename from Examples/Resources/xSQLServerScript/1-RunScriptUsingSQLAuthentication.ps1 rename to Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 index 659c076f4..ff0458a1a 100644 --- a/Examples/Resources/xSQLServerScript/1-RunScriptUsingSQLAuthentication.ps1 +++ b/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 @@ -11,11 +11,11 @@ Configuration Example $SqlCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc Node localhost { - xSQLServerScript 'RunSQLScript' + SqlScript 'RunSQLScript' { ServerInstance = 'localhost\SQL2016' Credential = $SqlCredential diff --git a/Examples/Resources/xSQLServerScript/2-RunScriptUsingWindowsAuthentication.ps1 b/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 similarity index 89% rename from Examples/Resources/xSQLServerScript/2-RunScriptUsingWindowsAuthentication.ps1 rename to Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 index 3e5664c7b..dcb5f6cfb 100644 --- a/Examples/Resources/xSQLServerScript/2-RunScriptUsingWindowsAuthentication.ps1 +++ b/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 @@ -12,11 +12,11 @@ Configuration Example $WindowsCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc Node localhost { - xSQLServerScript 'RunSQLScript-AsSYSTEM' + SqlScript 'RunSQLScript-AsSYSTEM' { ServerInstance = 'localhost\SQL2016' @@ -26,7 +26,7 @@ Configuration Example Variable = @("FilePath=C:\temp\log\AuditFiles") } - xSQLServerScript 'RunSQLScript-AsUSER' + SqlScript 'RunSQLScript-AsUSER' { ServerInstance = 'localhost\SQL2016' @@ -38,7 +38,7 @@ Configuration Example PsDscRunAsCredential = $WindowsCredential } - xSQLServerScript 'RunSQLScript-With30SecondTimeout' + SqlScript 'RunSQLScript-With30SecondTimeout' { ServerInstance = 'localhost\SQL2016' diff --git a/Examples/Resources/xSQLServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 b/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 similarity index 87% rename from Examples/Resources/xSQLServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 rename to Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 index 25d1152e6..5173fa11e 100644 --- a/Examples/Resources/xSQLServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 +++ b/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 @@ -17,13 +17,13 @@ $configurationData = @{ Configuration Example { - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { foreach ($SQLInstance in $node.SQLInstances) { - xSQLServerConfiguration ('SQLConfigCLR_{0}' -f $SQLInstance) + SqlServerConfiguration ('SQLConfigCLR_{0}' -f $SQLInstance) { SQLServer = $node.NodeName SQLInstanceName = $SQLInstance diff --git a/Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 b/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 similarity index 84% rename from Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 rename to Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 index 93c1b222c..9fa7337cf 100644 --- a/Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 +++ b/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 @@ -7,11 +7,11 @@ Configuration Example { - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerConfiguration 'SQLConfigPriorityBoost' + SqlServerConfiguration 'SQLConfigPriorityBoost' { SQLServer = 'localhost' diff --git a/Examples/Resources/xSQLServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 b/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 similarity index 80% rename from Examples/Resources/xSQLServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 rename to Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 index 3bbb8bf7d..4968a1474 100644 --- a/Examples/Resources/xSQLServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 +++ b/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerEndpoint SQLConfigureEndpoint-Instance1 + SqlServerEndpoint SQLConfigureEndpoint-Instance1 { EndpointName = 'HADR' SQLInstanceName = 'INST1' @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerEndpoint SQLConfigureEndpoint-Instances2 + SqlServerEndpoint SQLConfigureEndpoint-Instances2 { EndpointName = 'HADR' SQLInstanceName = 'INST2' diff --git a/Examples/Resources/xSQLServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 b/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 similarity index 88% rename from Examples/Resources/xSQLServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 rename to Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 index f807d42be..2a7dac754 100644 --- a/Examples/Resources/xSQLServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 +++ b/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerEndpoint SQLConfigureEndpoint + SqlServerEndpoint SQLConfigureEndpoint { Ensure = 'Present' diff --git a/Examples/Resources/xSQLServerEndpoint/3-RemoveEndpoint.ps1 b/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 similarity index 82% rename from Examples/Resources/xSQLServerEndpoint/3-RemoveEndpoint.ps1 rename to Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 index deecb023c..5d280483e 100644 --- a/Examples/Resources/xSQLServerEndpoint/3-RemoveEndpoint.ps1 +++ b/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerEndpoint SQLConfigureEndpoint-Instance1 + SqlServerEndpoint SQLConfigureEndpoint-Instance1 { Ensure = 'Absent' @@ -27,7 +27,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerEndpoint SQLConfigureEndpoint-Instance2 + SqlServerEndpoint SQLConfigureEndpoint-Instance2 { Ensure = 'Absent' diff --git a/Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1 b/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 similarity index 89% rename from Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1 rename to Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 index fea85e1fb..7111808bd 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1 +++ b/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 @@ -18,11 +18,11 @@ Configuration Example $SqlServiceCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerEndpointPermission SQLConfigureEndpointPermission + SqlServerEndpointPermission SQLConfigureEndpointPermission { Ensure = 'Present' NodeName = $Node.NodeName diff --git a/Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1 b/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 similarity index 89% rename from Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1 rename to Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 index 47a1192c6..b28400ebe 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1 +++ b/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 @@ -18,11 +18,11 @@ Configuration Example $SqlServiceCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerEndpointPermission SQLConfigureEndpointPermission + SqlServerEndpointPermission SQLConfigureEndpointPermission { Ensure = 'Absent' NodeName = $Node.NodeName diff --git a/Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 b/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 similarity index 89% rename from Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 rename to Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 index 1c750eb61..23e1ea040 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 +++ b/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 @@ -43,11 +43,11 @@ Configuration Example $SqlServiceNode2Credential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node $AllNodes.Where{$_.Role -eq 'PrimaryReplica' }.NodeName { - xSQLServerEndpointPermission SQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission SQLConfigureEndpointPermissionPrimary { Ensure = 'Present' NodeName = $Node.NodeName @@ -59,7 +59,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerEndpointPermission SQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission SQLConfigureEndpointPermissionSecondary { Ensure = 'Present' NodeName = $Node.NodeName @@ -74,7 +74,7 @@ Configuration Example Node $AllNodes.Where{ $_.Role -eq 'SecondaryReplica' }.NodeName { - xSQLServerEndpointPermission SQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission SQLConfigureEndpointPermissionPrimary { Ensure = 'Present' NodeName = $Node.NodeName @@ -86,7 +86,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerEndpointPermission SQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission SQLConfigureEndpointPermissionSecondary { Ensure = 'Present' NodeName = $Node.NodeName diff --git a/Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 b/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 similarity index 78% rename from Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 rename to Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 index 2af15d227..56288f775 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 +++ b/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 @@ -43,11 +43,11 @@ Configuration Example $SqlServiceNode2Credential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node $AllNodes.Where{$_.Role -eq 'PrimaryReplica' }.NodeName { - xSQLServerEndpointPermission RemoveSQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionPrimary { Ensure = 'Absent' NodeName = $Node.NodeName @@ -58,10 +58,10 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential - DependsOn = '[xSQLServerEndpointPermission]SQLConfigureEndpointPermissionPrimary' + DependsOn = '[SqlServerEndpointPermission]SQLConfigureEndpointPermissionPrimary' } - xSQLServerEndpointPermission RemoveSQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionSecondary { Ensure = 'Absent' NodeName = $Node.NodeName @@ -72,13 +72,13 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential - DependsOn = '[xSQLServerEndpointPermission]SQLConfigureEndpointPermissionSecondary' + DependsOn = '[SqlServerEndpointPermission]SQLConfigureEndpointPermissionSecondary' } } Node $AllNodes.Where{ $_.Role -eq 'SecondaryReplica' }.NodeName { - xSQLServerEndpointPermission RemoveSQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionPrimary { Ensure = 'Absent' NodeName = $Node.NodeName @@ -89,10 +89,10 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential - DependsOn = '[xSQLServerEndpointPermission]SQLConfigureEndpointPermissionPrimary' + DependsOn = '[SqlServerEndpointPermission]SQLConfigureEndpointPermissionPrimary' } - xSQLServerEndpointPermission RemoveSQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionSecondary { Ensure = 'Absent' NodeName = $Node.NodeName @@ -103,7 +103,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential - DependsOn = '[xSQLServerEndpointPermission]SQLConfigureEndpointPermissionSecondary' + DependsOn = '[SqlServerEndpointPermission]SQLConfigureEndpointPermissionSecondary' } } } diff --git a/Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1 b/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 similarity index 91% rename from Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1 rename to Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 index 11baa12e2..4a7e154a1 100644 --- a/Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1 +++ b/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 @@ -21,12 +21,12 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { # Start the DefaultMirrorEndpoint in the default instance - xSQLServerEndpointState StartEndpoint1 + SqlServerEndpointState StartEndpoint1 { NodeName = 'SQLNODE01.company.local' InstanceName = 'MSSQLSERVER' @@ -37,7 +37,7 @@ Configuration Example } # Start the HADR in the default instance - xSQLServerEndpointState StartEndpoint2 + SqlServerEndpointState StartEndpoint2 { NodeName = 'SQLNODE01.company.local' InstanceName = 'MSSQLSERVER' @@ -48,7 +48,7 @@ Configuration Example } # Start the DefaultMirrorEndpoint in the named instance INSTANCE1 - xSQLServerEndpointState StartEndpoint3 + SqlServerEndpointState StartEndpoint3 { NodeName = 'SQLNODE01.company.local' InstanceName = 'INSTANCE1' diff --git a/Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1 b/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 similarity index 88% rename from Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1 rename to Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 index 69422e93b..0fd1dac00 100644 --- a/Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1 +++ b/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerEndpointState StopEndpoint + SqlServerEndpointState StopEndpoint { NodeName = 'SQLNODE01.company.local' InstanceName = 'MSSQLSERVER' diff --git a/Examples/Resources/xSQLServerLogin/1-AddLogin.ps1 b/Examples/Resources/SqlServerLogin/1-AddLogin.ps1 similarity index 90% rename from Examples/Resources/xSQLServerLogin/1-AddLogin.ps1 rename to Examples/Resources/SqlServerLogin/1-AddLogin.ps1 index 063a495a1..e44d1acfe 100644 --- a/Examples/Resources/xSQLServerLogin/1-AddLogin.ps1 +++ b/Examples/Resources/SqlServerLogin/1-AddLogin.ps1 @@ -21,10 +21,10 @@ Configuration Example $LoginCredential ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerLogin Add_WindowsUser + SqlServerLogin Add_WindowsUser { Ensure = 'Present' Name = 'CONTOSO\WindowsUser' @@ -34,7 +34,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerLogin Add_DisabledWindowsUser + SqlServerLogin Add_DisabledWindowsUser { Ensure = 'Present' Name = 'CONTOSO\WindowsUser2' @@ -45,7 +45,7 @@ Configuration Example Disabled = $true } - xSQLServerLogin Add_WindowsGroup + SqlServerLogin Add_WindowsGroup { Ensure = 'Present' Name = 'CONTOSO\WindowsGroup' @@ -55,7 +55,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerLogin Add_SqlLogin + SqlServerLogin Add_SqlLogin { Ensure = 'Present' Name = 'SqlLogin' diff --git a/Examples/Resources/xSQLServerLogin/2-RemoveLogin.ps1 b/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 similarity index 85% rename from Examples/Resources/xSQLServerLogin/2-RemoveLogin.ps1 rename to Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 index 98a50222d..f09a9050f 100644 --- a/Examples/Resources/xSQLServerLogin/2-RemoveLogin.ps1 +++ b/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 @@ -11,10 +11,10 @@ This example shows how to remove the SQL Login 'SqlLogin'. Configuration Example { - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerLogin Remove_WindowsUser + SqlServerLogin Remove_WindowsUser { Ensure = 'Absent' Name = 'CONTOSO\WindowsUser' @@ -23,7 +23,7 @@ Configuration Example SQLInstanceName = 'DSC' } - xSQLServerLogin Remove_WindowsGroup + SqlServerLogin Remove_WindowsGroup { Ensure = 'Absent' Name = 'CONTOSO\WindowsGroup' @@ -32,7 +32,7 @@ Configuration Example SQLInstanceName = 'DSC' } - xSQLServerLogin Remove_SqlLogin + SqlServerLogin Remove_SqlLogin { Ensure = 'Absent' Name = 'SqlLogin' diff --git a/Examples/Resources/xSQLServerMaxDop/1-SetMaxDopToOne.ps1 b/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 similarity index 87% rename from Examples/Resources/xSQLServerMaxDop/1-SetMaxDopToOne.ps1 rename to Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 index 53638884e..4e513683c 100644 --- a/Examples/Resources/xSQLServerMaxDop/1-SetMaxDopToOne.ps1 +++ b/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerMaxDop Set_SQLServerMaxDop_ToOne + SqlServerMaxDop Set_SQLServerMaxDop_ToOne { Ensure = 'Present' DynamicAlloc = $false diff --git a/Examples/Resources/xSQLServerMaxDop/2-SetMaxDopToAuto.ps1 b/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 similarity index 90% rename from Examples/Resources/xSQLServerMaxDop/2-SetMaxDopToAuto.ps1 rename to Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 index 4cfd75451..bbdd8f4d3 100644 --- a/Examples/Resources/xSQLServerMaxDop/2-SetMaxDopToAuto.ps1 +++ b/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 @@ -18,11 +18,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerMaxDop Set_SQLServerMaxDop_ToAuto + SqlServerMaxDop Set_SQLServerMaxDop_ToAuto { Ensure = 'Present' DynamicAlloc = $true diff --git a/Examples/Resources/xSQLServerMaxDop/3-SetMaxDopToDefault.ps1 b/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 similarity index 85% rename from Examples/Resources/xSQLServerMaxDop/3-SetMaxDopToDefault.ps1 rename to Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 index 917ada584..3b1a9459b 100644 --- a/Examples/Resources/xSQLServerMaxDop/3-SetMaxDopToDefault.ps1 +++ b/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerMaxDop Set_SQLServerMaxDop_ToDefault + SqlServerMaxDop Set_SQLServerMaxDop_ToDefault { Ensure = 'Absent' SQLServer = 'SQLServer' diff --git a/Examples/Resources/xSQLServerMemory/1-SetMaxMemoryTo12GB.ps1 b/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 similarity index 87% rename from Examples/Resources/xSQLServerMemory/1-SetMaxMemoryTo12GB.ps1 rename to Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 index fc8a2a789..30aa1f419 100644 --- a/Examples/Resources/xSQLServerMemory/1-SetMaxMemoryTo12GB.ps1 +++ b/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerMemory Set_SQLServerMaxMemory_To12GB + SqlServerMemory Set_SQLServerMaxMemory_To12GB { Ensure = 'Present' DynamicAlloc = $false diff --git a/Examples/Resources/xSQLServerMemory/2-SetMaxMemoryToAuto.ps1 b/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 similarity index 90% rename from Examples/Resources/xSQLServerMemory/2-SetMaxMemoryToAuto.ps1 rename to Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 index a13999410..4dcdb2d64 100644 --- a/Examples/Resources/xSQLServerMemory/2-SetMaxMemoryToAuto.ps1 +++ b/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 @@ -18,11 +18,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerMemory Set_SQLServerMaxMemory_ToAuto + SqlServerMemory Set_SQLServerMaxMemory_ToAuto { Ensure = 'Present' DynamicAlloc = $true diff --git a/Examples/Resources/xSQLServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 b/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 similarity index 86% rename from Examples/Resources/xSQLServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 rename to Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 index 7c245ec29..0333515e5 100644 --- a/Examples/Resources/xSQLServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 +++ b/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerMemory Set_SQLServerMinAndMaxMemory_ToAuto + SqlServerMemory Set_SQLServerMinAndMaxMemory_ToAuto { Ensure = 'Present' DynamicAlloc = $true diff --git a/Examples/Resources/xSQLServerMemory/4-SetMaxMemoryToDefault.ps1 b/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 similarity index 84% rename from Examples/Resources/xSQLServerMemory/4-SetMaxMemoryToDefault.ps1 rename to Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 index 975249117..c7d036493 100644 --- a/Examples/Resources/xSQLServerMemory/4-SetMaxMemoryToDefault.ps1 +++ b/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerMemory Set_SQLServerMaxMemory_ToDefault + SqlServerMemory Set_SQLServerMaxMemory_ToDefault { Ensure = 'Absent' SQLServer = 'SQLServer' diff --git a/Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1 b/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 similarity index 86% rename from Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1 rename to Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 index 20062dd69..ee91453e0 100644 --- a/Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1 +++ b/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerNetwork 'ChangeTcpIpOnDefaultInstance' + SqlServerNetwork 'ChangeTcpIpOnDefaultInstance' { InstanceName = 'MSSQLSERVER' ProtocolName = 'Tcp' diff --git a/Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 b/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 similarity index 86% rename from Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 rename to Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 index 1ba825cf5..ac0f5ddee 100644 --- a/Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 +++ b/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 @@ -13,11 +13,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerNetwork 'ChangeTcpIpOnDefaultInstance' + SqlServerNetwork 'ChangeTcpIpOnDefaultInstance' { InstanceName = 'MSSQLSERVER' ProtocolName = 'Tcp' diff --git a/Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1 b/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 similarity index 87% rename from Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1 rename to Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 index 92ceac630..10fee8649 100644 --- a/Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1 +++ b/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 @@ -13,12 +13,12 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDSC node localhost { # Add permission - xSQLServerPermission 'SQLConfigureServerPermission-SYSTEM' + SqlServerPermission 'SQLConfigureServerPermission-SYSTEM' { Ensure = 'Present' NodeName = 'SQLNODE01.company.local' @@ -29,7 +29,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerPermission 'SQLConfigureServerPermission-ClusSvc' + SqlServerPermission 'SQLConfigureServerPermission-ClusSvc' { Ensure = 'Present' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1 b/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 similarity index 88% rename from Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1 rename to Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 index 8355c62b6..e53b20b9c 100644 --- a/Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1 +++ b/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 @@ -13,12 +13,12 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDSC node localhost { # Add permission - xSQLServerPermission SQLConfigureServerPermission + SqlServerPermission SQLConfigureServerPermission { Ensure = 'Absent' NodeName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1 b/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 similarity index 88% rename from Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1 rename to Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 index c1d5bf716..25d71253b 100644 --- a/Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1 +++ b/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerReplication distributor + SqlServerReplication distributor { Ensure = 'Present' InstanceName = 'MSSQLSERVER' diff --git a/Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1 b/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 similarity index 89% rename from Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1 rename to Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 index 3d29ae26b..30737e9a8 100644 --- a/Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1 +++ b/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerReplication publisher + SqlServerReplication publisher { Ensure = 'Present' InstanceName = 'PUBLISHER' diff --git a/Examples/Resources/xSQLServerRole/1-AddServerRole.ps1 b/Examples/Resources/SqlServerRole/1-AddServerRole.ps1 similarity index 84% rename from Examples/Resources/xSQLServerRole/1-AddServerRole.ps1 rename to Examples/Resources/SqlServerRole/1-AddServerRole.ps1 index c14a0cb10..434fa4611 100644 --- a/Examples/Resources/xSQLServerRole/1-AddServerRole.ps1 +++ b/Examples/Resources/SqlServerRole/1-AddServerRole.ps1 @@ -12,10 +12,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerRole Add_ServerRole_AdminSqlforBI + SqlServerRole Add_ServerRole_AdminSqlforBI { Ensure = 'Present' ServerRoleName = "AdminSqlforBI" diff --git a/Examples/Resources/xSQLServerRole/2-RemoveServerRole.ps1 b/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 similarity index 86% rename from Examples/Resources/xSQLServerRole/2-RemoveServerRole.ps1 rename to Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 index 3abaf2e12..6f54ea5de 100644 --- a/Examples/Resources/xSQLServerRole/2-RemoveServerRole.ps1 +++ b/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 @@ -12,10 +12,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerRole Remove_ServerRole + SqlServerRole Remove_ServerRole { Ensure = 'Absent' ServerRoleName = "serverRoleToDelete" diff --git a/Examples/Resources/xSQLServerRole/3-AddMembersToServerRole.ps1 b/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 similarity index 87% rename from Examples/Resources/xSQLServerRole/3-AddMembersToServerRole.ps1 rename to Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 index 4fd419159..6610afc01 100644 --- a/Examples/Resources/xSQLServerRole/3-AddMembersToServerRole.ps1 +++ b/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 @@ -13,10 +13,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerRole Add_ServerRole_AdminSqlforBI + SqlServerRole Add_ServerRole_AdminSqlforBI { Ensure = 'Present' ServerRoleName = 'AdminSqlforBI' diff --git a/Examples/Resources/xSQLServerRole/4-MembersToIncludeInServerRole.ps1 b/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 similarity index 87% rename from Examples/Resources/xSQLServerRole/4-MembersToIncludeInServerRole.ps1 rename to Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 index 444a60071..ac85fed85 100644 --- a/Examples/Resources/xSQLServerRole/4-MembersToIncludeInServerRole.ps1 +++ b/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 @@ -13,10 +13,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerRole Add_ServerRole_AdminSqlforBI + SqlServerRole Add_ServerRole_AdminSqlforBI { Ensure = 'Present' ServerRoleName = 'AdminSqlforBI' diff --git a/Examples/Resources/xSQLServerRole/5-MembersToExcludeInServerRole.ps1 b/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 similarity index 87% rename from Examples/Resources/xSQLServerRole/5-MembersToExcludeInServerRole.ps1 rename to Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 index 5a2f520d0..cf742f88a 100644 --- a/Examples/Resources/xSQLServerRole/5-MembersToExcludeInServerRole.ps1 +++ b/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 @@ -13,10 +13,10 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerRole Drop_ServerRole_AdminSqlforBI + SqlServerRole Drop_ServerRole_AdminSqlforBI { Ensure = 'Present' ServerRoleName = 'AdminSqlforBI' diff --git a/Examples/Resources/xSQLServerServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 b/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 similarity index 83% rename from Examples/Resources/xSQLServerServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 rename to Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 index 42b91b13c..5d92cced8 100644 --- a/Examples/Resources/xSQLServerServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 +++ b/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 @@ -12,10 +12,10 @@ Configuration Example $ServiceAccountCredential ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node localhost { - xSQLServerServiceAccount SetServiceAcccount_User + SqlServiceAccount SetServiceAcccount_User { SQLServer = 'TestServer' SQLInstanceName = 'MSSQLSERVER' diff --git a/Examples/Resources/xSQLServerServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 b/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 similarity index 87% rename from Examples/Resources/xSQLServerServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 rename to Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 index d0ff7a4c3..6a67ed0a7 100644 --- a/Examples/Resources/xSQLServerServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 +++ b/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 @@ -15,10 +15,10 @@ Configuration Example $ServiceAcccountCredential ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc Node localhost { - xSQLServerServiceAccount SetServiceAcccount_User + SqlServiceAccount SetServiceAcccount_User { SQLServer = 'TestServer' SQLInstanceName = 'DSC' diff --git a/Examples/Resources/xSQLServerSetup/1-InstallDefaultInstanceSingleServer.ps1 b/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 similarity index 97% rename from Examples/Resources/xSQLServerSetup/1-InstallDefaultInstanceSingleServer.ps1 rename to Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 index 8988308c3..9eafc2c7c 100644 --- a/Examples/Resources/xSQLServerSetup/1-InstallDefaultInstanceSingleServer.ps1 +++ b/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 @@ -35,7 +35,7 @@ Configuration Example $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { @@ -55,7 +55,7 @@ Configuration Example #endregion Install prerequisites for SQL Server #region Install SQL Server - xSQLServerSetup 'InstallDefaultInstance' + SqlSetup 'InstallDefaultInstance' { InstanceName = 'MSSQLSERVER' Features = 'SQLENGINE,AS' diff --git a/Examples/Resources/xSQLServerSetup/2-InstallNamedInstanceSingleServer.ps1 b/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 similarity index 97% rename from Examples/Resources/xSQLServerSetup/2-InstallNamedInstanceSingleServer.ps1 rename to Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 index 254763e86..a754fffe6 100644 --- a/Examples/Resources/xSQLServerSetup/2-InstallNamedInstanceSingleServer.ps1 +++ b/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 @@ -35,7 +35,7 @@ Configuration Example $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDSC node localhost { @@ -55,7 +55,7 @@ Configuration Example #endregion Install prerequisites for SQL Server #region Install SQL Server - xSQLServerSetup 'InstallNamedInstance-INST2016' + SqlSetup 'InstallNamedInstance-INST2016' { InstanceName = 'INST2016' Features = 'SQLENGINE,AS' diff --git a/Examples/Resources/xSQLServerSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 b/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 similarity index 97% rename from Examples/Resources/xSQLServerSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 rename to Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 index 3b01a2588..bdd01187b 100644 --- a/Examples/Resources/xSQLServerSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 +++ b/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 @@ -39,7 +39,7 @@ Configuration Example $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { @@ -59,7 +59,7 @@ Configuration Example #endregion Install prerequisites for SQL Server #region Install SQL Server - xSQLServerSetup 'InstallNamedInstance-INST2016' + SqlSetup 'InstallNamedInstance-INST2016' { InstanceName = 'INST2016' Features = 'SQLENGINE,AS' diff --git a/Examples/Resources/xSQLServerSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 b/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 similarity index 98% rename from Examples/Resources/xSQLServerSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 rename to Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 index 786bb5d53..8ddd54537 100644 --- a/Examples/Resources/xSQLServerSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 +++ b/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 @@ -59,7 +59,7 @@ Configuration Example $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { @@ -79,7 +79,7 @@ Configuration Example #endregion Install prerequisites for SQL Server #region Install SQL Server Failover Cluster - xSQLServerSetup 'InstallNamedInstanceNode1-INST2016' + SqlSetup 'InstallNamedInstanceNode1-INST2016' { Action = 'InstallFailoverCluster' ForceReboot = $false diff --git a/Examples/Resources/xSQLServerSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 b/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 similarity index 97% rename from Examples/Resources/xSQLServerSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 rename to Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 index 17f9b250e..3bf76ce91 100644 --- a/Examples/Resources/xSQLServerSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 +++ b/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 @@ -55,7 +55,7 @@ Configuration Example $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { @@ -75,7 +75,7 @@ Configuration Example #endregion Install prerequisites for SQL Server #region Install SQL Server Failover Cluster - xSQLServerSetup 'InstallNamedInstanceNode2-INST2016' + SqlSetup 'InstallNamedInstanceNode2-INST2016' { Action = 'AddNode' ForceReboot = $false diff --git a/Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1 b/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 similarity index 83% rename from Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1 rename to Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 index 96c191d9c..d1566a51e 100644 --- a/Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1 +++ b/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xWaitForAvailabilityGroup SQLConfigureAG-WaitAGTest1 + SqlWaitForAG SQLConfigureAG-WaitAGTest1 { Name = 'AGTest1' RetryIntervalSec = 20 diff --git a/Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1 b/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 similarity index 81% rename from Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1 rename to Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 index 93773477f..ef25ba152 100644 --- a/Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1 +++ b/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSQLServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xWaitForAvailabilityGroup SQLConfigureAG-WaitAGTest1 + SqlWaitForAG SQLConfigureAG-WaitAGTest1 { Name = 'AGTest1' RetryIntervalSec = 20 @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xWaitForAvailabilityGroup SQLConfigureAG-WaitAGTest2 + SqlWaitForAG SQLConfigureAG-WaitAGTest2 { Name = 'AGTest2' RetryIntervalSec = 20 diff --git a/Examples/Resources/xSQLServerFirewall/1-CreateInboundFirewallRules.ps1 b/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 similarity index 84% rename from Examples/Resources/xSQLServerFirewall/1-CreateInboundFirewallRules.ps1 rename to Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 index 8ce7ccfa5..3333b28c2 100644 --- a/Examples/Resources/xSQLServerFirewall/1-CreateInboundFirewallRules.ps1 +++ b/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerFirewall Create_FirewallRules_For_SQL2012 + SqlWindowsFirewall Create_FirewallRules_For_SQL2012 { Ensure = 'Present' Features = 'SQLENGINE,AS,RS,IS' @@ -26,7 +26,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerFirewall Create_FirewallRules_For_SQL2016 + SqlWindowsFirewall Create_FirewallRules_For_SQL2016 { Ensure = 'Present' Features = 'SQLENGINE' diff --git a/Examples/Resources/xSQLServerFirewall/2-RemoveInboundFirewallRules.ps1 b/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 similarity index 84% rename from Examples/Resources/xSQLServerFirewall/2-RemoveInboundFirewallRules.ps1 rename to Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 index 583befca6..3ba7fac4c 100644 --- a/Examples/Resources/xSQLServerFirewall/2-RemoveInboundFirewallRules.ps1 +++ b/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 @@ -12,11 +12,11 @@ Configuration Example $SysAdminAccount ) - Import-DscResource -ModuleName xSqlServer + Import-DscResource -ModuleName SqlServerDsc node localhost { - xSQLServerFirewall Remove_FirewallRules_For_SQL2012 + SqlWindowsFirewall Remove_FirewallRules_For_SQL2012 { Ensure = 'Absent' Features = 'SQLENGINE,AS,RS,IS' @@ -26,7 +26,7 @@ Configuration Example PsDscRunAsCredential = $SysAdminAccount } - xSQLServerFirewall Remove_FirewallRules_For_SQL2016 + SqlWindowsFirewall Remove_FirewallRules_For_SQL2016 { Ensure = 'Absent' Features = 'SQLENGINE' diff --git a/Examples/SQL-ClusterDB.ps1 b/Examples/SQL-ClusterDB.ps1 index 8b31fc540..451b3015a 100644 --- a/Examples/SQL-ClusterDB.ps1 +++ b/Examples/SQL-ClusterDB.ps1 @@ -5,7 +5,7 @@ param () Configuration SQL { - Import-DscResource -Module xSQLServer + Import-DscResource -Module SqlServerDSC Import-DscResource -Module xFailoverCluster Node $AllNodes.NodeName @@ -104,7 +104,7 @@ Configuration SQL SQLSvcAccount = $Node.SQLServiceAccount } - xSqlServerFirewall "FirewallMSSQLSERVER" + SqlWindowsFirewall "FirewallMSSQLSERVER" { DependsOn = "[xSQLServerFailoverClusterSetup]PrepareMSSQLSERVER" SourcePath = $Node.SourcePath @@ -126,8 +126,8 @@ Configuration SQL RetryIntervalSec = 5 RetryCount = 720 } - - xSQLServerFailoverClusterSetup "CompleteMSSQLSERVER" + + SqlServerDSCFailoverClusterSetup "CompleteMSSQLSERVER" { DependsOn = @( "[WaitForAll]Cluster", @@ -200,4 +200,3 @@ foreach($Node in $ConfigurationData.AllNodes) SQL -ConfigurationData $ConfigurationData Set-DscLocalConfigurationManager -Path .\SQL -Verbose Start-DscConfiguration -Path .\SQL -Verbose -Wait -Force - diff --git a/Examples/SQL-Standalone.ps1 b/Examples/SQL-Standalone.ps1 index 9f52781f8..3cab9d36b 100644 --- a/Examples/SQL-Standalone.ps1 +++ b/Examples/SQL-Standalone.ps1 @@ -5,7 +5,7 @@ param () Configuration SQLSA { - Import-DscResource -Module xSQLServer + Import-DscResource -Module SqlServerDSC # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique @@ -20,7 +20,7 @@ Configuration SQLSA $Role.Contains("Database") -or $Role.Contains("Datawarehouse") -or $Role.Contains("Reporting") -or - $Role.Contains("Analysis") -or + $Role.Contains("Analysis") -or $Role.Contains("Integration") ) { @@ -28,7 +28,7 @@ Configuration SQLSA Set-Variable -Name ($Role.Replace(" ","").Replace(".","").Replace("Server","Instance")) -Value $Instance } } - } + } Node $AllNodes.NodeName { @@ -79,7 +79,7 @@ Configuration SQLSA ASConfigDir = "O:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Config" } - xSqlServerFirewall ($Node.NodeName + $SQLInstanceName) + SqlWindowsFirewall ($Node.NodeName + $SQLInstanceName) { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName + $SQLInstanceName) SourcePath = $Node.SourcePath @@ -146,4 +146,3 @@ foreach($Node in $ConfigurationData.AllNodes) SQLSA -ConfigurationData $ConfigurationData Set-DscLocalConfigurationManager -Path .\SQLSA -Verbose Start-DscConfiguration -Path .\SQLSA -Verbose -Wait -Force - diff --git a/Examples/SQLPush_SingleServer.ps1 b/Examples/SQLPush_SingleServer.ps1 index 209598d4f..e357c5cad 100644 --- a/Examples/SQLPush_SingleServer.ps1 +++ b/Examples/SQLPush_SingleServer.ps1 @@ -33,7 +33,7 @@ foreach ($computer in $computers) Configuration SQLSA { Import-DscResource –Module PSDesiredStateConfiguration - Import-DscResource -Module xSQLServer + Import-DscResource -Module SqlServerDSC Node $AllNodes.NodeName { @@ -71,7 +71,7 @@ Configuration SQLSA SQLBackupDir = "G:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" } - xSqlServerFirewall ($Node.NodeName) + SqlWindowsFirewall ($Node.NodeName) { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) SourcePath = $Node.SourcePath @@ -79,7 +79,7 @@ Configuration SQLSA Features = $Node.Features } - xSQLServerMemory ($Node.Nodename) + SqlServerMemory ($Node.Nodename) { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) Ensure = "Present" @@ -87,13 +87,13 @@ Configuration SQLSA MinMemory = "256" MaxMemory ="1024" } - xSQLServerMaxDop($Node.Nodename) + SqlServerMaxDop($Node.Nodename) { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) Ensure = "Present" DynamicAlloc = $true } - xSQLServerLogin($Node.Nodename+"TestUser2") + SqlServerLogin($Node.Nodename+"TestUser2") { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) Ensure = "Present" @@ -101,7 +101,7 @@ Configuration SQLSA LoginCredential = $Node.InstallerServiceAccount LoginType = "SQLLogin" } - xSQLServerLogin($Node.Nodename+"TestUser1") + SqlServerLogin($Node.Nodename+"TestUser1") { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) Ensure = "Present" @@ -109,7 +109,7 @@ Configuration SQLSA LoginCredential = $Node.InstallerServiceAccount LoginType = "SQLLogin" } - xSQLServerDatabaseRole($Node.Nodename) + SqlDatabaseRole($Node.Nodename) { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) Ensure = "Present" @@ -123,18 +123,18 @@ Configuration SQLSA RecoveryModel = "Full" SqlServerInstance ="$($Node.NodeName)\$($Node.SQLInstanceName)" } - xSQLServerDatabaseOwner($Node.Nodename) + SqlDatabaseOwner($Node.Nodename) { Database = "TestDB" Name = "TestUser2" } - xSQLServerDatabasePermission($Node.Nodename) + SqlDatabasePermission($Node.Nodename) { Database = "Model" Name = "TestUser1" Permissions ="SELECT","DELETE" } - xSQLServerDatabase($Node.Nodename) + SqlDatabase($Node.Nodename) { Database = "Test3" Ensure = "Present" @@ -165,7 +165,7 @@ ForEach ($computer in $computers) { } $Destination = "\\"+$computer+"\\c$\Program Files\WindowsPowerShell\Modules" - Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\xSQLServer' -Destination $Destination -Recurse -Force + Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\SqlServerDSC' -Destination $Destination -Recurse -Force } SQLSA -ConfigurationData $ConfigurationData -OutputPath $OutputPath @@ -182,4 +182,3 @@ foreach($Computer in $Computers) { test-dscconfiguration -ComputerName $Computer } - diff --git a/README.md b/README.md index 499516b9c..656a51e53 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# xSQLServer +# SqlServerDsc -The **xSQLServer** module contains DSC resources for deployment and configuration -of SQL Server. +The **SqlServerDsc** module contains DSC resources +for deployment and configuration of SQL Server. This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) @@ -12,89 +12,96 @@ questions or comments. ### master -[![Build status](https://ci.appveyor.com/api/projects/status/mxn453y284eab8li/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xsqlserver/branch/master) -[![codecov](https://codecov.io/gh/PowerShell/xSQLServer/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/xSQLServer/branch/master) +[![Build status](https://ci.appveyor.com/api/projects/status/mxn453y284eab8li/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/SqlServerDsc/branch/master) +[![codecov](https://codecov.io/gh/PowerShell/SqlServerDsc/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/SqlServerDsc/branch/master) -This is the branch containing the latest release - no contributions should be made -directly to this branch. +This is the branch containing the latest release - +no contributions should be made directly to this branch. ### dev -[![Build status](https://ci.appveyor.com/api/projects/status/mxn453y284eab8li/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/xsqlserver/branch/dev) -[![codecov](https://codecov.io/gh/PowerShell/xSQLServer/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/xSQLServer/branch/dev) +[![Build status](https://ci.appveyor.com/api/projects/status/mxn453y284eab8li/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/SqlServerDsc/branch/dev) +[![codecov](https://codecov.io/gh/PowerShell/SqlServerDsc/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/SqlServerDsc/branch/dev) -This is the development branch to which contributions should be proposed by contributors -as pull requests. This development branch will periodically be merged to the master -branch, and be released to [PowerShell Gallery](https://www.powershellgallery.com/). +This is the development branch +to which contributions should be proposed by contributors as pull requests. +This development branch will periodically be merged to the master branch, +and be released to [PowerShell Gallery](https://www.powershellgallery.com/). ## Contributing -Regardless of the way you want to contribute we are tremendously happy to have you -here. - -There are several ways you can contribute. You can submit an issue to report a bug. -You can submit an issue to request an improvement. You can take part in discussions -for issues. You can review pull requests and comment on other contributors changes. -You can also improve the resources and tests, or even create new resources, by -sending in pull requests yourself. - -* If you want to submit an issue or take part in discussions, please browse the - list of [issues](https://github.com/PowerShell/xSQLServer/issues). Please check - out [Contributing to the DSC Resource Kit](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md) +Regardless of the way you want to contribute +we are tremendously happy to have you here. + +There are several ways you can contribute. +You can submit an issue to report a bug. +You can submit an issue to request an improvement. +You can take part in discussions for issues. +You can review pull requests and comment on other contributors changes. +You can also improve the resources and tests, +or even create new resources, +by sending in pull requests yourself. + +* If you want to submit an issue or take part in discussions, + please browse the list of [issues](https://github.com/PowerShell/SqlServerDsc/issues). + Please check out [Contributing to the DSC Resource Kit](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md) on how to work with issues. -* If you want to review pull requests, please first check out the - [Review Pull Request guidelines](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md#reviewing-pull-requests), - and the browse the list of [pull requests](https://github.com/PowerShell/xSQLServer/pulls) +* If you want to review pull requests, + please first check out the [Review Pull Request guidelines](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md#reviewing-pull-requests), + and the browse the list of [pull requests](https://github.com/PowerShell/SqlServerDsc/pulls) and look for those pull requests with label 'needs review'. -* If you want to improve the resources or tests, or create a new resource, then - please check out the following guidelines. +* If you want to improve the resources or tests, + or create a new resource, + then please check out the following guidelines. * The [Contributing to the DSC Resource Kit](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md) guidelines. - * The specific [Contributing to xSQLServer](https://github.com/PowerShell/xSQLServer/blob/dev/CONTRIBUTING.md) + * The specific [Contributing to SqlServerDsc](https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md) guidelines. * The common [Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md). * The common [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md) guidelines. * The common [Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). - * If you are new to GitHub (and git), then please check out - [Getting Started with GitHub](https://github.com/PowerShell/DscResources/blob/master/GettingStartedWithGitHub.md). + * If you are new to GitHub (and git), + then please check out [Getting Started with GitHub](https://github.com/PowerShell/DscResources/blob/master/GettingStartedWithGitHub.md). * If you are new to Pester and writing test, then please check out [Getting started with Pester](https://github.com/PowerShell/DscResources/blob/master/GettingStartedWithPester.md). -If you need any help along the way, don't be afraid to ask. We are here for each -other. +If you need any help along the way, +don't be afraid to ask. +We are here for each other. ## Installation -To manually install the module, download the source code and unzip the contents -of the '\Modules\xSQLServer' directory to the +To manually install the module, +download the source code and unzip the contents +of the '\Modules\SqlServerDsc' directory to the '$env:ProgramFiles\WindowsPowerShell\Modules' folder. -To install from the PowerShell gallery using PowerShellGet (in PowerShell 5.0) run -the following command: +To install from the PowerShell gallery using PowerShellGet (in PowerShell 5.0) +run the following command: ```powershell -Find-Module -Name xSQLServer -Repository PSGallery | Install-Module +Find-Module -Name SqlServerDsc -Repository PSGallery | Install-Module ``` To confirm installation, run the below command and ensure you see the SQL Server DSC resources available: ```powershell -Get-DscResource -Module xSQLServer +Get-DscResource -Module SqlServerDsc ``` ## Requirements -The minimum Windows Management Framework (PowerShell) version required is 5.0 or -higher, which ships with Windows 10 or Windows Server 2016, but can also be -installed on Windows 7 SP1, Windows 8.1, Windows Server 2008 R2 SP1, -Windows Server 2012 and Windows Server 2012 R2. +The minimum Windows Management Framework (PowerShell) version required is 5.0 +or higher, which ships with Windows 10 or Windows Server 2016, +but can also be installed on Windows 7 SP1, Windows 8.1, +Windows Server 2008 R2 SP1, Windows Server 2012 and Windows Server 2012 R2. ## Examples -You can review the [Examples](/Examples) directory in the xSQLServer module for -some general use scenarios for all of the resources that are in the module. +You can review the [Examples](/Examples) directory in the SqlServerDsc module +for some general use scenarios for all of the resources that are in the module. ## Change log @@ -102,62 +109,62 @@ A full list of changes in each version can be found in the [change log](CHANGELO ## Resources -* [**xSQLServerAlias**](#xsqlserveralias) resource to manage SQL Server client Aliases. -* [**xSQLServerAlwaysOnAvailabilityGroup**](#xsqlserveralwaysonavailabilitygroup) +* [**SqlAG**](#sqlag) resource to ensure an availability group is present or absent. -* [**xSQLServerAlwayOnAvailabilityGroupDatabaseMembership**](#xsqlserveralwaysonavailabilitygroupdatabasemembership) +* [**SqlAGDatabase**](#sqlagdatabase) to manage the database membership in Availability Groups. -* [**xSQLServerAlwaysOnAvailabilityGroupReplica**](#xsqlserveralwaysonavailabilitygroupreplica) +* [**SqlAGListener**](#sqlaglistener) + Create or remove an availability group listener. +* [**SqlAGReplica**](#sqlagreplica) resource to ensure an availability group replica is present or absent. -* [**xSQLServerAlwaysOnService**](#xsqlserveralwaysonservice) resource to enable +* [**SqlAlias**](#sqlalias) resource to manage SQL Server client Aliases. +* [**SqlAlwaysOnService**](#sqlalwaysonservice) resource to enable always on on a SQL Server. -* [**xSQLServerAvailabilityGroupListener**](#xsqlserveravailabilitygrouplistener) - Create or remove an availability group listener. -* [**xSQLServerConfiguration**](#xsqlserverconfiguration) resource to manage - [SQL Server Configuration Options](https://msdn.microsoft.com/en-us/library/ms189631.aspx). -* [**xSQLServerDatabase**](#xsqlserverdatabase) resource to manage ensure database +* [**SqlDatabase**](#sqldatabase) resource to manage ensure database is present or absent. -* [**xSQLServerDatabaseDefaultLocation**](#xsqlserverdatabasedefaultlocation) resource +* [**SqlDatabaseDefaultLocation**](#sqldatabasedefaultlocation) resource to manage default locations for Data, Logs, and Backups for SQL Server -* [**xSQLServerDatabaseOwner**](#xsqlserverdatabaseowner) resource to manage SQL +* [**SqlDatabaseOwner**](#sqldatabaseowner) resource to manage SQL database owners. -* [**xSQLServerDatabasePermission**](#xsqlserverdatabasepermission) resource to +* [**SqlDatabasePermission**](#sqldatabasepermission) resource to manage SQL database permissions. -* [**xSQLServerDatabaseRecoveryModel**](#xsqlserverdatabaserecoverymodel) resource +* [**SqlDatabaseRecoveryModel**](#sqldatabaserecoverymodel) resource to manage database recovery model. -* [**xSQLServerDatabaseRole**](#xsqlserverdatabaserole) resource to manage SQL +* [**SqlDatabaseRole**](#sqldatabaserole) resource to manage SQL database roles. -* [**xSQLServerEndpoint**](#xsqlserverendpoint) resource to ensure database endpoint +* [**SqlRS**](#sqlrs) configures SQL Server Reporting + Services to use a database engine in another instance. +* [**SqlRSSecureConnectionLevel**](#sqlrssecureconnectionlevel) sets + the secure connection level for SQL Server Reporting Services. +* [**SqlScript**](#sqlscript) resource to extend DSC Get/Set/Test + functionality to T-SQL. +* [**SqlServerConfiguration**](#sqlserverconfiguration) resource to manage + [SQL Server Configuration Options](https://msdn.microsoft.com/en-us/library/ms189631.aspx). +* [**SqlServerEndpoint**](#sqlserverendpoint) resource to ensure database endpoint is present or absent. -* [**xSQLServerEndpointPermission**](#xsqlserverendpointpermission) Grant or revoke +* [**SqlServerEndpointPermission**](#sqlserverendpointpermission) Grant or revoke permission on the endpoint. -* [**xSQLServerEndpointState**](#xsqlserverendpointstate) Change state of the endpoint. -* [**xSQLServerFirewall**](#xsqlserverfirewall) configures firewall settings to - allow remote access to a SQL Server instance. -* [**xSQLServerLogin**](#xsqlserverlogin) resource to manage SQL logins. -* [**xSQLServerMaxDop**](#xsqlservermaxdop) resource to manage MaxDegree of Parallelism +* [**SqlServerEndpointState**](#sqlserverendpointstate) Change state of the endpoint. +* [**SqlServerLogin**](#sqlserverlogin) resource to manage SQL logins. +* [**SqlServerMaxDop**](#sqlservermaxdop) resource to manage MaxDegree of Parallelism for SQL Server. -* [**xSQLServerMemory**](#xsqlservermemory) resource to manage Memory for SQL Server. -* [**xSQLServerNetwork**](#xsqlservernetwork) resource to manage SQL Server Network +* [**SqlServerMemory**](#sqlservermemory) resource to manage Memory for SQL Server. +* [**SqlServerNetwork**](#sqlservernetwork) resource to manage SQL Server Network Protocols. -* [**xSQLServerPermission**](#xsqlserverpermission) Grant or revoke permission on +* [**SqlServerPermission**](#sqlserverpermission) Grant or revoke permission on the SQL Server. -* [**xSQLServerRole**](#xsqlserverrole) resource to manage SQL server roles. -* [**xSQLServerReplication**](#xsqlserverreplication) resource to manage SQL Replication +* [**SqlServerReplication**](#sqlserverreplication) resource to manage SQL Replication distribution and publishing. -* [**xSQLServerRSConfig**](#xsqlserverrsconfig) configures SQL Server Reporting - Services to use a database engine in another instance. -* [**xSQLServerRSSecureConnectionLevel**](#xsqlserverrssecureconnectionlevel) sets - the secure connection level for SQL Server Reporting Services. -* [**xSQLServerScript**](#xsqlserverscript) resource to extend DSC Get/Set/Test - functionality to T-SQL. -* [**xSQLServerServiceAccount**](#xsqlserverserviceaccount) Manage the service account +* [**SqlServerRole**](#sqlserverrole) resource to manage SQL server roles. +* [**SqlServiceAccount**](#sqlserviceaccount) Manage the service account for SQL Server services. -* [**xSQLServerSetup**](#xsqlserversetup) installs a standalone SQL Server instance. -* [**xWaitForAvailabilityGroup**](#xwaitforavailabilitygroup) resource to wait until - availability group is created on primary server. +* [**SqlSetup**](#sqlsetup) installs a standalone SQL Server instance. +* [**SqlWaitForAG**](#sqlwaitforag) resource to + wait until availability group is created on primary server. +* [**SqlWindowsFirewall**](#sqlwindowsfirewall) configures firewall settings to + allow remote access to a SQL Server instance. -### xSQLServerAlias +### SqlAlias No description. @@ -187,10 +194,10 @@ No description. #### Examples -* [Add an SQL Server alias](/Examples/Resources/xSQLServerAlias/1-AddSQLServerAlias.ps1) -* [Remove an SQL Server alias](/Examples/Resources/xSQLServerAlias/2-RemoveSQLServerAlias.ps1) +* [Add an SQL Server alias](/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1) +* [Remove an SQL Server alias](/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1) -### xSQLServerAlwaysOnAvailabilityGroup +### SqlAG This resource is used to create, remove, and update an Always On Availability Group. It will also manage the Availability Group replica on the specified node. @@ -264,11 +271,11 @@ It will also manage the Availability Group replica on the specified node. #### Examples -* [Add a SQL Server Always On Availability Group](/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/1-CreateAvailabilityGroup.ps1) -* [Add a SQL Server Always On Availability Group and explicitly defines its properties](/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/3-CreateAvailabilityGroupDetailed.ps1) -* [Remove a SQL Server Always On Availability Group](/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroup/2-RemoveAvailabilityGroup.ps1) +* [Add a SQL Server Always On Availability Group](/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1) +* [Add a SQL Server Always On Availability Group and explicitly defines its properties](/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1) +* [Remove a SQL Server Always On Availability Group](/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1) -### xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership +### SqlAGDatabase This resource is used to add and/or remove databases to a specified availability group. @@ -323,7 +330,7 @@ group. * **`[Boolean]` IsActiveNode** _(Read)_: Determines if the current node is actively hosting the SQL Server instance. -### xSQLServerAlwaysOnAvailabilityGroupReplica +### SqlAGReplica This resource is used to create, remove, and update an Always On Availability Group Replica. @@ -391,10 +398,10 @@ Always On Availability Group Replica. #### Examples -* [Add a SQL Server Always On Availability Group Replica](/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/1-CreateAvailabilityGroupReplica.ps1) -* [Remove a SQL Server Always On Availability Group Replica](/Examples/Resources/xSQLServerAlwaysOnAvailabilityGroupReplica/2-RemoveAvailabilityGroupReplica.ps1) +* [Add a SQL Server Always On Availability Group Replica](/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1) +* [Remove a SQL Server Always On Availability Group Replica](/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1) -### xSQLServerAlwaysOnService +### SqlAlwaysOnService Enables or disabled SQL Server Always On high availability and disaster recovery (Always On HADR). @@ -421,10 +428,10 @@ Enables or disabled SQL Server Always On high availability and disaster recovery #### Examples -* [Enable SQL Server Always On](/Examples/Resources/xSQLServerAlwaysOnService/1-EnableAlwaysOn.ps1) -* [Disable SQL Server Always On](/Examples/Resources/xSQLServerAlwaysOnService/1-DisableAlwaysOn.ps1) +* [Enable SQL Server Always On](/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1) +* [Disable SQL Server Always On](/Examples/Resources/SqlAlwaysOnService/1-DisableAlwaysOn.ps1) -### xSQLServerAvailabilityGroupListener +### SqlAGListener No description. @@ -460,17 +467,17 @@ No description. #### Examples * [Adds an Availability Group listener with the same name as the - Availability Group VCO](/Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1) + Availability Group VCO](/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1) * [Adds an Availability Group listener with a different name than the - Availability Group VCO](/Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1) + Availability Group VCO](/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1) * [Removes an Availability Group listener with the same name as the - Availability Group VCO](/Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1) + Availability Group VCO](/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1) * [Removes an Availability Group listener with a different name than the - Availability Group VCO](/Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1) -* [Adds an Availability Group listener using DHCP on the default server subnet](/Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1) -* [Adds an Availability Group listener using DHCP with a specific subnet](/Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1) + Availability Group VCO](/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1) +* [Adds an Availability Group listener using DHCP on the default server subnet](/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1) +* [Adds an Availability Group listener using DHCP with a specific subnet](/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1) -### xSQLServerConfiguration +### SqlServerConfiguration No description. @@ -495,10 +502,10 @@ No description. #### Examples -* [Configure two instances on the same server to have CLR enabled](/Examples/Resources/xSQLServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1) -* [Configure a instance to have 'Priority Boost' enabled](/Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1) +* [Configure two instances on the same server to have CLR enabled](/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1) +* [Configure a instance to have 'Priority Boost' enabled](/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1) -### xSQLServerDatabase +### SqlDatabase This resource is used to create or delete a database. For more information about database, please read: @@ -523,10 +530,10 @@ database, please read: #### Examples -* [Create a Database](/Examples/Resources/xSQLServerDatabase/1-CreateDatabase.ps1) -* [Delete a database](/Examples/Resources/xSQLServerDatabase/2-DeleteDatabase.ps1) +* [Create a Database](/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1) +* [Delete a database](/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1) -### xSQLServerDatabaseDefaultLocation +### SqlDatabaseDefaultLocation This resource is used to configure default locations for user databases. The types of default locations that can be changed are Data, Log, and Backup. For @@ -560,9 +567,9 @@ more information about database default locations, please read the article #### Examples -* [Set database default locations](/Examples/Resources/xSQLServerDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1) +* [Set database default locations](/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1) -### xSQLServerDatabaseOwner +### SqlDatabaseOwner This resource is used to configure the owner of a database. For more information about database owner, please read the article @@ -583,9 +590,9 @@ For more information about database owner, please read the article #### Examples -* [Set database owner](/Examples/Resources/xSQLServerDatabaseOwner/1-SetDatabaseOwner.ps1) +* [Set database owner](/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1) -### xSQLServerDatabasePermission +### SqlDatabasePermission This resource is used to grant, deny or revoke permissions for a user in a database. For more information about permissions, please read the article @@ -619,11 +626,11 @@ will also get their permission revoked. #### Examples -* [Grant Database Permission](/Examples/Resources/xSQLServerDatabasePermission/1-GrantDatabasePermissions.ps1) -* [Revoke Database Permission](/Examples/Resources/xSQLServerDatabasePermission/2-RevokeDatabasePermissions.ps1) -* [Deny Database Permission](/Examples/Resources/xSQLServerDatabasePermission/3-DenyDatabasePermissions.ps1) +* [Grant Database Permission](/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1) +* [Revoke Database Permission](/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1) +* [Deny Database Permission](/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1) -### xSQLServerDatabaseRecoveryModel +### SqlDatabaseRecoveryModel This resource set the recovery model for a database. The recovery model controls how transactions are logged, whether the transaction log requires (and allows) @@ -647,9 +654,9 @@ Read more about recovery model in this article #### Examples -* [Set the RecoveryModel of a database](/Examples/Resources/xSQLServerDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1) +* [Set the RecoveryModel of a database](/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1) -### xSQLServerDatabaseRole +### SqlDatabaseRole This resource is used to add or remove role for a login in a database. Read more about database role in this article [CREATE ROLE (Transact-SQL)](https://msdn.microsoft.com/en-us/library/ms187936.aspx) @@ -675,18 +682,18 @@ Read more about database role in this article [CREATE ROLE (Transact-SQL)](https #### Examples -* [Add Role of a database](/Examples/Resources/xSQLServerDatabaseRole/1-AddDatabaseRole.ps1) -* [Remove Role of a database](/Examples/Resources/xSQLServerDatabaseRole/2-RemoveDatabaseRole.ps1) +* [Add Role of a database](/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1) +* [Remove Role of a database](/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1) -### xSQLServerEndpoint +### SqlServerEndpoint This resource is used to create an endpoint. Currently it only supports creating a database mirror endpoint which can be used by, for example, AlwaysOn. >Note: The endpoint will be started after creation, but will not be enforced. Please -use [**xSQLServerEndpointState**](#xsqlserverendpointstate) to make sure the endpoint +use [**SqlServerEndpointState**](#xsqlserverendpointstate) to make sure the endpoint remains in started state. To set connect permission to the endpoint, please use -the resource [**xSQLServerEndpointPermission**](#xsqlserverendpointpermission). +the resource [**SqlServerEndpointPermission**](#xsqlserverendpointpermission). #### Requirements @@ -715,7 +722,7 @@ the resource [**xSQLServerEndpointPermission**](#xsqlserverendpointpermission). None. -### xSQLServerEndpointPermission +### SqlServerEndpointPermission This resource is used to give connect permission to an endpoint for a user (login). @@ -737,15 +744,15 @@ This resource is used to give connect permission to an endpoint for a user (logi #### Examples -* [Add connect permission to an Endpoint](/Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1) -* [Remove the connect permission for an Endpoint](/Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1) +* [Add connect permission to an Endpoint](/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1) +* [Remove the connect permission for an Endpoint](/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1) * [Add connect permission to both an Always On primary replica and an Always On - secondary replica, and where each replica has a different SQL service account](/Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1) + secondary replica, and where each replica has a different SQL service account](/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1) * [Remove connect permission to both an Always On primary replica and an Always On secondary replica, and where each replica has a different SQL service - account](/Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1) + account](/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1) -### xSQLServerEndpointState +### SqlServerEndpointState This resource is used to set the state of an endpoint. @@ -770,10 +777,10 @@ This resource is used to set the state of an endpoint. #### Examples -* [Make sure that an endpoint is started](/Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1) -* [Make sure that an endpoint is stopped](/Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1) +* [Make sure that an endpoint is started](/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1) +* [Make sure that an endpoint is stopped](/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1) -### xSQLServerFirewall +### SqlWindowsFirewall This will set default firewall rules for the supported features. Currently the features supported are Database Engine, Analysis Services, SQL Browser, @@ -855,10 +862,10 @@ Port: tcp/135 | SQL Server Integration Services Port #### Examples -* [Create inbound firewall rules](/Examples/Resources/xSQLServerFirewall/1-CreateInboundFirewallRules.ps1) -* [Remove inbound firewall rules](/Examples/Resources/xSQLServerFirewall/2-RemoveInboundFirewallRules.ps1) +* [Create inbound firewall rules](/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1) +* [Remove inbound firewall rules](/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1) -### xSQLServerLogin +### SqlServerLogin No description. @@ -896,7 +903,7 @@ No description. None. -### xSQLServerMaxDop +### SqlServerMaxDop This resource set the max degree of parallelism server configuration option. The max degree of parallelism option is used to limit the number of processors to @@ -946,11 +953,11 @@ Read more about max degree of parallelism in this article #### Examples -* [Set SQLServerMaxDop to 1](/Examples/Resources/xSQLServerMaxDop/1-SetMaxDopToOne.ps1) -* [Set SQLServerMaxDop to Auto](/Examples/Resources/xSQLServerMaxDop/2-SetMaxDopToAuto.ps1) -* [Set SQLServerMaxDop to Default](/Examples/Resources/xSQLServerMaxDop/3-SetMaxDopToDefault.ps1) +* [Set SQLServerMaxDop to 1](/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1) +* [Set SQLServerMaxDop to Auto](/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1) +* [Set SQLServerMaxDop to Default](/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1) -### xSQLServerMemory +### SqlServerMemory This resource sets the minimum server memory and maximum server memory configuration option. @@ -1021,12 +1028,12 @@ SQL Max Memory = TotalPhysicalMemory - (NumOfSQLThreads\*ThreadStackSize) - #### Examples -* [Set SQLServerMaxMemory to 12GB](/Examples/Resources/xSQLServerMemory/1-SetMaxMemoryTo12GB.ps1) -* [Set SQLServerMaxMemory to Auto](/Examples/Resources/xSQLServerMemory/2-SetMaxMemoryToAuto.ps1) -* [Set SQLServerMinMemory to 2GB and SQLServerMaxMemory to Auto](/Examples/Resources/xSQLServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1) -* [Set SQLServerMaxMemory to Default](/Examples/Resources/xSQLServerMemory/3-SetMaxMemoryToDefault.ps1) +* [Set SQLServerMaxMemory to 12GB](/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1) +* [Set SQLServerMaxMemory to Auto](/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1) +* [Set SQLServerMinMemory to 2GB and SQLServerMaxMemory to Auto](/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1) +* [Set SQLServerMaxMemory to Default](/Examples/Resources/SqlServerMemory/3-SetMaxMemoryToDefault.ps1) -### xSQLServerNetwork +### SqlServerNetwork This resource is used to change the network settings for the instance. @@ -1063,10 +1070,10 @@ Read more about the network settings in the article #### Examples -* [Enable TCP/IP with static port and restart SQL Server](/Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1) -* [Enable TCP/IP with dynamic port](/Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1) +* [Enable TCP/IP with static port and restart SQL Server](/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1) +* [Enable TCP/IP with dynamic port](/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1) -### xSQLServerPermission +### SqlServerPermission This resource sets server permissions to a user (login). @@ -1094,10 +1101,10 @@ AlterAnyEndPoint and ViewServerState. #### Examples -* [Add server permission for a login](/Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1) -* [Remove server permission for a login](/Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1) +* [Add server permission for a login](/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1) +* [Remove server permission for a login](/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1) -### xSQLServerReplication +### SqlServerReplication No description. @@ -1130,10 +1137,10 @@ No description. #### Examples -* [Configure a instance as the distributor](/Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1) -* [Configure a instance as the publisher](/Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1) +* [Configure a instance as the distributor](/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1) +* [Configure a instance as the publisher](/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1) -### xSQLServerRole +### SqlServerRole This resource is used to create a server role, when Ensure is set to 'Present'. Or remove a server role, when Ensure is set to 'Absent'. The resource also manages @@ -1169,13 +1176,13 @@ server roles, please read the below articles. #### Examples -* [Add server role](/Examples/Resources/xSQLServerRole/1-AddServerRole.ps1) -* [Remove server role](/Examples/Resources/xSQLServerRole/2-RemoveServerRole.ps1) -* [Add members to server role](/Examples/Resources/xSQLServerRole/3-AddMembersToServerRole.ps1) -* [Members to include in server role](/Examples/Resources/xSQLServerRole/4-MembersToIncludeInServerRole.ps1) -* [Members to exclude from server role](/Examples/Resources/xSQLServerRole/5-MembersToExcludeInServerRole.ps1) +* [Add server role](/Examples/Resources/SqlServerRole/1-AddServerRole.ps1) +* [Remove server role](/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1) +* [Add members to server role](/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1) +* [Members to include in server role](/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1) +* [Members to exclude from server role](/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1) -### xSQLServerRSConfig +### SqlRS Initializes and configures SQL Reporting Services server. @@ -1212,10 +1219,10 @@ Initializes and configures SQL Reporting Services server. #### Examples -* [Default configuration](Examples/Resources/xSQLServerRSConfig/1-DefaultConfiguration.ps1) -* [Custom virtual directories and reserved URLs](Examples/Resources/xSQLServerRSConfig/2-CustomConfiguration.ps1) +* [Default configuration](Examples/Resources/SqlRS/1-DefaultConfiguration.ps1) +* [Custom virtual directories and reserved URLs](Examples/Resources/SqlRS/2-CustomConfiguration.ps1) -### xSQLServerRSSecureConnectionLevel +### SqlRSSecureConnectionLevel No description. @@ -1237,7 +1244,7 @@ No description. None. -### xSQLServerScript +### SqlScript Provides the means to run a user generated T-SQL script on the SQL Server instance. Three scripts are required; Get T-SQL script, Set T-SQL script and the Test T-SQL @@ -1268,7 +1275,8 @@ The Set T-SQL script performs the actual change when Test T-SQL script fails. PowerShell module. _Note: There is a known problem running this resource using PowerShell 4.0. -See [issue #273](https://github.com/PowerShell/xSQLServer/issues/273) for more information._ +See [issue #273](https://github.com/PowerShell/SqlServerDsc/issues/273) +for more information._ #### Parameters @@ -1306,10 +1314,10 @@ See [issue #273](https://github.com/PowerShell/xSQLServer/issues/273) for more i #### Examples -* [Run a script using SQL Authentication](/Examples/Resources/xSQLServerScript/1-RunScriptUsingSQLAuthentication.ps1) -* [Run a script using Windows Authentication](/Examples/Resources/xSQLServerScript/2-RunScriptUsingWindowsAuthentication.ps1) +* [Run a script using SQL Authentication](/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1) +* [Run a script using Windows Authentication](/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1) -### xSQLServerServiceAccount +### SqlServiceAccount Manage the service account for SQL Server services. @@ -1336,10 +1344,10 @@ Manage the service account for SQL Server services. #### Examples -* [Run service under a user account](/Examples/Resources/xSQLServerServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1) -* [Run service with a virtual account](/Examples/Resources/xSQLServerServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1) +* [Run service under a user account](/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1) +* [Run service with a virtual account](/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1) -### xSQLServerSetup +### SqlSetup Installs SQL Server on the target node. @@ -1483,15 +1491,15 @@ installing feature Database Engine and Analysis Services respectively. #### Examples -* [Install a default instance on a single server](/Examples/Resources/xSQLServerSetup/1-InstallDefaultInstanceSingleServer.ps1) -* [Install a named instance on a single server](/Examples/Resources/xSQLServerSetup/2-InstallNamedInstanceSingleServer.ps1) -* [Install a named instance on a single server from an UNC path using SourceCredential](/Examples/Resources/xSQLServerSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1) -* [Install a named instance as the first node in SQL Server Failover Cluster](/Examples/Resources/xSQLServerSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1) -* [Install a named instance as the second node in SQL Server Failover Cluster](/Examples/Resources/xSQLServerSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1) +* [Install a default instance on a single server](/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1) +* [Install a named instance on a single server](/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1) +* [Install a named instance on a single server from an UNC path using SourceCredential](/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1) +* [Install a named instance as the first node in SQL Server Failover Cluster](/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1) +* [Install a named instance as the second node in SQL Server Failover Cluster](/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/xSQLServer/issues?q=is%3Aissue%20is%3Aopen%20xSQLServerSetup). +All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue%20is%3Aopen%20SqlSetup). ##### Severe known issues @@ -1499,7 +1507,7 @@ This is a list of known issues that severely impact the use of the resource. There are currently no known severe issues. -### xWaitForAvailabilityGroup +### SqlWaitForAG This resource will wait for a cluster role/group to be created. This is used to wait for an Availability Group to create the cluster role/group in the cluster. @@ -1538,5 +1546,5 @@ or that it has finished creating the Availability Group. #### Examples -* [Wait for a cluster role/group to be available](/Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1) -* [Wait for multiple cluster roles/groups to be available](/Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1) +* [Wait for a cluster role/group to be available](/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1) +* [Wait for multiple cluster roles/groups to be available](/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1) diff --git a/SQLServerDsc.psd1 b/SQLServerDsc.psd1 new file mode 100644 index 000000000..ea95e5732 --- /dev/null +++ b/SQLServerDsc.psd1 @@ -0,0 +1,127 @@ +@{ + # Version number of this module. + ModuleVersion = '9.0.0.0' + + # ID used to uniquely identify this module + GUID = '74e9ddb5-4cbc-4fa2-a222-2bcfb533fd66' + + # Author of this module + Author = 'Microsoft Corporation' + + # Company or vendor of this module + CompanyName = 'Microsoft Corporation' + + # Copyright statement for this module + Copyright = '(c) 2017 Microsoft Corporation. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'Module with DSC Resources for deployment and configuration of Microsoft SQL Server.' + + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '5.0' + + # Minimum version of the common language runtime (CLR) required by this module + CLRVersion = '4.0' + + # Functions to export from this module + FunctionsToExport = '*' + + # Cmdlets to export from this module + CmdletsToExport = '*' + + RequiredAssemblies = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') + + # A URL to the license for this module. + LicenseUri = 'https://github.com/PowerShell/SqlServerDsc/blob/master/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/PowerShell/SqlServerDsc' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + ReleaseNotes = '- Changes to xSQLServer + - Updated Pester syntax to v4 + - Fixes broken links to issues in the CHANGELOG.md. + - Changes to xSQLServerDatabase + - Added parameter to specify collation for a database to be different from server + collation ([issue 767](https://github.com/PowerShell/xSQLServer/issues/767)). + - Fixed unit tests for Get-TargetResource to ensure correctly testing return + values ([issue 849](https://github.com/PowerShell/xSQLServer/issues/849)) + - Changes to xSQLServerAlwaysOnAvailabilityGroup + - Refactored the unit tests to allow them to be more user friendly and to test + additional SQLServer variations. + - Each test will utilize the Import-SQLModuleStub to ensure the correct + module is loaded ([issue 784](https://github.com/PowerShell/xSQLServer/issues/784)). + - Fixed an issue when setting the SQLServer parameter to a Fully Qualified + Domain Name (FQDN) ([issue 468](https://github.com/PowerShell/xSQLServer/issues/468)). + - Fixed the logic so that if a parameter is not supplied to the resource, the + resource will not attempt to apply the defaults on subsequent checks + ([issue 517](https://github.com/PowerShell/xSQLServer/issues/517)). + - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, + the resource will only determine if a change is needed if the target node + is the active host of the SQL Server instance ([issue 868](https://github.com/PowerShell/xSQLServer/issues/868)). + - Changes to xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, + the resource will only determine if a change is needed if the target node + is the active host of the SQL Server instance ([issue 869](https://github.com/PowerShell/xSQLServer/issues/869)). + - Changes to xSQLServerAlwaysOnAvailabilityGroupReplica + - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, + the resource will only determine if a change is needed if the target node is + the active host of the SQL Server instance ([issue 870](https://github.com/PowerShell/xSQLServer/issues/870)). + - Added the CommonTestHelper.psm1 to store common testing functions. + - Added the Import-SQLModuleStub function to ensure the correct version of the + module stubs are loaded ([issue 784](https://github.com/PowerShell/xSQLServer/issues/784)). + - Changes to xSQLServerMemory + - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, + the resource will only determine if a change is needed if the target node + is the active host of the SQL Server instance ([issue 867](https://github.com/PowerShell/xSQLServer/issues/867)). + - Changes to xSQLServerNetwork + - BREAKING CHANGE: Renamed parameter TcpDynamicPorts to TcpDynamicPort and + changed type to Boolean ([issue 534](https://github.com/PowerShell/xSQLServer/issues/534)). + - Resolved issue when switching from dynamic to static port. + configuration ([issue 534](https://github.com/PowerShell/xSQLServer/issues/534)). + - Added localization (en-US) for all strings in resource and unit tests + ([issue 618](https://github.com/PowerShell/xSQLServer/issues/618)). + - Updated examples to reflect new parameters. + - Changes to xSQLServerRSConfig + - Added examples + - Added resource + - xSQLServerDatabaseDefaultLocation + ([issue 656](https://github.com/PowerShell/xSQLServer/issues/656)) + - Changes to xSQLServerEndpointPermission + - Fixed a problem when running the tests locally in a PowerShell console it + would ask for parameters ([issue 897](https://github.com/PowerShell/xSQLServer/issues/897)). + - Changes to xSQLServerAvailabilityGroupListener + - Fixed a problem when running the tests locally in a PowerShell console it + would ask for parameters ([issue 897](https://github.com/PowerShell/xSQLServer/issues/897)). + - Changes to xSQLServerMaxDop + - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, + the resource will only determine if a change is needed if the target node + is the active host of the SQL Server instance ([issue 882](https://github.com/PowerShell/xSQLServer/issues/882)). + + ' + + } # End of PSData hashtable + + } # End of PrivateData hashtable + } + + + + + + + + + + diff --git a/xSQLServerHelper.psm1 b/SqlServerDscHelper.psm1 similarity index 98% rename from xSQLServerHelper.psm1 rename to SqlServerDscHelper.psm1 index 62e6e1d25..bc8048448 100644 --- a/xSQLServerHelper.psm1 +++ b/SqlServerDscHelper.psm1 @@ -3,7 +3,7 @@ Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot ` -ChildPath 'DscResources') ` -ChildPath 'CommonResourceHelper.psm1') -$script:localizedData = Get-LocalizedData -ResourceName 'xSQLServerHelper' -ScriptRoot $PSScriptRoot +$script:localizedData = Get-LocalizedData -ResourceName 'SqlServerDscHelper' -ScriptRoot $PSScriptRoot <# .SYNOPSIS @@ -342,8 +342,8 @@ function Get-SqlInstanceMajorVersion Returns a localized error message. This helper function is obsolete, should use new helper functions. - https://github.com/PowerShell/xSQLServer/blob/dev/CONTRIBUTING.md#localization - https://github.com/PowerShell/xSQLServer/blob/dev/DSCResources/CommonResourceHelper.psm1 + https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md#localization + https://github.com/PowerShell/SqlServerDsc/blob/dev/DSCResources/CommonResourceHelper.psm1 Strings in this function has not been localized since this helper function should be removed when all resources has moved over to the new localization, @@ -441,7 +441,7 @@ function New-TerminatingError This helper function is obsolete, should use Write-Warning together with individual resource localization strings. - https://github.com/PowerShell/xSQLServer/blob/dev/CONTRIBUTING.md#localization + https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md#localization Strings in this function has not been localized since this helper function should be removed when all resources has moved over to the new localization, @@ -496,7 +496,7 @@ function New-WarningMessage This helper function is obsolete, should use Write-Verbose together with individual resource localization strings. - https://github.com/PowerShell/xSQLServer/blob/dev/CONTRIBUTING.md#localization + https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md#localization Strings in this function has not been localized since this helper function should be removed when all resources has moved over to the new localization, diff --git a/Tests/Integration/MSFT_xSQLServerAlwaysOnService.Integration.Tests.ps1 b/Tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 similarity index 98% rename from Tests/Integration/MSFT_xSQLServerAlwaysOnService.Integration.Tests.ps1 rename to Tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 index b93a57c94..09d3ed29b 100644 --- a/Tests/Integration/MSFT_xSQLServerAlwaysOnService.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceFriendlyName = 'xSQLServerAlwaysOnService' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceFriendlyName = 'SqlAlwaysOnService' $script:DSCResourceName = "MSFT_$($script:DSCResourceFriendlyName)" if (-not $env:APPVEYOR -eq $true) diff --git a/Tests/Integration/MSFT_xSQLServerAlwaysOnService.config.ps1 b/Tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 similarity index 94% rename from Tests/Integration/MSFT_xSQLServerAlwaysOnService.config.ps1 rename to Tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 index 973013303..77e6f90ed 100644 --- a/Tests/Integration/MSFT_xSQLServerAlwaysOnService.config.ps1 +++ b/Tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 @@ -15,7 +15,7 @@ $ConfigurationData = @{ ) } -Configuration MSFT_xSQLServerAlwaysOnService_EnableAlwaysOn_Config +Configuration MSFT_SqlAlwaysOnService_EnableAlwaysOn_Config { param ( @@ -26,7 +26,7 @@ Configuration MSFT_xSQLServerAlwaysOnService_EnableAlwaysOn_Config ) Import-DscResource -ModuleName 'PSDscResources' - Import-DscResource -ModuleName 'xSQLServer' + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { WindowsFeature 'AddFeatureFailoverClustering' @@ -123,7 +123,7 @@ Configuration MSFT_xSQLServerAlwaysOnService_EnableAlwaysOn_Config } } - xSQLServerAlwaysOnService 'Integration_Test' + SqlAlwaysOnService 'Integration_Test' { Ensure = 'Present' SQLServer = $Node.ComputerName @@ -141,7 +141,7 @@ Configuration MSFT_xSQLServerAlwaysOnService_EnableAlwaysOn_Config } } -Configuration MSFT_xSQLServerAlwaysOnService_DisableAlwaysOn_Config +Configuration MSFT_SqlAlwaysOnService_DisableAlwaysOn_Config { param ( @@ -151,10 +151,10 @@ Configuration MSFT_xSQLServerAlwaysOnService_DisableAlwaysOn_Config $SqlInstallCredential ) - Import-DscResource -ModuleName 'xSQLServer' + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - xSQLServerAlwaysOnService 'Integration_Test' + SqlAlwaysOnService 'Integration_Test' { Ensure = 'Absent' SQLServer = $Node.ComputerName diff --git a/Tests/Integration/MSFT_xSQLServerDatabaseDefaultLocation.Integration.Tests.ps1 b/Tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 similarity index 98% rename from Tests/Integration/MSFT_xSQLServerDatabaseDefaultLocation.Integration.Tests.ps1 rename to Tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 index 5db3676f6..281c8ca91 100644 --- a/Tests/Integration/MSFT_xSQLServerDatabaseDefaultLocation.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceFriendlyName = 'xSQLServerDatabaseDefaultLocation' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceFriendlyName = 'SqlDatabaseDefaultLocation' $script:DSCResourceName = "MSFT_$($script:DSCResourceFriendlyName)" if (-not $env:APPVEYOR -eq $true) diff --git a/Tests/Integration/MSFT_xSQLServerDatabaseDefaultLocation.config.ps1 b/Tests/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 similarity index 86% rename from Tests/Integration/MSFT_xSQLServerDatabaseDefaultLocation.config.ps1 rename to Tests/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 index 048c9b47e..3a55bc697 100644 --- a/Tests/Integration/MSFT_xSQLServerDatabaseDefaultLocation.config.ps1 +++ b/Tests/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 @@ -19,7 +19,7 @@ $ConfigurationData = @{ ) } -Configuration MSFT_xSQLServerDatabaseDefaultLocation_Data_Config +Configuration MSFT_SqlDatabaseDefaultLocation_Data_Config { param ( @@ -30,7 +30,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Data_Config ) Import-DscResource -ModuleName 'PSDesiredStateConfiguration' - Import-DscResource -ModuleName 'xSQLServer' + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { File 'SQLDataPath' @@ -42,7 +42,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Data_Config Type = 'Directory' } - xSQLServerDatabaseDefaultLocation 'Integration_Test' + SqlDatabaseDefaultLocation 'Integration_Test' { Type = 'Data' Path = $Node.DataFilePath @@ -57,7 +57,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Data_Config } } -Configuration MSFT_xSQLServerDatabaseDefaultLocation_Log_Config +Configuration MSFT_SqlDatabaseDefaultLocation_Log_Config { param ( @@ -68,7 +68,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Log_Config ) Import-DscResource -ModuleName 'PSDesiredStateConfiguration' - Import-DscResource -ModuleName 'xSQLServer' + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { File 'SQLLogPath' @@ -80,7 +80,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Log_Config Type = 'Directory' } - xSQLServerDatabaseDefaultLocation 'Integration_Test' + SqlDatabaseDefaultLocation 'Integration_Test' { Type = 'Log' Path = $Node.LogFilePath @@ -95,7 +95,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Log_Config } } -Configuration MSFT_xSQLServerDatabaseDefaultLocation_Backup_Config +Configuration MSFT_SqlDatabaseDefaultLocation_Backup_Config { param ( @@ -106,7 +106,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Backup_Config ) Import-DscResource -ModuleName 'PSDesiredStateConfiguration' - Import-DscResource -ModuleName 'xSQLServer' + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { File 'SQLBackupPath' @@ -118,7 +118,7 @@ Configuration MSFT_xSQLServerDatabaseDefaultLocation_Backup_Config Type = 'Directory' } - xSQLServerDatabaseDefaultLocation 'Integration_Test' + SqlDatabaseDefaultLocation 'Integration_Test' { Type = 'Backup' Path = $Node.BackupFilePath diff --git a/Tests/Integration/MSFT_xSQLServerRSConfig.Integration.Tests.ps1 b/Tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 similarity index 98% rename from Tests/Integration/MSFT_xSQLServerRSConfig.Integration.Tests.ps1 rename to Tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 index 9f49456c6..42250ea1f 100644 --- a/Tests/Integration/MSFT_xSQLServerRSConfig.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceFriendlyName = 'xSQLServerRSConfig' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceFriendlyName = 'SqlRS' $script:DSCResourceName = "MSFT_$($script:DSCResourceFriendlyName)" if (-not $env:APPVEYOR -eq $true) diff --git a/Tests/Integration/MSFT_xSQLServerRSConfig.config.ps1 b/Tests/Integration/MSFT_SqlRS.config.ps1 similarity index 93% rename from Tests/Integration/MSFT_xSQLServerRSConfig.config.ps1 rename to Tests/Integration/MSFT_SqlRS.config.ps1 index 7b65b390c..f6e9b5898 100644 --- a/Tests/Integration/MSFT_xSQLServerRSConfig.config.ps1 +++ b/Tests/Integration/MSFT_SqlRS.config.ps1 @@ -30,7 +30,7 @@ $ConfigurationData = @{ ) } -Configuration MSFT_xSQLServerRSConfig_InstallReportingServices_Config +Configuration MSFT_SqlRS_InstallReportingServices_Config { param ( @@ -52,7 +52,7 @@ Configuration MSFT_xSQLServerRSConfig_InstallReportingServices_Config Import-DscResource -ModuleName 'PSDscResources' Import-DscResource -ModuleName 'xStorage' - Import-DscResource -ModuleName 'xSQLServer' + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { xMountImage 'MountIsoMedia' @@ -82,7 +82,7 @@ Configuration MSFT_xSQLServerRSConfig_InstallReportingServices_Config Ensure = 'Present' } - xSQLServerSetup 'InstallReportingServicesInstance' + SqlSetup 'InstallReportingServicesInstance' { InstanceName = $Node.InstanceName Features = $Node.Features @@ -109,7 +109,7 @@ Configuration MSFT_xSQLServerRSConfig_InstallReportingServices_Config PsDscRunAsCredential = $SqlInstallCredential } - xSQLServerRSConfig 'Integration_Test' + SqlRS 'Integration_Test' { # Instance name for the Reporting Services. InstanceName = $Node.InstanceName @@ -124,7 +124,7 @@ Configuration MSFT_xSQLServerRSConfig_InstallReportingServices_Config PsDscRunAsCredential = $SqlInstallCredential DependsOn = @( - '[xSQLServerSetup]InstallReportingServicesInstance' + '[SqlSetup]InstallReportingServicesInstance' ) } } diff --git a/Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1 b/Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 similarity index 99% rename from Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1 rename to Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 index d3d11d27c..7a86c282d 100644 --- a/Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceFriendlyName = 'xSQLServerSetup' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceFriendlyName = 'SqlSetup' $script:DSCResourceName = "MSFT_$($script:DSCResourceFriendlyName)" if (-not $env:APPVEYOR -eq $true) diff --git a/Tests/Integration/MSFT_xSQLServerSetup.config.ps1 b/Tests/Integration/MSFT_SqlSetup.config.ps1 similarity index 95% rename from Tests/Integration/MSFT_xSQLServerSetup.config.ps1 rename to Tests/Integration/MSFT_SqlSetup.config.ps1 index 2279a8d89..8843f48aa 100644 --- a/Tests/Integration/MSFT_xSQLServerSetup.config.ps1 +++ b/Tests/Integration/MSFT_SqlSetup.config.ps1 @@ -28,7 +28,7 @@ $ConfigurationData = @{ ) } -Configuration MSFT_xSQLServerSetup_InstallSqlEngineAsSystem_Config +Configuration MSFT_SqlSetup_InstallSqlEngineAsSystem_Config { param ( @@ -55,7 +55,7 @@ Configuration MSFT_xSQLServerSetup_InstallSqlEngineAsSystem_Config Import-DscResource -ModuleName 'PSDscResources' Import-DscResource -ModuleName 'xStorage' - Import-DscResource -ModuleName 'xSQLServer' + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { xMountImage 'MountIsoMedia' @@ -113,7 +113,7 @@ Configuration MSFT_xSQLServerSetup_InstallSqlEngineAsSystem_Config Ensure = 'Present' } - xSQLServerSetup 'Integration_Test' + SqlSetup 'Integration_Test' { InstanceName = $Node.InstanceName Features = $Node.Features @@ -134,7 +134,7 @@ Configuration MSFT_xSQLServerSetup_InstallSqlEngineAsSystem_Config $SqlAdministratorCredential.UserName <# Must have permission to properties IsClustered and - IsHadrEnable for xSQLServerAlwaysOnService. + IsHadrEnable for SqlAlwaysOnService. #> $SqlInstallCredential.UserName ) diff --git a/Tests/xSQLServerCommon.Tests.ps1 b/Tests/SqlServerDscCommon.Tests.ps1 similarity index 94% rename from Tests/xSQLServerCommon.Tests.ps1 rename to Tests/SqlServerDscCommon.Tests.ps1 index 618dcd463..43c3f6d17 100644 --- a/Tests/xSQLServerCommon.Tests.ps1 +++ b/Tests/SqlServerDscCommon.Tests.ps1 @@ -5,7 +5,7 @@ param() $script:moduleRoot = Split-Path $PSScriptRoot -Parent -Describe 'xSQLServer module common tests' { +Describe 'SqlServerDsc module common tests' { Context -Name 'When there are example file for resource' { <# For Appveyor builds copy the module to the system modules directory so it falls @@ -13,7 +13,7 @@ Describe 'xSQLServer module common tests' { #> if ($env:APPVEYOR) { - $powershellModulePath = Join-Path -Path (($env:PSModulePath -split ';')[0]) -ChildPath 'xSQLServer' + $powershellModulePath = Join-Path -Path (($env:PSModulePath -split ';')[0]) -ChildPath 'SqlServerDsc' Copy-item -Path $env:APPVEYOR_BUILD_FOLDER -Destination $powershellModulePath -Recurse -Force } @@ -69,7 +69,7 @@ Describe 'xSQLServer module common tests' { Remove-item -Path $powershellModulePath -Recurse -Force -Confirm:$false # Restore the module in 'memory' to ensure other tests after this test have access to it - Import-Module -Name "$script:moduleRoot\xSQLServer.psd1" -Global -Force + Import-Module -Name "$script:moduleRoot\SqlServerDsc.psd1" -Global -Force } } } diff --git a/Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroup.Tests.ps1 b/Tests/Unit/MSFT_SqlAG.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroup.Tests.ps1 rename to Tests/Unit/MSFT_SqlAG.Tests.ps1 index 0a0409bca..d0eb895b0 100644 --- a/Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroup.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAG.Tests.ps1 @@ -12,8 +12,8 @@ Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -P Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'Tests' -ChildPath (Join-Path -Path 'TestHelpers' -ChildPath 'CommonTestHelper.psm1'))) -Force -Global $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName 'xSQLServer' ` - -DSCResourceName 'MSFT_xSQLServerAlwaysOnAvailabilityGroup' ` + -DSCModuleName 'SqlServerDsc' ` + -DSCResourceName 'MSFT_SqlAG' ` -TestType Unit #endregion HEADER @@ -35,7 +35,7 @@ try { Invoke-TestSetup - InModuleScope 'MSFT_xSQLServerAlwaysOnAvailabilityGroup' { + InModuleScope 'MSFT_SqlAG' { #region parameter mocks @@ -681,7 +681,7 @@ try #endregion cmdlet mocks - Describe 'xSQLServerAlwaysOnAvailabilityGroup\Get-TargetResource' -Tag 'Get' { + Describe 'SqlAG\Get-TargetResource' -Tag 'Get' { BeforeAll { Mock -CommandName Connect-SQL -MockWith $mockConnectSql -Verifiable } @@ -770,7 +770,7 @@ try } } - Describe 'xSQLServerAlwaysOnAvailabilityGroup\Set-TargetResource' -Tag 'Set' { + Describe 'SqlAG\Set-TargetResource' -Tag 'Set' { BeforeAll { Mock -CommandName Connect-SQL -MockWith $mockConnectSql -Verifiable Mock -CommandName Get-PrimaryReplicaServerObject -MockWith $mockConnectSql -Verifiable @@ -1205,7 +1205,7 @@ try } } - Describe 'xSQLServerAlwaysOnAvailabilityGroup\Test-TargetResource' -Tag 'Test' { + Describe 'SqlAG\Test-TargetResource' -Tag 'Test' { BeforeAll { Mock -CommandName Connect-SQL -MockWith $mockConnectSql -Verifiable Mock -CommandName Test-ActiveNode -MockWith { @@ -1389,7 +1389,7 @@ try } } - Describe 'xSQLServerAlwaysOnAvailabilityGroup\Update-AvailabilityGroup' -Tag 'Helper' { + Describe 'SqlAG\Update-AvailabilityGroup' -Tag 'Helper' { BeforeAll { Mock -CommandName New-TerminatingError -MockWith { $ErrorType diff --git a/Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.Tests.ps1 b/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.Tests.ps1 rename to Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 index 95e108627..ddb703f08 100644 --- a/Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 @@ -9,15 +9,15 @@ if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCR } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent | Split-Path -Parent) -ChildPath 'xSQLServerHelper.psm1') -Scope Global -Force +Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent | Split-Path -Parent) -ChildPath 'SqlServerDscHelper.psm1') -Scope Global -Force Import-Module -Name ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SQLPSStub.psm1 ) -Force -Global # Loading mocked classes Add-Type -Path ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SMO.cs ) $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName 'xSQLServer' ` - -DSCResourceName 'MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership' ` + -DSCModuleName 'SqlServerDsc' ` + -DSCResourceName 'MSFT_SqlAGDatabase' ` -TestType Unit #endregion HEADER @@ -37,7 +37,7 @@ try { Invoke-TestSetup - InModuleScope 'MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership' { + InModuleScope 'MSFT_SqlAGDatabase' { #region Parameter Mocks @@ -354,7 +354,7 @@ WITH NORECOVERY' #endregion Invoke Query Mock - Describe 'xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership\Get-TargetResource' { + Describe 'SqlAGDatabase\Get-TargetResource' { BeforeAll { Mock -CommandName Connect-SQL -MockWith { return $mockServerObject } -Verifiable Mock -CommandName Import-SQLPSModule -MockWith {} -Verifiable @@ -422,7 +422,7 @@ WITH NORECOVERY' } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership\Set-TargetResource' { + Describe 'SqlAGDatabase\Set-TargetResource' { BeforeAll { Mock -CommandName Get-PrimaryReplicaServerObject -MockWith { return $mockServerObject } -Verifiable -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } Mock -CommandName Get-PrimaryReplicaServerObject -MockWith { return $mockServer2Object } -Verifiable -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server2' } @@ -1137,7 +1137,7 @@ WITH NORECOVERY' } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership\Test-TargetResource' { + Describe 'SqlAGDatabase\Test-TargetResource' { BeforeAll { Mock -CommandName Connect-SQL -MockWith { return $mockServerObject } -Verifiable Mock -CommandName Get-PrimaryReplicaServerObject -MockWith { return $mockServerObject } -Verifiable -ParameterFilter { $AvailabilityGroup.PrimaryReplicaServerName -eq 'Server1' } @@ -1331,7 +1331,7 @@ WITH NORECOVERY' } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership\Get-DatabasesToAddToAvailabilityGroup' { + Describe 'SqlAGDatabase\Get-DatabasesToAddToAvailabilityGroup' { BeforeEach { $getDatabasesToAddToAvailabilityGroup = @{ DatabaseName = $mockDatabaseNameParameter.Clone() @@ -1370,7 +1370,7 @@ WITH NORECOVERY' } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership\Get-DatabasesToRemoveFromAvailabilityGroup' { + Describe 'SqlAGDatabase\Get-DatabasesToRemoveFromAvailabilityGroup' { BeforeEach { $getDatabasesToRemoveFromAvailabilityGroupParameters = @{ DatabaseName = $mockDatabaseNameParameter.Clone() @@ -1447,7 +1447,7 @@ WITH NORECOVERY' } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership\Get-MatchingDatabaseNames' { + Describe 'SqlAGDatabase\Get-MatchingDatabaseNames' { BeforeEach { $getMatchingDatabaseNamesParameters = @{ DatabaseName = $mockDatabaseNameParameter.Clone() @@ -1479,7 +1479,7 @@ WITH NORECOVERY' } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership\Get-DatabaseNamesNotFoundOnTheInstance' { + Describe 'SqlAGDatabase\Get-DatabaseNamesNotFoundOnTheInstance' { Context 'When the Get-DatabaseNamesNotFoundOnTheInstance function is called' { BeforeAll { # The defined databases that should be identified as missing diff --git a/Tests/Unit/MSFT_xSQLServerAvailabilityGroupListener.Tests.ps1 b/Tests/Unit/MSFT_SqlAGListener.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerAvailabilityGroupListener.Tests.ps1 rename to Tests/Unit/MSFT_SqlAGListener.Tests.ps1 index d3ec63a44..305000356 100644 --- a/Tests/Unit/MSFT_xSQLServerAvailabilityGroupListener.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAGListener.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerAvailabilityGroupListener' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlAGListener' #region HEADER @@ -93,7 +93,7 @@ try #endregion Pester Test Initialization - Describe 'xSQLServerAvailabilityGroupListener\Get-TargetResource' { + Describe 'SqlAGListener\Get-TargetResource' { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -224,7 +224,7 @@ try Assert-VerifiableMock } - Describe 'xSQLServerAvailabilityGroupListener\Test-TargetResource' { + Describe 'SqlAGListener\Test-TargetResource' { BeforeEach { $testParameters = $defaultParameters.Clone() } @@ -509,7 +509,7 @@ try Assert-VerifiableMock } - Describe 'xSQLServerAvailabilityGroupListener\Set-TargetResource' { + Describe 'SqlAGListener\Set-TargetResource' { BeforeEach { $testParameters = $defaultParameters.Clone() diff --git a/Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.Tests.ps1 b/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.Tests.ps1 rename to Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 index 24a24b8a4..65f8a6758 100644 --- a/Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 @@ -13,8 +13,8 @@ Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -P Add-Type -Path ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SMO.cs ) $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName 'xSQLServer' ` - -DSCResourceName 'MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica' ` + -DSCModuleName 'SqlServerDsc' ` + -DSCResourceName 'MSFT_SqlAGReplica' ` -TestType Unit #endregion HEADER @@ -33,7 +33,7 @@ try { Invoke-TestSetup - InModuleScope 'MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica' { + InModuleScope 'MSFT_SqlAGReplica' { #region parameter mocks @@ -530,7 +530,7 @@ try #endregion - Describe 'xSQLServerAlwaysOnAvailabilityGroupReplica\Get-TargetResource' { + Describe 'SqlAGReplica\Get-TargetResource' { BeforeEach { $getTargetResourceParameters = @{ Name = $mockAvailabilityGroupReplicaName @@ -602,7 +602,7 @@ try } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupReplica\Set-TargetResource' { + Describe 'SqlAGReplica\Set-TargetResource' { BeforeAll { Mock -CommandName Import-SQLPSModule -MockWith {} -Verifiable @@ -1266,7 +1266,7 @@ try } } - Describe 'xSQLServerAlwaysOnAvailabilityGroupReplica\Test-TargetResource' { + Describe 'SqlAGReplica\Test-TargetResource' { BeforeEach { $mockAlternateEndpointPort = $false diff --git a/Tests/Unit/MSFT_xSQLServerAlias.Tests.ps1 b/Tests/Unit/MSFT_SqlAlias.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerAlias.Tests.ps1 rename to Tests/Unit/MSFT_SqlAlias.Tests.ps1 index ff796b22c..8ff0a6fc8 100644 --- a/Tests/Unit/MSFT_xSQLServerAlias.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAlias.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerAlias' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlAlias' #region HEADER diff --git a/Tests/Unit/MSFT_xSQLServerAlwaysOnService.Tests.ps1 b/Tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerAlwaysOnService.Tests.ps1 rename to Tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 index 59547d7b0..bec070953 100644 --- a/Tests/Unit/MSFT_xSQLServerAlwaysOnService.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerAlwaysOnService' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlAlwaysOnService' # Unit Test Template Version: 1.1.0 [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/Tests/Unit/MSFT_xSQLServerDatabase.Tests.ps1 b/Tests/Unit/MSFT_SqlDatabase.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_xSQLServerDatabase.Tests.ps1 rename to Tests/Unit/MSFT_SqlDatabase.Tests.ps1 index 5a1ae80ed..7818ccb22 100644 --- a/Tests/Unit/MSFT_xSQLServerDatabase.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlDatabase.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerDatabase' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlDatabase' #region HEADER @@ -125,7 +125,7 @@ try } #endregion - Describe "MSFT_xSQLServerDatabase\Get-TargetResource" -Tag 'Get'{ + Describe "MSFT_SqlDatabase\Get-TargetResource" -Tag 'Get'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable } @@ -185,7 +185,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerDatabase\Test-TargetResource" -Tag 'Test'{ + Describe "MSFT_SqlDatabase\Test-TargetResource" -Tag 'Test'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable } @@ -287,7 +287,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerDatabase\Set-TargetResource" -Tag 'Set'{ + Describe "MSFT_SqlDatabase\Set-TargetResource" -Tag 'Set'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Mock -CommandName New-Object -MockWith $mockNewObjectDatabase -ParameterFilter { diff --git a/Tests/Unit/MSFT_xSQLServerDatabaseDefaultLocation.Tests.ps1 b/Tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_xSQLServerDatabaseDefaultLocation.Tests.ps1 rename to Tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 index 9b79817a8..561799653 100644 --- a/Tests/Unit/MSFT_xSQLServerDatabaseDefaultLocation.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 @@ -13,8 +13,8 @@ Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -P Add-Type -Path ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SMO.cs ) $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName 'xSQLServer' ` - -DSCResourceName 'MSFT_xSQLServerDatabaseDefaultLocation' ` + -DSCModuleName 'SqlServerDsc' ` + -DSCResourceName 'MSFT_SqlDatabaseDefaultLocation' ` -TestType Unit #endregion HEADER @@ -31,7 +31,7 @@ try { Invoke-TestSetup - InModuleScope 'MSFT_xSQLServerDatabaseDefaultLocation' { + InModuleScope 'MSFT_SqlDatabaseDefaultLocation' { $mockSqlServerName = 'localhost' $mockSqlServerInstanceName = 'MSSQLSERVER' $mockSQLDataPath = 'C:\Program Files\Data\' @@ -101,7 +101,7 @@ try ) #endregion - Describe 'MSFT_xSQLServerDatabaseDefaultLocation\Get-TargetResource' -Tag 'Get'{ + Describe 'MSFT_SqlDatabaseDefaultLocation\Get-TargetResource' -Tag 'Get'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Mock -CommandName Test-ActiveNode -Mockwith { @@ -135,7 +135,7 @@ try } } - Describe 'MSFT_xSQLServerDatabaseDefaultLocation\Test-TargetResource' -Tag 'Test'{ + Describe 'MSFT_SqlDatabaseDefaultLocation\Test-TargetResource' -Tag 'Test'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Mock -CommandName Test-ActiveNode -MockWith { @@ -213,7 +213,7 @@ try } } - Describe 'MSFT_xSQLServerDatabaseDefaultLocation\Set-TargetResource' -Tag 'Set'{ + Describe 'MSFT_SqlDatabaseDefaultLocation\Set-TargetResource' -Tag 'Set'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Mock -CommandName Restart-SqlService -Verifiable diff --git a/Tests/Unit/MSFT_xSQLServerDatabaseOwner.Tests.ps1 b/Tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 similarity index 95% rename from Tests/Unit/MSFT_xSQLServerDatabaseOwner.Tests.ps1 rename to Tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 index ee95cb492..6390c5d31 100644 --- a/Tests/Unit/MSFT_xSQLServerDatabaseOwner.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 @@ -1,303 +1,303 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerDatabaseOwner' - -#region HEADER - -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit - -#endregion HEADER - -function Invoke-TestSetup { -} - -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment -} - -# Begin Testing -try -{ - Invoke-TestSetup - - InModuleScope $script:DSCResourceName { - $mockSqlServerName = 'localhost' - $mockSqlServerInstanceName = 'MSSQLSERVER' - $mockSqlDatabaseName = 'AdventureWorks' - $mockSqlServerLogin = 'Zebes\SamusAran' - $mockSqlServerLoginType = 'WindowsUser' - $mockDatabaseOwner = 'Elysia\Chozo' - $mockInvalidOperationForSetOwnerMethod = $false - $mockExpectedDatabaseOwner = 'Elysia\Chozo' - - # Default parameters that are used for the It-blocks - $mockDefaultParameters = @{ - SQLInstanceName = $mockSqlServerInstanceName - SQLServer = $mockSqlServerName - } - - #region Function mocks - $mockConnectSQL = { - return @( - ( - New-Object Object | - Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSqlServerInstanceName -PassThru | - Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSqlServerName -PassThru | - Add-Member -MemberType ScriptProperty -Name Databases -Value { - return @{ - $mockSqlDatabaseName = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlDatabaseName -PassThru | - Add-Member -MemberType NoteProperty -Name Owner -Value $mockDatabaseOwner -PassThru | - Add-Member -MemberType ScriptMethod -Name SetOwner -Value { - if ($mockInvalidOperationForSetOwnerMethod) - { - throw 'Mock of method SetOwner() was called with invalid operation.' - } - - if ( $this.Owner -ne $mockExpectedDatabaseOwner ) - { - throw "Called mocked SetOwner() method without setting the right login. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedDatabaseOwner, $this.Owner - } - } -PassThru -Force - )) - } - } -PassThru -Force | - Add-Member -MemberType ScriptProperty -Name Logins -Value { - return @{ - $mockSqlServerLogin = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru - )) - } - } -PassThru -Force - ) - ) - } - #endregion - - Describe "MSFT_xSQLServerDatabaseOwner\Get-TargetResource" -Tag 'Get'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When passing values to parameters and database name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = 'unknownDatabaseName' - Name = $mockSqlServerLogin - } - - $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is either in the desired state or not in the desired state' { - It 'Should not throw' { - $testParameters = $defaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - } - - $result = Get-TargetResource @testParameters - } - - It 'Should return the name of the owner from the get method' { - $result.Name | Should -Be $testParameters.Name - } - - It 'Should return the same values as passed as parameters' { - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.Database | Should -Be $testParameters.Database - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerDatabaseOwner\Test-TargetResource" -Tag 'Test'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When the system is not in the desired state' { - It 'Should return the state as false when desired login is not the database owner' { - $testParameters = $defaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $false - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is in the desired state' { - It 'Should return the state as true when desired login is the database owner' { - $mockDatabaseOwner = 'Zebes\SamusAran' - $mockSqlServerLogin = 'Zebes\SamusAran' - $testParameters = $defaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $true - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerDatabaseOwner\Set-TargetResource" -Tag 'Set'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When the system is not in the desired state and database name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = 'unknownDatabaseName' - Name = $mockSqlServerLogin - } - - $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state and login name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = 'John' - } - - $throwInvalidOperation = ("Login 'John' does not exist on " + ` - "SQL server 'localhost\MSSQLSERVER'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state' { - It 'Should not throw' { - $mockExpectedDatabaseOwner = $mockSqlServerLogin - $mockDatabaseOwner = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state' { - It 'Should throw the correct error when the method SetOwner() set the wrong login' { - $mockExpectedDatabaseOwner = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - } - - $throwInvalidOperation = ('Failed to set owner named Zebes\SamusAran of the database ' + ` - 'named AdventureWorks on localhost\MSSQLSERVER. InnerException: ' + ` - 'Exception calling "SetOwner" with "1" argument(s): "Called mocked ' + ` - 'SetOwner() method without setting the right login. ' + ` - "Expected 'Zebes\SamusAran'. But was 'Elysia\Chozo'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state' { - It 'Should throw the correct error when the method SetOwner() was called' { - $mockInvalidOperationForSetOwnerMethod = $true - $mockExpectedDatabaseOwner = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - } - - $throwInvalidOperation = ('Failed to set owner named Zebes\SamusAran of the database ' + ` - 'named AdventureWorks on localhost\MSSQLSERVER. InnerException: ' + ` - 'Exception calling "SetOwner" with "1" argument(s): "Mock ' + ` - 'of method SetOwner() was called with invalid operation.') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Assert-VerifiableMock - } - } -} -finally -{ - Invoke-TestCleanup -} +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlDatabaseOwner' + +#region HEADER + +# Unit Test Template Version: 1.2.0 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +{ + & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) +} + +Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + +$TestEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:DSCModuleName ` + -DSCResourceName $script:DSCResourceName ` + -TestType Unit + +#endregion HEADER + +function Invoke-TestSetup { +} + +function Invoke-TestCleanup { + Restore-TestEnvironment -TestEnvironment $TestEnvironment +} + +# Begin Testing +try +{ + Invoke-TestSetup + + InModuleScope $script:DSCResourceName { + $mockSqlServerName = 'localhost' + $mockSqlServerInstanceName = 'MSSQLSERVER' + $mockSqlDatabaseName = 'AdventureWorks' + $mockSqlServerLogin = 'Zebes\SamusAran' + $mockSqlServerLoginType = 'WindowsUser' + $mockDatabaseOwner = 'Elysia\Chozo' + $mockInvalidOperationForSetOwnerMethod = $false + $mockExpectedDatabaseOwner = 'Elysia\Chozo' + + # Default parameters that are used for the It-blocks + $mockDefaultParameters = @{ + SQLInstanceName = $mockSqlServerInstanceName + SQLServer = $mockSqlServerName + } + + #region Function mocks + $mockConnectSQL = { + return @( + ( + New-Object Object | + Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSqlServerInstanceName -PassThru | + Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSqlServerName -PassThru | + Add-Member -MemberType ScriptProperty -Name Databases -Value { + return @{ + $mockSqlDatabaseName = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlDatabaseName -PassThru | + Add-Member -MemberType NoteProperty -Name Owner -Value $mockDatabaseOwner -PassThru | + Add-Member -MemberType ScriptMethod -Name SetOwner -Value { + if ($mockInvalidOperationForSetOwnerMethod) + { + throw 'Mock of method SetOwner() was called with invalid operation.' + } + + if ( $this.Owner -ne $mockExpectedDatabaseOwner ) + { + throw "Called mocked SetOwner() method without setting the right login. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedDatabaseOwner, $this.Owner + } + } -PassThru -Force + )) + } + } -PassThru -Force | + Add-Member -MemberType ScriptProperty -Name Logins -Value { + return @{ + $mockSqlServerLogin = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru + )) + } + } -PassThru -Force + ) + ) + } + #endregion + + Describe "MSFT_SqlDatabaseOwner\Get-TargetResource" -Tag 'Get'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + } + + Context 'When passing values to parameters and database name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = 'unknownDatabaseName' + Name = $mockSqlServerLogin + } + + $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is either in the desired state or not in the desired state' { + It 'Should not throw' { + $testParameters = $defaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + } + + $result = Get-TargetResource @testParameters + } + + It 'Should return the name of the owner from the get method' { + $result.Name | Should -Be $testParameters.Name + } + + It 'Should return the same values as passed as parameters' { + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.Database | Should -Be $testParameters.Database + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlDatabaseOwner\Test-TargetResource" -Tag 'Test'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + } + + Context 'When the system is not in the desired state' { + It 'Should return the state as false when desired login is not the database owner' { + $testParameters = $defaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $false + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is in the desired state' { + It 'Should return the state as true when desired login is the database owner' { + $mockDatabaseOwner = 'Zebes\SamusAran' + $mockSqlServerLogin = 'Zebes\SamusAran' + $testParameters = $defaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $true + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlDatabaseOwner\Set-TargetResource" -Tag 'Set'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + } + + Context 'When the system is not in the desired state and database name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = 'unknownDatabaseName' + Name = $mockSqlServerLogin + } + + $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is not in the desired state and login name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = 'John' + } + + $throwInvalidOperation = ("Login 'John' does not exist on " + ` + "SQL server 'localhost\MSSQLSERVER'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is not in the desired state' { + It 'Should not throw' { + $mockExpectedDatabaseOwner = $mockSqlServerLogin + $mockDatabaseOwner = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is not in the desired state' { + It 'Should throw the correct error when the method SetOwner() set the wrong login' { + $mockExpectedDatabaseOwner = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + } + + $throwInvalidOperation = ('Failed to set owner named Zebes\SamusAran of the database ' + ` + 'named AdventureWorks on localhost\MSSQLSERVER. InnerException: ' + ` + 'Exception calling "SetOwner" with "1" argument(s): "Called mocked ' + ` + 'SetOwner() method without setting the right login. ' + ` + "Expected 'Zebes\SamusAran'. But was 'Elysia\Chozo'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is not in the desired state' { + It 'Should throw the correct error when the method SetOwner() was called' { + $mockInvalidOperationForSetOwnerMethod = $true + $mockExpectedDatabaseOwner = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + } + + $throwInvalidOperation = ('Failed to set owner named Zebes\SamusAran of the database ' + ` + 'named AdventureWorks on localhost\MSSQLSERVER. InnerException: ' + ` + 'Exception calling "SetOwner" with "1" argument(s): "Mock ' + ` + 'of method SetOwner() was called with invalid operation.') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Assert-VerifiableMock + } + } +} +finally +{ + Invoke-TestCleanup +} diff --git a/Tests/Unit/MSFT_xSQLServerDatabasePermission.Tests.ps1 b/Tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_xSQLServerDatabasePermission.Tests.ps1 rename to Tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 index 5e8ca8aa9..e7919c6ce 100644 --- a/Tests/Unit/MSFT_xSQLServerDatabasePermission.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 @@ -1,860 +1,860 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerDatabasePermission' - -#region HEADER - -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit - -#endregion HEADER - -function Invoke-TestSetup { - # Loading mocked classes - Add-Type -Path (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\Unit\Stubs\SMO.cs') -} - -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment -} - -# Begin Testing -try -{ - Invoke-TestSetup - - InModuleScope $script:DSCResourceName { - $mockSqlServerName = 'localhost' - $mockSqlServerInstanceName = 'MSSQLSERVER' - $mockSqlDatabaseName = 'AdventureWorks' - $mockSqlServerLogin = 'Zebes\SamusAran' - $mockSqlServerLoginUnknown = 'Elysia\Chozo' - $mockLoginType = 'WindowsUser' - $mockInvalidOperationEnumDatabasePermissions = $false - $mockInvalidOperationForCreateMethod = $false - $mockExpectedSqlServerLogin = 'Zebes\SamusAran' - $mockSqlPermissionState = 'Grant' - - $mockSqlPermissionType01 = New-Object -TypeName Microsoft.SqlServer.Management.Smo.DatabasePermissionSet -ArgumentList ($true, $false) - $mockSqlPermissionType02 = New-Object -TypeName Microsoft.SqlServer.Management.Smo.DatabasePermissionSet -ArgumentList ($false, $true) - - $script:mockMethodGrantRan = $false - $script:mockMethodDenyRan = $false - $script:mockMethodRevokeRan = $false - $script:mockMethodCreateLoginRan = $false - - # Default parameters that are used for the It-blocks - $mockDefaultParameters = @{ - SQLInstanceName = $mockSqlServerInstanceName - SQLServer = $mockSqlServerName - } - - #region Function mocks - $mockConnectSQL = { - return @( - ( - New-Object Object | - Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSqlServerInstanceName -PassThru | - Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSqlServerName -PassThru | - Add-Member -MemberType ScriptProperty -Name Databases -Value { - return @{ - $mockSqlDatabaseName = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlDatabaseName -PassThru | - Add-Member -MemberType ScriptProperty -Name Users -Value { - return @{ - $mockSqlServerLogin = @(( - New-Object Object | - Add-Member -MemberType ScriptMethod -Name IsMember -Value { - return $true - } -PassThru - )) - } - } -PassThru | - Add-Member -MemberType ScriptMethod -Name EnumDatabasePermissions -Value { - param - ( - [Parameter()] - [System.String] - $SqlServerLogin - ) - if ($mockInvalidOperationEnumDatabasePermissions) - { - throw 'Mock EnumDatabasePermissions Method was called with invalid operation.' - } - - if ( $SqlServerLogin -eq $mockExpectedSqlServerLogin ) - { - $mockEnumDatabasePermissions = @() - $mockEnumDatabasePermissions += New-Object Object | - Add-Member -MemberType NoteProperty -Name PermissionType -Value $mockSqlPermissionType01 -PassThru | - Add-Member -MemberType NoteProperty -Name PermissionState -Value $mockSqlPermissionState -PassThru | - Add-Member -MemberType NoteProperty -Name Grantee -Value $mockExpectedSqlServerLogin -PassThru | - Add-Member -MemberType NoteProperty -Name GrantorType -Value 'User' -PassThru | - Add-Member -MemberType NoteProperty -Name ObjectClass -Value 'Database' -PassThru | - Add-Member -MemberType NoteProperty -Name ObjectName -Value $mockSqlDatabaseName -PassThru - $mockEnumDatabasePermissions += New-Object Object | - Add-Member -MemberType NoteProperty -Name PermissionType -Value $mockSqlPermissionType02 -PassThru | - Add-Member -MemberType NoteProperty -Name PermissionState -Value $mockSqlPermissionState -PassThru | - Add-Member -MemberType NoteProperty -Name Grantee -Value $mockExpectedSqlServerLogin -PassThru | - Add-Member -MemberType NoteProperty -Name GrantorType -Value 'User' -PassThru | - Add-Member -MemberType NoteProperty -Name ObjectClass -Value 'Database' -PassThru | - Add-Member -MemberType NoteProperty -Name ObjectName -Value $mockSqlDatabaseName -PassThru - - $mockEnumDatabasePermissions - } - else - { - return $null - } - } -PassThru | - Add-Member -MemberType ScriptMethod -Name Grant -Value { - param - ( - [Parameter()] - [System.Object] - $permissionSet, - - [Parameter()] - [System.String] - $SqlServerLogin - ) - - $script:mockMethodGrantRan = $true - - if ( $SqlServerLogin -ne $mockExpectedSqlServerLogin ) - { - throw "Called mocked Grant() method without setting the right login name. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedSqlServerLogin, $SqlServerLogin - } - } -PassThru | - Add-Member -MemberType ScriptMethod -Name Revoke -Value { - param - ( - [Parameter()] - [System.Object] - $permissionSet, - - [Parameter()] - [System.String] - $SqlServerLogin - ) - - $script:mockMethodRevokeRan = $true - - if ( $SqlServerLogin -ne $mockExpectedSqlServerLogin ) - { - throw "Called mocked Revoke() method without setting the right login name. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedSqlServerLogin, $SqlServerLogin - } - } -PassThru | - Add-Member -MemberType ScriptMethod -Name Deny -Value { - param - ( - [Parameter()] - [System.Object] - $permissionSet, - - [Parameter()] - [System.String] - $SqlServerLogin - ) - - $script:mockMethodDenyRan = $true - - if ( $SqlServerLogin -ne $mockExpectedSqlServerLogin ) - { - throw "Called mocked Deny() method without setting the right login name. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedSqlServerLogin, $SqlServerLogin - } - } -PassThru -Force - )) - } - } -PassThru -Force | - Add-Member -MemberType ScriptProperty -Name Logins -Value { - return @{ - $mockSqlServerLogin = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name LoginType -Value $mockLoginType -PassThru - )) - $mockSqlServerLoginUnknown= @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name LoginType -Value $mockLoginType -PassThru - )) - } - } -PassThru -Force - ) - ) - } - - $mockNewObjectUser = { - return @( - ( - New-Object Object | - Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlServerLoginUnknown -PassThru | - Add-Member -MemberType NoteProperty -Name Login -Value $mockSqlServerLoginUnknown -PassThru | - Add-Member -MemberType ScriptMethod -Name Create -Value { - $script:mockMethodCreateLoginRan = $true - - if ($mockInvalidOperationForCreateMethod) - { - throw 'Mock Create Method was called with invalid operation.' - } - if ( $this.Name -ne $mockExpectedSqlServerLogin ) - { - throw "Called mocked Create() method without adding the right user. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedSqlServerLogin, $this.Name - } - } -PassThru -Force - ) - ) - } - - #endregion - - Describe "MSFT_xSQLServerDatabasePermission\Get-TargetResource" -Tag 'Get'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When passing values to parameters and database name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = 'unknownDatabaseName' - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - } - - $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When passing values to parameters and login name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = 'unknownLoginName' - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - } - - $throwInvalidOperation = ("Login 'unknownLoginName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When passing values to parameters and database name and login name do exist' { - It 'Should throw the correct error with EnumDatabasePermissions method' { - $mockInvalidOperationEnumDatabasePermissions = $true - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - } - - $throwInvalidOperation = ('Failed to get permission for login named Zebes\SamusAran of ' + ` - 'the database named AdventureWorks on localhost\MSSQLSERVER.') - - { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state and ensure is set to Absent' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update','Select' ) - } - - It 'Should return the state as absent when the desired permission does not exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure is set to Absent' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - } - - It 'Should not return the state as absent when the desired permission does not exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Not -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - } - - It 'Should return the state as absent when the desired permission does not exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Present' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update','Select' ) - } - - It 'Should not return the state as absent when the desired permission does not exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Not -Be 'Present' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerDatabasePermission\Test-TargetResource" -Tag 'Test'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When passing values to parameters and database name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = 'unknownDatabaseName' - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When passing values to parameters and login name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = 'unknownLoginName' - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - $throwInvalidOperation = ("Login 'unknownLoginName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When passing values to parameters and database name and login name do exist' { - It 'Should throw the correct error with EnumDatabasePermissions method' { - $mockInvalidOperationEnumDatabasePermissions = $true - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - $throwInvalidOperation = ('Failed to get permission for login named Zebes\SamusAran of ' + ` - 'the database named AdventureWorks on localhost\MSSQLSERVER.') - - { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state and ensure is set to Absent' { - It 'Should return the state as true when the desired permission does not exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update','Select' ) - Ensure = 'Absent' - } - - Test-TargetResource @testParameters | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure is set to Absent' { - It 'Should return the state as false when the desired permission does not exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Absent' - } - - Test-TargetResource @testParameters | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure is set to Present' { - It 'Should return the state as false when the desired permission does not exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update','Select' ) - Ensure = 'Present' - } - - Test-TargetResource @testParameters | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state and ensure is set to Present' { - It 'Should return the state as true when the desired permission does exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - Test-TargetResource @testParameters | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerDatabasePermission\Set-TargetResource" -Tag 'Set'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - Mock -CommandName New-Object -MockWith $mockNewObjectUser -ParameterFilter { - $TypeName -eq 'Microsoft.SqlServer.Management.Smo.User' - } -Verifiable - - $script:mockMethodGrantRan = $false - $script:mockMethodDenyRan = $false - $script:mockMethodRevokeRan = $false - $script:mockMethodCreateLoginRan = $false - } - - Context 'When passing values to parameters and database name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = 'unknownDatabaseName' - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When passing values to parameters and login name does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = 'unknownLoginName' - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - $throwInvalidOperation = ("Login 'unknownLoginName' does not exist " + ` - "on SQL server 'localhost\MSSQLSERVER'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the login cannot be created' { - It 'Should throw the correct error' { - $mockInvalidOperationForCreateMethod = $true - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLoginUnknown - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - $throwInvalidOperation = ('Failed adding the login Elysia\Chozo ' + ` - 'as a user of the database AdventureWorks, ' + ` - 'on the instance localhost\MSSQLSERVER.') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - $script:mockMethodCreateLoginRan | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state' { - Context 'When the mock methods fail (testing the test)' { - BeforeAll { - $throwInvalidOperation = ('Failed to set permission for login named ' + ` - 'Zebes\SamusAran of the database named ' + ` - 'AdventureWorks on localhost\MSSQLSERVER.') - - $mockExpectedSqlServerLogin = $mockSqlServerLoginUnknown - } - - It 'Should throw the correct error when mock Grant() method is called' { - $testParameters = $mockDefaultParameters.Clone() - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - $script:mockMethodGrantRan | Should -Be $true - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $false - } - - It 'Should throw the correct error when mock Grant() method is called (for GrantWithGrant)' { - $testParameters = $mockDefaultParameters.Clone() - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'GrantWithGrant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - $script:mockMethodGrantRan | Should -Be $true - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $false - } - - - It 'Should throw the correct error when mock Deny() method is called' { - $testParameters = $mockDefaultParameters.Clone() - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Deny' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - $script:mockMethodGrantRan | Should -Be $false - $script:mockMethodDenyRan | Should -Be $true - $script:mockMethodRevokeRan | Should -Be $false - } - - It 'Should throw the correct error when mock Revoke() method is called' { - $testParameters = $mockDefaultParameters.Clone() - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Absent' - } - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - $script:mockMethodGrantRan | Should -Be $false - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $true - } - - It 'Should throw the correct error when mock Revoke() method is called' { - $testParameters = $mockDefaultParameters.Clone() - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'GrantWithGrant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Absent' - } - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - $script:mockMethodGrantRan | Should -Be $false - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $true - } - } - - Context 'When Ensure is set to Present' { - Context 'When the login does not exist' { - It 'Should create the login without throwing an error' { - $mockInvalidOperationForCreateMethod = $false - $mockExpectedSqlServerLogin = $mockSqlServerLoginUnknown - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLoginUnknown - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - $script:mockMethodCreateLoginRan | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - It 'Should call the method Grant() without throwing' { - $mockExpectedSqlServerLogin = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - $script:mockMethodGrantRan | Should -Be $true - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should call the method Grant() (WithGrant) without throwing' { - $mockExpectedSqlServerLogin = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'GrantWithGrant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - $script:mockMethodGrantRan | Should -Be $true - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should call the method Deny() without throwing' { - $mockExpectedSqlServerLogin = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Deny' - Permissions = @( 'Connect','Update' ) - Ensure = 'Present' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - $script:mockMethodGrantRan | Should -Be $false - $script:mockMethodDenyRan | Should -Be $true - $script:mockMethodRevokeRan | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When Ensure is set to Absent' { - It 'Should call the method Revoke() for permission state ''Grant'' without throwing' { - $mockExpectedSqlServerLogin = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Grant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Absent' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - $script:mockMethodGrantRan | Should -Be $false - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should call the method Revoke() for permission state ''GrantWithGrant'' without throwing' { - $mockExpectedSqlServerLogin = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'GrantWithGrant' - Permissions = @( 'Connect','Update' ) - Ensure = 'Absent' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - $script:mockMethodGrantRan | Should -Be $false - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should call the method Revoke() for permission state ''Deny'' without throwing' { - $mockExpectedSqlServerLogin = $mockSqlServerLogin - $testParameters = $mockDefaultParameters - $testParameters += @{ - Database = $mockSqlDatabaseName - Name = $mockSqlServerLogin - PermissionState = 'Deny' - Permissions = @( 'Connect','Update' ) - Ensure = 'Absent' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - $script:mockMethodGrantRan | Should -Be $false - $script:mockMethodDenyRan | Should -Be $false - $script:mockMethodRevokeRan | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - } - - Assert-VerifiableMock - } - } -} -finally -{ - Invoke-TestCleanup -}#endregion +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlDatabasePermission' + +#region HEADER + +# Unit Test Template Version: 1.2.0 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +{ + & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) +} + +Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + +$TestEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:DSCModuleName ` + -DSCResourceName $script:DSCResourceName ` + -TestType Unit + +#endregion HEADER + +function Invoke-TestSetup { + # Loading mocked classes + Add-Type -Path (Join-Path -Path $script:moduleRoot -ChildPath 'Tests\Unit\Stubs\SMO.cs') +} + +function Invoke-TestCleanup { + Restore-TestEnvironment -TestEnvironment $TestEnvironment +} + +# Begin Testing +try +{ + Invoke-TestSetup + + InModuleScope $script:DSCResourceName { + $mockSqlServerName = 'localhost' + $mockSqlServerInstanceName = 'MSSQLSERVER' + $mockSqlDatabaseName = 'AdventureWorks' + $mockSqlServerLogin = 'Zebes\SamusAran' + $mockSqlServerLoginUnknown = 'Elysia\Chozo' + $mockLoginType = 'WindowsUser' + $mockInvalidOperationEnumDatabasePermissions = $false + $mockInvalidOperationForCreateMethod = $false + $mockExpectedSqlServerLogin = 'Zebes\SamusAran' + $mockSqlPermissionState = 'Grant' + + $mockSqlPermissionType01 = New-Object -TypeName Microsoft.SqlServer.Management.Smo.DatabasePermissionSet -ArgumentList ($true, $false) + $mockSqlPermissionType02 = New-Object -TypeName Microsoft.SqlServer.Management.Smo.DatabasePermissionSet -ArgumentList ($false, $true) + + $script:mockMethodGrantRan = $false + $script:mockMethodDenyRan = $false + $script:mockMethodRevokeRan = $false + $script:mockMethodCreateLoginRan = $false + + # Default parameters that are used for the It-blocks + $mockDefaultParameters = @{ + SQLInstanceName = $mockSqlServerInstanceName + SQLServer = $mockSqlServerName + } + + #region Function mocks + $mockConnectSQL = { + return @( + ( + New-Object Object | + Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSqlServerInstanceName -PassThru | + Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSqlServerName -PassThru | + Add-Member -MemberType ScriptProperty -Name Databases -Value { + return @{ + $mockSqlDatabaseName = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlDatabaseName -PassThru | + Add-Member -MemberType ScriptProperty -Name Users -Value { + return @{ + $mockSqlServerLogin = @(( + New-Object Object | + Add-Member -MemberType ScriptMethod -Name IsMember -Value { + return $true + } -PassThru + )) + } + } -PassThru | + Add-Member -MemberType ScriptMethod -Name EnumDatabasePermissions -Value { + param + ( + [Parameter()] + [System.String] + $SqlServerLogin + ) + if ($mockInvalidOperationEnumDatabasePermissions) + { + throw 'Mock EnumDatabasePermissions Method was called with invalid operation.' + } + + if ( $SqlServerLogin -eq $mockExpectedSqlServerLogin ) + { + $mockEnumDatabasePermissions = @() + $mockEnumDatabasePermissions += New-Object Object | + Add-Member -MemberType NoteProperty -Name PermissionType -Value $mockSqlPermissionType01 -PassThru | + Add-Member -MemberType NoteProperty -Name PermissionState -Value $mockSqlPermissionState -PassThru | + Add-Member -MemberType NoteProperty -Name Grantee -Value $mockExpectedSqlServerLogin -PassThru | + Add-Member -MemberType NoteProperty -Name GrantorType -Value 'User' -PassThru | + Add-Member -MemberType NoteProperty -Name ObjectClass -Value 'Database' -PassThru | + Add-Member -MemberType NoteProperty -Name ObjectName -Value $mockSqlDatabaseName -PassThru + $mockEnumDatabasePermissions += New-Object Object | + Add-Member -MemberType NoteProperty -Name PermissionType -Value $mockSqlPermissionType02 -PassThru | + Add-Member -MemberType NoteProperty -Name PermissionState -Value $mockSqlPermissionState -PassThru | + Add-Member -MemberType NoteProperty -Name Grantee -Value $mockExpectedSqlServerLogin -PassThru | + Add-Member -MemberType NoteProperty -Name GrantorType -Value 'User' -PassThru | + Add-Member -MemberType NoteProperty -Name ObjectClass -Value 'Database' -PassThru | + Add-Member -MemberType NoteProperty -Name ObjectName -Value $mockSqlDatabaseName -PassThru + + $mockEnumDatabasePermissions + } + else + { + return $null + } + } -PassThru | + Add-Member -MemberType ScriptMethod -Name Grant -Value { + param + ( + [Parameter()] + [System.Object] + $permissionSet, + + [Parameter()] + [System.String] + $SqlServerLogin + ) + + $script:mockMethodGrantRan = $true + + if ( $SqlServerLogin -ne $mockExpectedSqlServerLogin ) + { + throw "Called mocked Grant() method without setting the right login name. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedSqlServerLogin, $SqlServerLogin + } + } -PassThru | + Add-Member -MemberType ScriptMethod -Name Revoke -Value { + param + ( + [Parameter()] + [System.Object] + $permissionSet, + + [Parameter()] + [System.String] + $SqlServerLogin + ) + + $script:mockMethodRevokeRan = $true + + if ( $SqlServerLogin -ne $mockExpectedSqlServerLogin ) + { + throw "Called mocked Revoke() method without setting the right login name. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedSqlServerLogin, $SqlServerLogin + } + } -PassThru | + Add-Member -MemberType ScriptMethod -Name Deny -Value { + param + ( + [Parameter()] + [System.Object] + $permissionSet, + + [Parameter()] + [System.String] + $SqlServerLogin + ) + + $script:mockMethodDenyRan = $true + + if ( $SqlServerLogin -ne $mockExpectedSqlServerLogin ) + { + throw "Called mocked Deny() method without setting the right login name. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedSqlServerLogin, $SqlServerLogin + } + } -PassThru -Force + )) + } + } -PassThru -Force | + Add-Member -MemberType ScriptProperty -Name Logins -Value { + return @{ + $mockSqlServerLogin = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name LoginType -Value $mockLoginType -PassThru + )) + $mockSqlServerLoginUnknown= @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name LoginType -Value $mockLoginType -PassThru + )) + } + } -PassThru -Force + ) + ) + } + + $mockNewObjectUser = { + return @( + ( + New-Object Object | + Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlServerLoginUnknown -PassThru | + Add-Member -MemberType NoteProperty -Name Login -Value $mockSqlServerLoginUnknown -PassThru | + Add-Member -MemberType ScriptMethod -Name Create -Value { + $script:mockMethodCreateLoginRan = $true + + if ($mockInvalidOperationForCreateMethod) + { + throw 'Mock Create Method was called with invalid operation.' + } + if ( $this.Name -ne $mockExpectedSqlServerLogin ) + { + throw "Called mocked Create() method without adding the right user. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedSqlServerLogin, $this.Name + } + } -PassThru -Force + ) + ) + } + + #endregion + + Describe "MSFT_SqlDatabasePermission\Get-TargetResource" -Tag 'Get'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + } + + Context 'When passing values to parameters and database name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = 'unknownDatabaseName' + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + } + + $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When passing values to parameters and login name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = 'unknownLoginName' + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + } + + $throwInvalidOperation = ("Login 'unknownLoginName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When passing values to parameters and database name and login name do exist' { + It 'Should throw the correct error with EnumDatabasePermissions method' { + $mockInvalidOperationEnumDatabasePermissions = $true + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + } + + $throwInvalidOperation = ('Failed to get permission for login named Zebes\SamusAran of ' + ` + 'the database named AdventureWorks on localhost\MSSQLSERVER.') + + { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state and ensure is set to Absent' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update','Select' ) + } + + It 'Should return the state as absent when the desired permission does not exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure is set to Absent' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + } + + It 'Should not return the state as absent when the desired permission does not exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Not -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + } + + It 'Should return the state as absent when the desired permission does not exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Present' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update','Select' ) + } + + It 'Should not return the state as absent when the desired permission does not exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Not -Be 'Present' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlDatabasePermission\Test-TargetResource" -Tag 'Test'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + } + + Context 'When passing values to parameters and database name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = 'unknownDatabaseName' + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When passing values to parameters and login name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = 'unknownLoginName' + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + $throwInvalidOperation = ("Login 'unknownLoginName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When passing values to parameters and database name and login name do exist' { + It 'Should throw the correct error with EnumDatabasePermissions method' { + $mockInvalidOperationEnumDatabasePermissions = $true + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + $throwInvalidOperation = ('Failed to get permission for login named Zebes\SamusAran of ' + ` + 'the database named AdventureWorks on localhost\MSSQLSERVER.') + + { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state and ensure is set to Absent' { + It 'Should return the state as true when the desired permission does not exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update','Select' ) + Ensure = 'Absent' + } + + Test-TargetResource @testParameters | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure is set to Absent' { + It 'Should return the state as false when the desired permission does not exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Absent' + } + + Test-TargetResource @testParameters | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure is set to Present' { + It 'Should return the state as false when the desired permission does not exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update','Select' ) + Ensure = 'Present' + } + + Test-TargetResource @testParameters | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state and ensure is set to Present' { + It 'Should return the state as true when the desired permission does exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + Test-TargetResource @testParameters | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlDatabasePermission\Set-TargetResource" -Tag 'Set'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + Mock -CommandName New-Object -MockWith $mockNewObjectUser -ParameterFilter { + $TypeName -eq 'Microsoft.SqlServer.Management.Smo.User' + } -Verifiable + + $script:mockMethodGrantRan = $false + $script:mockMethodDenyRan = $false + $script:mockMethodRevokeRan = $false + $script:mockMethodCreateLoginRan = $false + } + + Context 'When passing values to parameters and database name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = 'unknownDatabaseName' + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + $throwInvalidOperation = ("Database 'unknownDatabaseName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When passing values to parameters and login name does not exist' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = 'unknownLoginName' + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + $throwInvalidOperation = ("Login 'unknownLoginName' does not exist " + ` + "on SQL server 'localhost\MSSQLSERVER'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the login cannot be created' { + It 'Should throw the correct error' { + $mockInvalidOperationForCreateMethod = $true + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLoginUnknown + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + $throwInvalidOperation = ('Failed adding the login Elysia\Chozo ' + ` + 'as a user of the database AdventureWorks, ' + ` + 'on the instance localhost\MSSQLSERVER.') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + $script:mockMethodCreateLoginRan | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state' { + Context 'When the mock methods fail (testing the test)' { + BeforeAll { + $throwInvalidOperation = ('Failed to set permission for login named ' + ` + 'Zebes\SamusAran of the database named ' + ` + 'AdventureWorks on localhost\MSSQLSERVER.') + + $mockExpectedSqlServerLogin = $mockSqlServerLoginUnknown + } + + It 'Should throw the correct error when mock Grant() method is called' { + $testParameters = $mockDefaultParameters.Clone() + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + $script:mockMethodGrantRan | Should -Be $true + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $false + } + + It 'Should throw the correct error when mock Grant() method is called (for GrantWithGrant)' { + $testParameters = $mockDefaultParameters.Clone() + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'GrantWithGrant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + $script:mockMethodGrantRan | Should -Be $true + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $false + } + + + It 'Should throw the correct error when mock Deny() method is called' { + $testParameters = $mockDefaultParameters.Clone() + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Deny' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + $script:mockMethodGrantRan | Should -Be $false + $script:mockMethodDenyRan | Should -Be $true + $script:mockMethodRevokeRan | Should -Be $false + } + + It 'Should throw the correct error when mock Revoke() method is called' { + $testParameters = $mockDefaultParameters.Clone() + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Absent' + } + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + $script:mockMethodGrantRan | Should -Be $false + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $true + } + + It 'Should throw the correct error when mock Revoke() method is called' { + $testParameters = $mockDefaultParameters.Clone() + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'GrantWithGrant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Absent' + } + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + $script:mockMethodGrantRan | Should -Be $false + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $true + } + } + + Context 'When Ensure is set to Present' { + Context 'When the login does not exist' { + It 'Should create the login without throwing an error' { + $mockInvalidOperationForCreateMethod = $false + $mockExpectedSqlServerLogin = $mockSqlServerLoginUnknown + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLoginUnknown + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + $script:mockMethodCreateLoginRan | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + It 'Should call the method Grant() without throwing' { + $mockExpectedSqlServerLogin = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + $script:mockMethodGrantRan | Should -Be $true + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should call the method Grant() (WithGrant) without throwing' { + $mockExpectedSqlServerLogin = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'GrantWithGrant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + $script:mockMethodGrantRan | Should -Be $true + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should call the method Deny() without throwing' { + $mockExpectedSqlServerLogin = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Deny' + Permissions = @( 'Connect','Update' ) + Ensure = 'Present' + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + $script:mockMethodGrantRan | Should -Be $false + $script:mockMethodDenyRan | Should -Be $true + $script:mockMethodRevokeRan | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When Ensure is set to Absent' { + It 'Should call the method Revoke() for permission state ''Grant'' without throwing' { + $mockExpectedSqlServerLogin = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Grant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Absent' + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + $script:mockMethodGrantRan | Should -Be $false + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should call the method Revoke() for permission state ''GrantWithGrant'' without throwing' { + $mockExpectedSqlServerLogin = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'GrantWithGrant' + Permissions = @( 'Connect','Update' ) + Ensure = 'Absent' + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + $script:mockMethodGrantRan | Should -Be $false + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should call the method Revoke() for permission state ''Deny'' without throwing' { + $mockExpectedSqlServerLogin = $mockSqlServerLogin + $testParameters = $mockDefaultParameters + $testParameters += @{ + Database = $mockSqlDatabaseName + Name = $mockSqlServerLogin + PermissionState = 'Deny' + Permissions = @( 'Connect','Update' ) + Ensure = 'Absent' + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + $script:mockMethodGrantRan | Should -Be $false + $script:mockMethodDenyRan | Should -Be $false + $script:mockMethodRevokeRan | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + } + + Assert-VerifiableMock + } + } +} +finally +{ + Invoke-TestCleanup +}#endregion diff --git a/Tests/Unit/MSFT_xSQLServerDatabaseRecoveryModel.Tests.ps1 b/Tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_xSQLServerDatabaseRecoveryModel.Tests.ps1 rename to Tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 index 5c0e09105..fefffa66f 100644 --- a/Tests/Unit/MSFT_xSQLServerDatabaseRecoveryModel.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerDatabaseRecoveryModel' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlDatabaseRecoveryModel' #region HEADER @@ -77,7 +77,7 @@ try } #endregion - Describe "MSFT_xSQLServerDatabaseRecoveryModel\Get-TargetResource" -Tag 'Get'{ + Describe "MSFT_SqlDatabaseRecoveryModel\Get-TargetResource" -Tag 'Get'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable } @@ -150,7 +150,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerDatabaseRecoveryModel\Test-TargetResource" -Tag 'Test'{ + Describe "MSFT_SqlDatabaseRecoveryModel\Test-TargetResource" -Tag 'Test'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable } @@ -192,7 +192,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerDatabaseRecoveryModel\Set-TargetResource" -Tag 'Set'{ + Describe "MSFT_SqlDatabaseRecoveryModel\Set-TargetResource" -Tag 'Set'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable } diff --git a/Tests/Unit/MSFT_xSQLServerDatabaseRole.Tests.ps1 b/Tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerDatabaseRole.Tests.ps1 rename to Tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 index d8af7bd41..5d51c8c30 100644 --- a/Tests/Unit/MSFT_xSQLServerDatabaseRole.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerDatabaseRole' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlDatabaseRole' #region HEADER @@ -215,7 +215,7 @@ try } #endregion - Describe "MSFT_xSQLServerDatabaseRole\Get-TargetResource" -Tag 'Get'{ + Describe "MSFT_SqlDatabaseRole\Get-TargetResource" -Tag 'Get'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable } @@ -419,7 +419,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerDatabaseRole\Test-TargetResource" -Tag 'Test'{ + Describe "MSFT_SqlDatabaseRole\Test-TargetResource" -Tag 'Test'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable } @@ -541,7 +541,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerDatabaseRole\Set-TargetResource" -Tag 'Set'{ + Describe "MSFT_SqlDatabaseRole\Set-TargetResource" -Tag 'Set'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Mock -CommandName New-Object -MockWith $mockNewObjectUser -ParameterFilter { diff --git a/Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 b/Tests/Unit/MSFT_SqlRS.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 rename to Tests/Unit/MSFT_SqlRS.Tests.ps1 index 31bd51852..28d1e6715 100644 --- a/Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlRS.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerRSConfig' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlRS' #region HEADER @@ -190,7 +190,7 @@ try $Class -eq 'Win32_OperatingSystem' } - Describe "xSQLServerRSConfig\Get-TargetResource" -Tag 'Get' { + Describe "SqlRS\Get-TargetResource" -Tag 'Get' { BeforeAll { $mockDynamic_SqlBuildVersion = '13.0.4001.0' @@ -308,7 +308,7 @@ try Assert-VerifiableMock } - Describe "xSQLServerRSConfig\Set-TargetResource" -Tag 'Set' { + Describe "SqlRS\Set-TargetResource" -Tag 'Set' { BeforeAll { Mock -CommandName Import-SQLPSModule -Verifiable Mock -CommandName Invoke-Sqlcmd -Verifiable @@ -504,7 +504,7 @@ try Assert-VerifiableMock } - Describe "xSQLServerRSConfig\Test-TargetResource" -Tag 'Test' { + Describe "SqlRS\Test-TargetResource" -Tag 'Test' { Context 'When the system is not in the desired state' { Context 'When Reporting Services are not initialized' { BeforeAll { diff --git a/Tests/Unit/MSFT_xSQLServerScript.Tests.ps1 b/Tests/Unit/MSFT_SqlScript.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_xSQLServerScript.Tests.ps1 rename to Tests/Unit/MSFT_SqlScript.Tests.ps1 index 133e725ab..579c68c2b 100644 --- a/Tests/Unit/MSFT_xSQLServerScript.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlScript.Tests.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Automated unit test for MSFT_xSQLServerScript DSC Resource + Automated unit test for MSFT_SqlScript DSC Resource #> # Suppression of this PSSA rule allowed in tests. @@ -20,8 +20,8 @@ if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCR Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName 'xSQLServer' ` - -DSCResourceName 'MSFT_xSQLServerScript' ` + -DSCModuleName 'SqlServerDsc' ` + -DSCResourceName 'MSFT_SqlScript' ` -TestType Unit #endregion HEADER @@ -41,9 +41,9 @@ try { Invoke-TestSetup - InModuleScope 'MSFT_xSQLServerScript' { - $script:DSCModuleName = 'xSQLServer' - $resourceName = 'MSFT_xSQLServerScript' + InModuleScope 'MSFT_SqlScript' { + $script:DSCModuleName = 'SqlServerDsc' + $resourceName = 'MSFT_SqlScript' $testParameters = @{ ServerInstance = $env:COMPUTERNAME diff --git a/Tests/Unit/MSFT_xSQLServerConfiguration.Tests.ps1 b/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerConfiguration.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 index bf332cf84..416b75149 100644 --- a/Tests/Unit/MSFT_xSQLServerConfiguration.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerConfiguration' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerConfiguration' # Unit Test Template Version: 1.1.0 [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/Tests/Unit/MSFT_xSQLServerEndpoint.Tests.ps1 b/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_xSQLServerEndpoint.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 index 1ea60283a..38979bb97 100644 --- a/Tests/Unit/MSFT_xSQLServerEndpoint.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerEndpoint' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerEndpoint' #region HEADER @@ -141,7 +141,7 @@ try EndpointName = $mockEndpointName } - Describe 'MSFT_xSQLServerEndpoint\Get-TargetResource' -Tag 'Get' { + Describe 'MSFT_SqlServerEndpoint\Get-TargetResource' -Tag 'Get' { BeforeEach { $testParameters = $defaultParameters @@ -225,7 +225,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerEndpoint\Test-TargetResource' -Tag 'Test' { + Describe 'MSFT_SqlServerEndpoint\Test-TargetResource' -Tag 'Test' { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -335,7 +335,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerEndpoint\Set-TargetResource' -Tag 'Set' { + Describe 'MSFT_SqlServerEndpoint\Set-TargetResource' -Tag 'Set' { BeforeEach { $testParameters = $defaultParameters.Clone() diff --git a/Tests/Unit/MSFT_xSQLServerEndpointPermission.Tests.ps1 b/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_xSQLServerEndpointPermission.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 index bf6929a5c..334e2fe9a 100644 --- a/Tests/Unit/MSFT_xSQLServerEndpointPermission.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerEndpointPermission' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerEndpointPermission' #region HEADER @@ -91,7 +91,7 @@ try Principal = $mockPrincipal } - Describe 'MSFT_xSQLServerEndpointPermission\Get-TargetResource' -Tag 'Get' { + Describe 'MSFT_SqlServerEndpointPermission\Get-TargetResource' -Tag 'Get' { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -167,7 +167,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerEndpointPermission\Test-TargetResource' -Tag 'Test' { + Describe 'MSFT_SqlServerEndpointPermission\Test-TargetResource' -Tag 'Test' { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -229,7 +229,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerEndpointPermission\Set-TargetResource' -Tag 'Set' { + Describe 'MSFT_SqlServerEndpointPermission\Set-TargetResource' -Tag 'Set' { BeforeEach { $testParameters = $defaultParameters.Clone() diff --git a/Tests/Unit/MSFT_xSQLServerEndpointState.Tests.ps1 b/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_xSQLServerEndpointState.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 index 56cb6e342..becb6e759 100644 --- a/Tests/Unit/MSFT_xSQLServerEndpointState.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerEndpointState' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerEndpointState' #region HEADER @@ -68,7 +68,7 @@ try #endregion Pester Test Initialization - Describe 'MSFT_xSQLServerEndpointState\Get-TargetResource' -Tag Get { + Describe 'MSFT_SqlServerEndpointState\Get-TargetResource' -Tag Get { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -180,7 +180,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerEndpointState\Test-TargetResource' -Tag Test { + Describe 'MSFT_SqlServerEndpointState\Test-TargetResource' -Tag Test { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -258,7 +258,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerEndpointState\Set-TargetResource' -Tag Set { + Describe 'MSFT_SqlServerEndpointState\Set-TargetResource' -Tag Set { BeforeEach { $testParameters = $defaultParameters.Clone() diff --git a/Tests/Unit/MSFT_xSQLServerLogin.Tests.ps1 b/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerLogin.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 index a7b335256..656333473 100644 --- a/Tests/Unit/MSFT_xSQLServerLogin.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 @@ -2,8 +2,8 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param() -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerLogin' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerLogin' #region HEADER @@ -206,7 +206,7 @@ try #endregion Pester Test Initialization - Describe 'MSFT_xSQLServerLogin\Get-TargetResource' { + Describe 'MSFT_SqlServerLogin\Get-TargetResource' { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Context 'When the login is Absent' { @@ -278,7 +278,7 @@ try } } - Describe 'MSFT_xSQLServerLogin\Test-TargetResource' { + Describe 'MSFT_SqlServerLogin\Test-TargetResource' { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Context 'When the desired state is Absent' { @@ -504,7 +504,7 @@ try } } - Describe 'MSFT_xSQLServerLogin\Set-TargetResource' { + Describe 'MSFT_SqlServerLogin\Set-TargetResource' { Mock -CommandName New-TerminatingError -MockWith { $ErrorType } -ModuleName $script:DSCResourceName Mock -CommandName Update-SQLServerLogin -MockWith {} -ModuleName $script:DSCResourceName Mock -CommandName New-SQLServerLogin -MockWith {} -ModuleName $script:DSCResourceName @@ -906,7 +906,7 @@ try } } - Describe 'MSFT_xSQLServerLogin\Update-SQLServerLogin' { + Describe 'MSFT_SqlServerLogin\Update-SQLServerLogin' { Mock -CommandName New-TerminatingError -MockWith { $ErrorType } -ModuleName $script:DSCResourceName Context 'When the Login is altered' { @@ -927,7 +927,7 @@ try } } - Describe 'MSFT_xSQLServerLogin\New-SQLServerLogin' { + Describe 'MSFT_SqlServerLogin\New-SQLServerLogin' { Mock -CommandName New-TerminatingError -MockWith { $ErrorType } -ModuleName $script:DSCResourceName Context 'When the Login is created' { @@ -1002,7 +1002,7 @@ try } } - Describe 'MSFT_xSQLServerLogin\Remove-SQLServerLogin' { + Describe 'MSFT_SqlServerLogin\Remove-SQLServerLogin' { Mock -CommandName New-TerminatingError -MockWith { $ErrorType } -ModuleName $script:DSCResourceName Context 'When the Login is dropped' { @@ -1023,7 +1023,7 @@ try } } - Describe 'MSFT_xSQLServerLogin\Set-SQLServerLoginPassword' { + Describe 'MSFT_SqlServerLogin\Set-SQLServerLoginPassword' { Mock -CommandName New-TerminatingError -MockWith { $ErrorType } -ModuleName $script:DSCResourceName Context 'When the password is set on an existing login' { diff --git a/Tests/Unit/MSFT_xSQLServerMaxDop.Tests.ps1 b/Tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_xSQLServerMaxDop.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 index ca3092649..45f72e5dd 100644 --- a/Tests/Unit/MSFT_xSQLServerMaxDop.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerMaxDop' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerMaxDop' #region HEADER @@ -98,7 +98,7 @@ try #endregion - Describe "MSFT_xSQLServerMaxDop\Get-TargetResource" -Tag 'Get'{ + Describe "MSFT_SqlServerMaxDop\Get-TargetResource" -Tag 'Get'{ Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable Mock -CommandName Test-ActiveNode -MockWith { return $mockProcessOnlyOnActiveNode } -Verifiable @@ -128,7 +128,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerMaxDop\Test-TargetResource" -Tag 'Test'{ + Describe "MSFT_SqlServerMaxDop\Test-TargetResource" -Tag 'Test'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable @@ -378,7 +378,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerMaxDop\Set-TargetResource" -Tag 'Set'{ + Describe "MSFT_SqlServerMaxDop\Set-TargetResource" -Tag 'Set'{ BeforeEach { Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable diff --git a/Tests/Unit/MSFT_xSQLServerMemory.Tests.ps1 b/Tests/Unit/MSFT_SqlServerMemory.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_xSQLServerMemory.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerMemory.Tests.ps1 index e54c72156..e75a531d9 100644 --- a/Tests/Unit/MSFT_xSQLServerMemory.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerMemory.Tests.ps1 @@ -1,778 +1,778 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerMemory' - -#region HEADER - -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -# Loading mocked classes -Add-Type -Path ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SMO.cs ) - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit - -#endregion HEADER - -function Invoke-TestSetup { -} - -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment -} - -# Begin Testing -try -{ - Invoke-TestSetup - - InModuleScope $script:DSCResourceName { - $mockSQLServerName = 'localhost' - $mockSQLServerInstanceName = 'MSSQLSERVER' - $mockMinServerMemory = 2048 - $mockMaxServerMemory = 10300 - $mockPhysicalMemoryCapacity = 8589934592 - $mockExpectedMinMemoryForAlterMethod = 0 - $mockExpectedMaxMemoryForAlterMethod = 2147483647 - $mockTestActiveNode = $true - - # Default parameters that are used for the It-blocks - $mockDefaultParameters = @{ - SQLInstanceName = $mockSQLServerInstanceName - SQLServer = $mockSQLServerName - } - - #region Function mocks - - $mockConnectSQL = { - return @( - ( - # New-Object Object | - New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server | - Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSQLServerInstanceName -PassThru -Force | - Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSQLServerName -PassThru -Force | - Add-Member -MemberType ScriptProperty -Name Configuration -Value { - return @( ( New-Object Object | - Add-Member -MemberType ScriptProperty -Name MinServerMemory -Value { - return @( ( New-Object Object | - Add-Member -MemberType NoteProperty -Name DisplayName -Value 'min server memory (MB)' -PassThru | - Add-Member -MemberType NoteProperty -Name Description -Value 'Minimum size of server memory (MB)' -PassThru | - Add-Member -MemberType NoteProperty -Name RunValue -Value $mockMinServerMemory -PassThru | - Add-Member -MemberType NoteProperty -Name ConfigValue -Value $mockMinServerMemory -PassThru -Force - ) ) - } -PassThru | - Add-Member -MemberType ScriptProperty -Name MaxServerMemory -Value { - return @( ( New-Object Object | - Add-Member -MemberType NoteProperty -Name DisplayName -Value 'max server memory (MB)' -PassThru | - Add-Member -MemberType NoteProperty -Name Description -Value 'Maximum size of server memory (MB)' -PassThru | - Add-Member -MemberType NoteProperty -Name RunValue -Value $mockMaxServerMemory -PassThru | - Add-Member -MemberType NoteProperty -Name ConfigValue -Value $mockMaxServerMemory -PassThru -Force - ) ) - } -PassThru -Force - ) ) - } -PassThru -Force | - Add-Member -MemberType ScriptMethod -Name Alter -Value { - if ( $this.Configuration.MinServerMemory.ConfigValue -ne $mockExpectedMinMemoryForAlterMethod ) - { - throw "Called mocked Alter() method without setting the right minimum server memory. Expected '{0}'. But was '{1}'." -f $mockExpectedMinMemoryForAlterMethod, $this.Configuration.MinServerMemory.ConfigValue - } - if ( $this.Configuration.MaxServerMemory.ConfigValue -ne $mockExpectedMaxMemoryForAlterMethod ) - { - throw "Called mocked Alter() method without setting the right maximum server memory. Expected '{0}'. But was '{1}'." -f $mockExpectedMaxMemoryForAlterMethod, $this.Configuration.MaxServerMemory.ConfigValue - } - } -PassThru -Force - ) - ) - } - - #endregion - - Describe "MSFT_xSQLServerMemory\Get-TargetResource" -Tag 'Get'{ - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - Mock -CommandName Test-ActiveNode -MockWith { return $mockTestActiveNode } -Verifiable - - Context 'When the system is either in the desired state or not in the desired state' { - $testParameters = $mockDefaultParameters - - $result = Get-TargetResource @testParameters - - It 'Should return the current value for MinMemory' { - $result.MinMemory | Should -Be 2048 - } - - It 'Should return the current value for MaxMemory' { - $result.MaxMemory | Should -Be 10300 - } - - It 'Should return the same values as passed as parameters' { - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should call the mock function Test-ActiveNode' { - Assert-MockCalled Test-ActiveNode -Exactly -Times 1 -Scope Context - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerMemory\Test-TargetResource" -Tag 'Test'{ - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - - Mock -CommandName Get-CimInstance -MockWith { - throw 'Mocked function Get-CimInstance was called with the wrong set of parameter filters.' - } - - Mock -CommandName Get-CimInstance -MockWith { - $mockGetCimInstanceMem = @() - - $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ - Name = 'Physical Memory' - Tag = 'Physical Memory 0' - Capacity = 8589934592 - } - - $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ - Name = 'Physical Memory' - Tag = 'Physical Memory 1' - Capacity = 8589934592 - } - - $mockGetCimInstanceMem - } -ParameterFilter { $ClassName -eq 'Win32_PhysicalMemory' } -Verifiable - - Mock -CommandName Get-CimInstance -MockWith { - $mockGetCimInstanceProc = [PSCustomObject]@{ - NumberOfCores = 2 - } - - $mockGetCimInstanceProc - } -ParameterFilter { $ClassName -eq 'Win32_Processor' } -Verifiable - - Mock -CommandName Get-CimInstance -MockWith { - $mockGetCimInstanceOS = [PSCustomObject]@{ - OSArchitecture = '64-bit' - } - - $mockGetCimInstanceOS - } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable - - Mock -CommandName Test-ActiveNode -MockWith { return $mockTestActiveNode } -Verifiable - - Context 'When the system is not in the desired state and DynamicAlloc is set to false' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - MinMemory = 1024 - MaxMemory = 8192 - DynamicAlloc = $false - } - - It 'Should return the state as false when desired MinMemory and MaxMemory are not present' { - $result = Test-TargetResource @testParameters - $result | Should -Be $false - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the system is not in the desired state and DynamicAlloc is set to false' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - MaxMemory = 8192 - DynamicAlloc = $false - } - - It 'Should return the state as false when desired MaxMemory is not present' { - $result = Test-TargetResource @testParameters - $result | Should -Be $false - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the system is in the desired state and DynamicAlloc is set to false' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - MinMemory = 0 - MaxMemory = 10300 - DynamicAlloc = $false - } - - It 'Should return the state as true when desired MinMemory and MaxMemory are present' { - $result = Test-TargetResource @testParameters - $result | Should -Be $true - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the MaxMemory parameter is not null and DynamicAlloc is set to true' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - MaxMemory = 8192 - DynamicAlloc = $true - Ensure = 'Present' - } - - It 'Should throw the correct error' { - { Test-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must be null when DynamicAlloc is set to true.' - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the MaxMemory parameter is null and DynamicAlloc is set to false' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - DynamicAlloc = $false - Ensure = 'Present' - } - - It 'Should throw the correct error' { - {Test-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must not be null when DynamicAlloc is set to false.' - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the system is not in the desired state and DynamicAlloc is set to true' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - DynamicAlloc = $true - } - - It 'Should return the state as false when desired MinMemory and MaxMemory are not present' { - $result = Test-TargetResource @testParameters - $result | Should -Be $false - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_PhysicalMemory' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_Processor' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_operatingsystem' - } -Scope Context - } - } - - Context 'When the system is not in the desired state, DynamicAlloc is set to true and ProcessOnlyOnActiveNode is set to true' { - AfterAll { - $mockTestActiveNode = $true - } - - BeforeAll { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - DynamicAlloc = $true - ProcessOnlyOnActiveNode = $true - } - - $mockTestActiveNode = $false - } - - It 'Should return the state as true' { - $result = Test-TargetResource @testParameters - $result | Should -Be $true - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -ParameterFilter { - $ClassName -eq 'Win32_PhysicalMemory' - } -Scope Context - } - - It 'Should not call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -ParameterFilter { - $ClassName -eq 'Win32_Processor' - } -Scope Context - } - - It 'Should not call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -ParameterFilter { - $ClassName -eq 'Win32_operatingsystem' - } -Scope Context - } - } - - $mockMinServerMemory = 0 - $mockMaxServerMemory = 12083 - - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - - Context 'When the system is in the desired state and DynamicAlloc is set to true' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - DynamicAlloc = $true - } - - It 'Should return the state as true when desired MinMemory and MaxMemory are present' { - $result = Test-TargetResource @testParameters - $result | Should -Be $true - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_PhysicalMemory' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_Processor' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_operatingsystem' - } -Scope Context - } - } - - $mockMinServerMemory = 1024 - $mockMaxServerMemory = 8192 - - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - - Context 'When the system is not in the desired state and Ensure is set to Absent' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Absent' - } - - It 'Should return the state as false when desired MinMemory and MaxMemory are not set to the default values' { - $result = Test-TargetResource @testParameters - $result | Should -Be $false - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - $mockMinServerMemory = 0 - $mockMaxServerMemory = 2147483647 - - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - - Context 'When the system is in the desired state and Ensure is set to Absent' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Absent' - } - - It 'Should return the state as true when desired MinMemory and MaxMemory are present' { - $result = Test-TargetResource @testParameters - $result | Should -Be $true - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - # This is regression test for issue #576 - Context 'When the system is in the desired state and SQLServer is not set' { - $testParameters = $mockDefaultParameters - $testParameters.Remove('SQLServer') - $testParameters += @{ - Ensure = 'Absent' - } - - It 'Should not throw an error' { - { Test-TargetResource @testParameters } | Should -Not -Throw - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerMemory\Set-TargetResource" -Tag 'Set' { - $mockMinServerMemory = 0 - $mockMaxServerMemory = 2147483647 - - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - - Mock -CommandName Get-CimInstance -MockWith { - throw 'Mocked function Get-CimInstance was called with the wrong set of parameter filters.' - } - - Mock -CommandName Get-CimInstance -MockWith { - $mockGetCimInstanceMem = @() - - $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ - Name = 'Physical Memory' - Tag = 'Physical Memory 0' - Capacity = 17179869184 - } - - $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ - Name = 'Physical Memory' - Tag = 'Physical Memory 1' - Capacity = 17179869184 - } - - $mockGetCimInstanceMem - } -ParameterFilter { $ClassName -eq 'Win32_PhysicalMemory' } -Verifiable - - Mock -CommandName Get-CimInstance -MockWith { - $mockGetCimInstanceProc = [PSCustomObject]@{ - NumberOfCores = 6 - } - - $mockGetCimInstanceProc - } -ParameterFilter { $ClassName -eq 'Win32_Processor' } -Verifiable - - Mock -CommandName Get-CimInstance -MockWith { - $mockGetCimInstanceOS = [PSCustomObject]@{ - OSArchitecture = 'IA64-bit' - } - - $mockGetCimInstanceOS - } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable - - Context 'When the MaxMemory parameter is not null and DynamicAlloc is set to true' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - MaxMemory = 8192 - DynamicAlloc = $true - Ensure = 'Present' - } - - It 'Should throw the correct error' { - { Set-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must be null when DynamicAlloc is set to true.' - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the MaxMemory parameter is null and DynamicAlloc is set to false' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - DynamicAlloc = $false - Ensure = 'Present' - } - - It 'Should throw the correct error' { - { Set-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must not be null when DynamicAlloc is set to false.' - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the system is not in the desired state and Ensure is set to Absent' { - $mockExpectedMinMemoryForAlterMethod = 0 - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Absent' - } - - It 'Should set the MinMemory and MaxMemory to the default values' { - { Set-TargetResource @testParameters } | Should -Not -Throw - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the system is not in the desired state and Ensure is set to Present, and DynamicAlloc is set to false' { - $mockMinServerMemory = 1024 - $mockMaxServerMemory = 8192 - - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - - $mockExpectedMinMemoryForAlterMethod = 1024 - $mockExpectedMaxMemoryForAlterMethod = 8192 - $testParameters = $mockDefaultParameters - $testParameters += @{ - MaxMemory = 8192 - MinMemory = 1024 - DynamicAlloc = $false - Ensure = 'Present' - } - - It 'Should set the MinMemory and MaxMemory to the correct values when Ensure parameter is set to Present and DynamicAlloc is set to false' { - { Set-TargetResource @testParameters } | Should -Not -Throw - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Context 'When the system (OS IA64-bit) is not in the desired state and Ensure is set to Present, and DynamicAlloc is set to true' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - DynamicAlloc = $true - Ensure = 'Present' - MinMemory = 2048 - } - - It 'Should set the MaxMemory to the correct values when Ensure parameter is set to Present and DynamicAlloc is set to true' { - { Set-TargetResource @testParameters } | Should -Not -Throw - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_PhysicalMemory' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_Processor' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_operatingsystem' - } -Scope Context - } - } - - Mock -CommandName Get-CimInstance -MockWith { - $mockGetCimInstanceOS = [PSCustomObject]@{ - OSArchitecture = '32-bit' - } - - $mockGetCimInstanceOS - } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable - - Context 'When the system (OS 32-bit) is not in the desired state and Ensure is set to Present, and DynamicAlloc is set to true' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - DynamicAlloc = $true - Ensure = 'Present' - } - - It 'Should set the MaxMemory to the correct values when Ensure parameter is set to Present and DynamicAlloc is set to true' { - { Set-TargetResource @testParameters } | Should -Not -Throw - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_PhysicalMemory' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_Processor' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_operatingsystem' - } -Scope Context - } - } - - Mock -CommandName Connect-SQL -MockWith { - $mockSqlServerObject = [PSCustomObject]@{ - InstanceName = $mockSQLServerInstanceName - ComputerNamePhysicalNetBIOS = $mockSQLServerName - Configuration = @{ - MinServerMemory = @{ - DisplayName = 'min server memory (MB)' - Description = 'Minimum size of server memory (MB)' - RunValue = 0 - ConfigValue = 0 - } - MaxServerMemory = @{ - DisplayName = 'max server memory (MB)' - Description = 'Maximum size of server memory (MB)' - RunValue = 10300 - ConfigValue = 10300 - } - } - } - - # Add the Alter method - $mockSqlServerObject | Add-Member -MemberType ScriptMethod -Name Alter -Value { - throw 'Mock Alter Method was called with invalid operation.' - } - - $mockSqlServerObject - } -Verifiable - - Context 'When the desired MinMemory and MaxMemory fails to be set' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - MaxMemory = 8192 - MinMemory = 1024 - DynamicAlloc = $false - Ensure = 'Present' - } - - It 'Should throw the correct error' { - { Set-TargetResource @testParameters } | Should -Throw ("Failed to alter the server configuration memory for $($env:COMPUTERNAME)" + "\" +` - "$mockSQLServerInstanceName. InnerException: Exception calling ""Alter"" with ""0"" argument(s): " + ` - """Mock Alter Method was called with invalid operation.""") - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should not call the mock function Get-CimInstance' { - Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context - } - } - - Mock -CommandName Get-CimInstance -MockWith { - throw - } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable - - Context 'When the Get-SqlDscDynamicMaxMemory fails to calculate the MaxMemory' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - DynamicAlloc = $true - Ensure = 'Present' - } - - It 'Should throw the correct error' { - { Set-TargetResource @testParameters } | Should -Throw 'Failed to calculate dynamically the maximum memory.' - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_PhysicalMemory' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_Processor' - } -Scope Context - } - - It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { - Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { - $ClassName -eq 'Win32_operatingsystem' - } -Scope Context - } - } - - Assert-VerifiableMock - } - } -} -finally -{ - Invoke-TestCleanup -} +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerMemory' + +#region HEADER + +# Unit Test Template Version: 1.2.0 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +{ + & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) +} + +Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + +# Loading mocked classes +Add-Type -Path ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SMO.cs ) + +$TestEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:DSCModuleName ` + -DSCResourceName $script:DSCResourceName ` + -TestType Unit + +#endregion HEADER + +function Invoke-TestSetup { +} + +function Invoke-TestCleanup { + Restore-TestEnvironment -TestEnvironment $TestEnvironment +} + +# Begin Testing +try +{ + Invoke-TestSetup + + InModuleScope $script:DSCResourceName { + $mockSQLServerName = 'localhost' + $mockSQLServerInstanceName = 'MSSQLSERVER' + $mockMinServerMemory = 2048 + $mockMaxServerMemory = 10300 + $mockPhysicalMemoryCapacity = 8589934592 + $mockExpectedMinMemoryForAlterMethod = 0 + $mockExpectedMaxMemoryForAlterMethod = 2147483647 + $mockTestActiveNode = $true + + # Default parameters that are used for the It-blocks + $mockDefaultParameters = @{ + SQLInstanceName = $mockSQLServerInstanceName + SQLServer = $mockSQLServerName + } + + #region Function mocks + + $mockConnectSQL = { + return @( + ( + # New-Object Object | + New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server | + Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSQLServerInstanceName -PassThru -Force | + Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSQLServerName -PassThru -Force | + Add-Member -MemberType ScriptProperty -Name Configuration -Value { + return @( ( New-Object Object | + Add-Member -MemberType ScriptProperty -Name MinServerMemory -Value { + return @( ( New-Object Object | + Add-Member -MemberType NoteProperty -Name DisplayName -Value 'min server memory (MB)' -PassThru | + Add-Member -MemberType NoteProperty -Name Description -Value 'Minimum size of server memory (MB)' -PassThru | + Add-Member -MemberType NoteProperty -Name RunValue -Value $mockMinServerMemory -PassThru | + Add-Member -MemberType NoteProperty -Name ConfigValue -Value $mockMinServerMemory -PassThru -Force + ) ) + } -PassThru | + Add-Member -MemberType ScriptProperty -Name MaxServerMemory -Value { + return @( ( New-Object Object | + Add-Member -MemberType NoteProperty -Name DisplayName -Value 'max server memory (MB)' -PassThru | + Add-Member -MemberType NoteProperty -Name Description -Value 'Maximum size of server memory (MB)' -PassThru | + Add-Member -MemberType NoteProperty -Name RunValue -Value $mockMaxServerMemory -PassThru | + Add-Member -MemberType NoteProperty -Name ConfigValue -Value $mockMaxServerMemory -PassThru -Force + ) ) + } -PassThru -Force + ) ) + } -PassThru -Force | + Add-Member -MemberType ScriptMethod -Name Alter -Value { + if ( $this.Configuration.MinServerMemory.ConfigValue -ne $mockExpectedMinMemoryForAlterMethod ) + { + throw "Called mocked Alter() method without setting the right minimum server memory. Expected '{0}'. But was '{1}'." -f $mockExpectedMinMemoryForAlterMethod, $this.Configuration.MinServerMemory.ConfigValue + } + if ( $this.Configuration.MaxServerMemory.ConfigValue -ne $mockExpectedMaxMemoryForAlterMethod ) + { + throw "Called mocked Alter() method without setting the right maximum server memory. Expected '{0}'. But was '{1}'." -f $mockExpectedMaxMemoryForAlterMethod, $this.Configuration.MaxServerMemory.ConfigValue + } + } -PassThru -Force + ) + ) + } + + #endregion + + Describe "MSFT_SqlServerMemory\Get-TargetResource" -Tag 'Get'{ + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + Mock -CommandName Test-ActiveNode -MockWith { return $mockTestActiveNode } -Verifiable + + Context 'When the system is either in the desired state or not in the desired state' { + $testParameters = $mockDefaultParameters + + $result = Get-TargetResource @testParameters + + It 'Should return the current value for MinMemory' { + $result.MinMemory | Should -Be 2048 + } + + It 'Should return the current value for MaxMemory' { + $result.MaxMemory | Should -Be 10300 + } + + It 'Should return the same values as passed as parameters' { + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should call the mock function Test-ActiveNode' { + Assert-MockCalled Test-ActiveNode -Exactly -Times 1 -Scope Context + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlServerMemory\Test-TargetResource" -Tag 'Test'{ + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + + Mock -CommandName Get-CimInstance -MockWith { + throw 'Mocked function Get-CimInstance was called with the wrong set of parameter filters.' + } + + Mock -CommandName Get-CimInstance -MockWith { + $mockGetCimInstanceMem = @() + + $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ + Name = 'Physical Memory' + Tag = 'Physical Memory 0' + Capacity = 8589934592 + } + + $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ + Name = 'Physical Memory' + Tag = 'Physical Memory 1' + Capacity = 8589934592 + } + + $mockGetCimInstanceMem + } -ParameterFilter { $ClassName -eq 'Win32_PhysicalMemory' } -Verifiable + + Mock -CommandName Get-CimInstance -MockWith { + $mockGetCimInstanceProc = [PSCustomObject]@{ + NumberOfCores = 2 + } + + $mockGetCimInstanceProc + } -ParameterFilter { $ClassName -eq 'Win32_Processor' } -Verifiable + + Mock -CommandName Get-CimInstance -MockWith { + $mockGetCimInstanceOS = [PSCustomObject]@{ + OSArchitecture = '64-bit' + } + + $mockGetCimInstanceOS + } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable + + Mock -CommandName Test-ActiveNode -MockWith { return $mockTestActiveNode } -Verifiable + + Context 'When the system is not in the desired state and DynamicAlloc is set to false' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + MinMemory = 1024 + MaxMemory = 8192 + DynamicAlloc = $false + } + + It 'Should return the state as false when desired MinMemory and MaxMemory are not present' { + $result = Test-TargetResource @testParameters + $result | Should -Be $false + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the system is not in the desired state and DynamicAlloc is set to false' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + MaxMemory = 8192 + DynamicAlloc = $false + } + + It 'Should return the state as false when desired MaxMemory is not present' { + $result = Test-TargetResource @testParameters + $result | Should -Be $false + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the system is in the desired state and DynamicAlloc is set to false' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + MinMemory = 0 + MaxMemory = 10300 + DynamicAlloc = $false + } + + It 'Should return the state as true when desired MinMemory and MaxMemory are present' { + $result = Test-TargetResource @testParameters + $result | Should -Be $true + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the MaxMemory parameter is not null and DynamicAlloc is set to true' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + MaxMemory = 8192 + DynamicAlloc = $true + Ensure = 'Present' + } + + It 'Should throw the correct error' { + { Test-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must be null when DynamicAlloc is set to true.' + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the MaxMemory parameter is null and DynamicAlloc is set to false' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + DynamicAlloc = $false + Ensure = 'Present' + } + + It 'Should throw the correct error' { + {Test-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must not be null when DynamicAlloc is set to false.' + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the system is not in the desired state and DynamicAlloc is set to true' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + DynamicAlloc = $true + } + + It 'Should return the state as false when desired MinMemory and MaxMemory are not present' { + $result = Test-TargetResource @testParameters + $result | Should -Be $false + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_PhysicalMemory' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_Processor' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_operatingsystem' + } -Scope Context + } + } + + Context 'When the system is not in the desired state, DynamicAlloc is set to true and ProcessOnlyOnActiveNode is set to true' { + AfterAll { + $mockTestActiveNode = $true + } + + BeforeAll { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + DynamicAlloc = $true + ProcessOnlyOnActiveNode = $true + } + + $mockTestActiveNode = $false + } + + It 'Should return the state as true' { + $result = Test-TargetResource @testParameters + $result | Should -Be $true + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -ParameterFilter { + $ClassName -eq 'Win32_PhysicalMemory' + } -Scope Context + } + + It 'Should not call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -ParameterFilter { + $ClassName -eq 'Win32_Processor' + } -Scope Context + } + + It 'Should not call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -ParameterFilter { + $ClassName -eq 'Win32_operatingsystem' + } -Scope Context + } + } + + $mockMinServerMemory = 0 + $mockMaxServerMemory = 12083 + + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + + Context 'When the system is in the desired state and DynamicAlloc is set to true' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + DynamicAlloc = $true + } + + It 'Should return the state as true when desired MinMemory and MaxMemory are present' { + $result = Test-TargetResource @testParameters + $result | Should -Be $true + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_PhysicalMemory' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_Processor' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_operatingsystem' + } -Scope Context + } + } + + $mockMinServerMemory = 1024 + $mockMaxServerMemory = 8192 + + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + + Context 'When the system is not in the desired state and Ensure is set to Absent' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Absent' + } + + It 'Should return the state as false when desired MinMemory and MaxMemory are not set to the default values' { + $result = Test-TargetResource @testParameters + $result | Should -Be $false + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + $mockMinServerMemory = 0 + $mockMaxServerMemory = 2147483647 + + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + + Context 'When the system is in the desired state and Ensure is set to Absent' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Absent' + } + + It 'Should return the state as true when desired MinMemory and MaxMemory are present' { + $result = Test-TargetResource @testParameters + $result | Should -Be $true + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + # This is regression test for issue #576 + Context 'When the system is in the desired state and SQLServer is not set' { + $testParameters = $mockDefaultParameters + $testParameters.Remove('SQLServer') + $testParameters += @{ + Ensure = 'Absent' + } + + It 'Should not throw an error' { + { Test-TargetResource @testParameters } | Should -Not -Throw + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlServerMemory\Set-TargetResource" -Tag 'Set' { + $mockMinServerMemory = 0 + $mockMaxServerMemory = 2147483647 + + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + + Mock -CommandName Get-CimInstance -MockWith { + throw 'Mocked function Get-CimInstance was called with the wrong set of parameter filters.' + } + + Mock -CommandName Get-CimInstance -MockWith { + $mockGetCimInstanceMem = @() + + $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ + Name = 'Physical Memory' + Tag = 'Physical Memory 0' + Capacity = 17179869184 + } + + $mockGetCimInstanceMem += New-Object -TypeName psobject -Property @{ + Name = 'Physical Memory' + Tag = 'Physical Memory 1' + Capacity = 17179869184 + } + + $mockGetCimInstanceMem + } -ParameterFilter { $ClassName -eq 'Win32_PhysicalMemory' } -Verifiable + + Mock -CommandName Get-CimInstance -MockWith { + $mockGetCimInstanceProc = [PSCustomObject]@{ + NumberOfCores = 6 + } + + $mockGetCimInstanceProc + } -ParameterFilter { $ClassName -eq 'Win32_Processor' } -Verifiable + + Mock -CommandName Get-CimInstance -MockWith { + $mockGetCimInstanceOS = [PSCustomObject]@{ + OSArchitecture = 'IA64-bit' + } + + $mockGetCimInstanceOS + } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable + + Context 'When the MaxMemory parameter is not null and DynamicAlloc is set to true' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + MaxMemory = 8192 + DynamicAlloc = $true + Ensure = 'Present' + } + + It 'Should throw the correct error' { + { Set-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must be null when DynamicAlloc is set to true.' + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the MaxMemory parameter is null and DynamicAlloc is set to false' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + DynamicAlloc = $false + Ensure = 'Present' + } + + It 'Should throw the correct error' { + { Set-TargetResource @testParameters } | Should -Throw 'The parameter MaxMemory must not be null when DynamicAlloc is set to false.' + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the system is not in the desired state and Ensure is set to Absent' { + $mockExpectedMinMemoryForAlterMethod = 0 + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Absent' + } + + It 'Should set the MinMemory and MaxMemory to the default values' { + { Set-TargetResource @testParameters } | Should -Not -Throw + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the system is not in the desired state and Ensure is set to Present, and DynamicAlloc is set to false' { + $mockMinServerMemory = 1024 + $mockMaxServerMemory = 8192 + + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + + $mockExpectedMinMemoryForAlterMethod = 1024 + $mockExpectedMaxMemoryForAlterMethod = 8192 + $testParameters = $mockDefaultParameters + $testParameters += @{ + MaxMemory = 8192 + MinMemory = 1024 + DynamicAlloc = $false + Ensure = 'Present' + } + + It 'Should set the MinMemory and MaxMemory to the correct values when Ensure parameter is set to Present and DynamicAlloc is set to false' { + { Set-TargetResource @testParameters } | Should -Not -Throw + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Context 'When the system (OS IA64-bit) is not in the desired state and Ensure is set to Present, and DynamicAlloc is set to true' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + DynamicAlloc = $true + Ensure = 'Present' + MinMemory = 2048 + } + + It 'Should set the MaxMemory to the correct values when Ensure parameter is set to Present and DynamicAlloc is set to true' { + { Set-TargetResource @testParameters } | Should -Not -Throw + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_PhysicalMemory' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_Processor' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_operatingsystem' + } -Scope Context + } + } + + Mock -CommandName Get-CimInstance -MockWith { + $mockGetCimInstanceOS = [PSCustomObject]@{ + OSArchitecture = '32-bit' + } + + $mockGetCimInstanceOS + } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable + + Context 'When the system (OS 32-bit) is not in the desired state and Ensure is set to Present, and DynamicAlloc is set to true' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + DynamicAlloc = $true + Ensure = 'Present' + } + + It 'Should set the MaxMemory to the correct values when Ensure parameter is set to Present and DynamicAlloc is set to true' { + { Set-TargetResource @testParameters } | Should -Not -Throw + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_PhysicalMemory' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_Processor' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_operatingsystem' + } -Scope Context + } + } + + Mock -CommandName Connect-SQL -MockWith { + $mockSqlServerObject = [PSCustomObject]@{ + InstanceName = $mockSQLServerInstanceName + ComputerNamePhysicalNetBIOS = $mockSQLServerName + Configuration = @{ + MinServerMemory = @{ + DisplayName = 'min server memory (MB)' + Description = 'Minimum size of server memory (MB)' + RunValue = 0 + ConfigValue = 0 + } + MaxServerMemory = @{ + DisplayName = 'max server memory (MB)' + Description = 'Maximum size of server memory (MB)' + RunValue = 10300 + ConfigValue = 10300 + } + } + } + + # Add the Alter method + $mockSqlServerObject | Add-Member -MemberType ScriptMethod -Name Alter -Value { + throw 'Mock Alter Method was called with invalid operation.' + } + + $mockSqlServerObject + } -Verifiable + + Context 'When the desired MinMemory and MaxMemory fails to be set' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + MaxMemory = 8192 + MinMemory = 1024 + DynamicAlloc = $false + Ensure = 'Present' + } + + It 'Should throw the correct error' { + { Set-TargetResource @testParameters } | Should -Throw ("Failed to alter the server configuration memory for $($env:COMPUTERNAME)" + "\" +` + "$mockSQLServerInstanceName. InnerException: Exception calling ""Alter"" with ""0"" argument(s): " + ` + """Mock Alter Method was called with invalid operation.""") + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should not call the mock function Get-CimInstance' { + Assert-MockCalled Get-CimInstance -Exactly -Times 0 -Scope Context + } + } + + Mock -CommandName Get-CimInstance -MockWith { + throw + } -ParameterFilter { $ClassName -eq 'Win32_operatingsystem' } -Verifiable + + Context 'When the Get-SqlDscDynamicMaxMemory fails to calculate the MaxMemory' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + DynamicAlloc = $true + Ensure = 'Present' + } + + It 'Should throw the correct error' { + { Set-TargetResource @testParameters } | Should -Throw 'Failed to calculate dynamically the maximum memory.' + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_PhysicalMemory' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_PhysicalMemory' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_Processor' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_Processor' + } -Scope Context + } + + It 'Should call the mock function Get-CimInstance with ClassName equal to Win32_operatingsystem' { + Assert-MockCalled Get-CimInstance -Exactly -Times 1 -ParameterFilter { + $ClassName -eq 'Win32_operatingsystem' + } -Scope Context + } + } + + Assert-VerifiableMock + } + } +} +finally +{ + Invoke-TestCleanup +} diff --git a/Tests/Unit/MSFT_xSQLServerNetwork.Tests.ps1 b/Tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_xSQLServerNetwork.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 index 4629075d7..6a73a71b6 100644 --- a/Tests/Unit/MSFT_xSQLServerNetwork.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerNetwork' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerNetwork' #region HEADER @@ -99,7 +99,7 @@ try ProtocolName = $mockTcpProtocolName } - Describe "MSFT_xSQLServerNetwork\Get-TargetResource" -Tag 'Get'{ + Describe "MSFT_SqlServerNetwork\Get-TargetResource" -Tag 'Get'{ BeforeEach { $testParameters = $mockDefaultParameters.Clone() @@ -141,7 +141,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerNetwork\Test-TargetResource" -Tag 'Test'{ + Describe "MSFT_SqlServerNetwork\Test-TargetResource" -Tag 'Test'{ BeforeEach { $testParameters = $mockDefaultParameters.Clone() @@ -309,7 +309,7 @@ try Assert-VerifiableMock } - Describe "MSFT_xSQLServerNetwork\Set-TargetResource" -Tag 'Set'{ + Describe "MSFT_SqlServerNetwork\Set-TargetResource" -Tag 'Set'{ BeforeEach { $testParameters = $mockDefaultParameters.Clone() diff --git a/Tests/Unit/MSFT_xSQLServerPermission.Tests.ps1 b/Tests/Unit/MSFT_SqlServerPermission.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_xSQLServerPermission.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerPermission.Tests.ps1 index 217a58e10..92b966b03 100644 --- a/Tests/Unit/MSFT_xSQLServerPermission.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerPermission.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerPermission' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerPermission' #region HEADER @@ -50,7 +50,7 @@ try Permission = $mockPermission } - Describe 'MSFT_xSQLServerPermission\Get-TargetResource' { + Describe 'MSFT_SqlServerPermission\Get-TargetResource' { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -172,7 +172,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerPermission\Test-TargetResource' { + Describe 'MSFT_SqlServerPermission\Test-TargetResource' { BeforeEach { $testParameters = $defaultParameters.Clone() @@ -240,7 +240,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xSQLServerPermission\Set-TargetResource' { + Describe 'MSFT_SqlServerPermission\Set-TargetResource' { BeforeEach { $testParameters = $defaultParameters.Clone() diff --git a/Tests/Unit/MSFT_xSQLServerReplication.Tests.ps1 b/Tests/Unit/MSFT_SqlServerReplication.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerReplication.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerReplication.Tests.ps1 index 0f844c6c9..a67868933 100644 --- a/Tests/Unit/MSFT_xSQLServerReplication.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerReplication.Tests.ps1 @@ -1,8 +1,8 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] param () -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerReplication' +$script:DSCModuleName = 'SqlServerDSC' +$script:DSCResourceName = 'MSFT_SqlServerReplication' #region HEADER # Unit Test Template Version: 1.1.0 diff --git a/Tests/Unit/MSFT_xSQLServerRole.Tests.ps1 b/Tests/Unit/MSFT_SqlServerRole.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_xSQLServerRole.Tests.ps1 rename to Tests/Unit/MSFT_SqlServerRole.Tests.ps1 index 5b9fba14d..e1436e1a2 100644 --- a/Tests/Unit/MSFT_xSQLServerRole.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServerRole.Tests.ps1 @@ -1,1008 +1,1008 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerRole' - -#region HEADER - -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit - -#endregion HEADER - -function Invoke-TestSetup { -} - -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment -} - -# Begin Testing -try -{ - Invoke-TestSetup - - InModuleScope $script:DSCResourceName { - $mockSqlServerName = 'localhost' - $mockSqlServerInstanceName = 'MSSQLSERVER' - $mockSqlServerRole = 'AdminSqlforBI' - $mockSqlServerLoginOne = 'CONTOSO\John' - $mockSqlServerLoginTwo = 'CONTOSO\Kelly' - $mockSqlServerLoginTree = 'CONTOSO\Lucy' - $mockSqlServerLoginFour = 'CONTOSO\Steve' - $mockEnumMemberNames = @($mockSqlServerLoginOne,$mockSqlServerLoginTwo) - $mockSqlServerLoginType = 'WindowsUser' - $mockExpectedServerRoleToDrop = 'ServerRoleToDrop' - - # Default parameters that are used for the It-blocks - $mockDefaultParameters = @{ - SQLInstanceName = $mockSqlServerInstanceName - SQLServer = $mockSqlServerName - } - - #region Function mocks - - $mockConnectSQL = { - return @( - ( - New-Object Object | - Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSqlServerInstanceName -PassThru | - Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSqlServerName -PassThru | - Add-Member -MemberType ScriptProperty -Name Roles -Value { - return @{ - $mockSqlServerRole = ( New-Object Object | - Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlServerRole -PassThru | - Add-Member -MemberType ScriptMethod -Name EnumMemberNames -Value { - if ($mockInvalidOperationForEnumMethod) - { - throw 'Mock EnumMemberNames Method was called with invalid operation.' - } - else - { - $mockEnumMemberNames - } - } -PassThru | - Add-Member -MemberType ScriptMethod -Name Drop -Value { - if ($mockInvalidOperationForDropMethod) - { - throw 'Mock Drop Method was called with invalid operation.' - } - - if ( $this.Name -ne $mockExpectedServerRoleToDrop ) - { - throw "Called mocked drop() method without dropping the right server role. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedServerRoleToDrop, $this.Name - } - } -PassThru | - Add-Member -MemberType ScriptMethod -Name AddMember -Value { - if ($mockInvalidOperationForAddMemberMethod) - { - throw 'Mock AddMember Method was called with invalid operation.' - } - - if ( $mockSqlServerLoginToAdd -ne $mockExpectedMemberToAdd ) - { - throw "Called mocked AddMember() method without adding the right login. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedMemberToAdd, $mockSqlServerLoginToAdd - } - } -PassThru | - Add-Member -MemberType ScriptMethod -Name DropMember -Value { - if ($mockInvalidOperationForDropMemberMethod) - { - throw 'Mock DropMember Method was called with invalid operation.' - } - - if ( $mockSqlServerLoginToDrop -ne $mockExpectedMemberToDrop ) - { - throw "Called mocked DropMember() method without removing the right login. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedMemberToDrop, $mockSqlServerLoginToDrop - } - } -PassThru - ) - } - } -PassThru | - Add-Member -MemberType ScriptProperty -Name Logins -Value { - return @{ - $mockSqlServerLoginOne = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru - )) - $mockSqlServerLoginTwo = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru - )) - $mockSqlServerLoginTree = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru - )) - $mockSqlServerLoginFour = @(( - New-Object Object | - Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru - )) - } - } -PassThru -Force - ) - ) - } - - $mockNewObjectServerRole = { - return @( - ( - New-Object Object | - Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlServerRoleAdd -PassThru | - Add-Member -MemberType ScriptMethod -Name Create -Value { - if ($mockInvalidOperationForCreateMethod) - { - throw 'Mock Create Method was called with invalid operation.' - } - - if ( $this.Name -ne $mockExpectedServerRoleToCreate ) - { - throw "Called mocked Create() method without adding the right server role. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedServerRoleToCreate, $this.Name - } - } -PassThru -Force - ) - ) - } - #endregion - - Describe "MSFT_xSQLServerRole\Get-TargetResource" -Tag 'Get'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When the system is in the desired state and ensure is set to Absent' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = 'UnknownRoleName' - } - - It 'Should return the state as absent when the role does not exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the members as null' { - $result = Get-TargetResource @testParameters - $result.Members | Should -Be $null - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure is set to Absent' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - } - - It 'Should not return the state as absent when the role exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Not -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the members as not null' { - $result = Get-TargetResource @testParameters - $result.Members | Should -Not -Be $null - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - # Regression test for issue #790 - It 'Should return the members as string array' { - $result = Get-TargetResource @testParameters - ($result.Members -is [String[]]) | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When passing values to parameters and throwing with EnumMemberNames method' { - It 'Should throw the correct error' { - $mockInvalidOperationForEnumMethod = $true - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - } - - $throwInvalidOperation = ('Failed to enumerate members of the server role ' + ` - 'named AdminSqlforBI on localhost\MSSQLSERVER. InnerException: ' + ` - 'Exception calling "EnumMemberNames" with "0" argument(s): ' + ` - '"Mock EnumMemberNames Method was called with invalid operation."') - - { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is in the desired state, parameter Members is assigned a value and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - Members = $mockEnumMemberNames - } - - It 'Should return the state as present when the members are correct' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Present' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the members as not null' { - $result = Get-TargetResource @testParameters - $result.Members | Should -Be $testParameters.Members - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - # Regression test for issue #790 - It 'Should return the members as string array' { - $result = Get-TargetResource @testParameters - ($result.Members -is [String[]]) | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state, parameter MembersToInclude is assigned a value and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - MembersToInclude = $mockSqlServerLoginTwo - } - - It 'Should return the state as present when the correct members exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Present' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the members as not null' { - $result = Get-TargetResource @testParameters - $result.Members | Should -Not -Be $null - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - # Regression test for issue #790 - It 'Should return the members as string array' { - $result = Get-TargetResource @testParameters - ($result.Members -is [String[]]) | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - $result.MembersToInclude | Should -Be $testParameters.MembersToInclude - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state, parameter MembersToExclude is assigned a value and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - MembersToExclude = $mockSqlServerLoginTree - } - - It 'Should return the state as present when the members does not exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Present' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - $result.MembersToExclude | Should -Be $testParameters.MembersToExclude - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state, parameter MembersToInclude is assigned a value, parameter Members is assigned a value, and ensure is set to Present' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - Members = $mockEnumMemberNames - MembersToInclude = $mockSqlServerLoginTree - } - - $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` - 'MembersToExclude must not be set, or be set ' + ` - 'to $null, when parameter Members are used.') - - { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - - } - - Context 'When the system is not in the desired state, parameter MembersToExclude is assigned a value, parameter Members is assigned a value, and ensure is set to Present' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - Members = $mockEnumMemberNames - MembersToExclude = $mockSqlServerLoginTree - } - - $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` - 'MembersToExclude must not be set, or be set ' + ` - 'to $null, when parameter Members are used.') - - { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = 'UnknownRoleName' - } - - It 'Should return the state as absent when the role does not exist' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the members as null' { - $result = Get-TargetResource @testParameters - $result.Members | Should -Be $null - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state, parameter Members is assigned a value and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - Members = @($mockSqlServerLoginOne,$mockSqlServerLoginTree) - } - - It 'Should return the state as absent when the members in the role are wrong' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the members as not null' { - $result = Get-TargetResource @testParameters - $result.Members | Should -Not -Be $null - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - # Regression test for issue #790 - It 'Should return the members as string array' { - $result = Get-TargetResource @testParameters - ($result.Members -is [String[]]) | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state, parameter MembersToInclude is assigned a value and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - MembersToInclude = $mockSqlServerLoginTree - } - - It 'Should return the state as absent when the members in the role are missing' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the members as not null' { - $result = Get-TargetResource @testParameters - $result.Members | Should -Not -Be $null - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - # Regression test for issue #790 - It 'Should return the members as string array' { - $result = Get-TargetResource @testParameters - ($result.Members -is [String[]]) | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - $result.MembersToInclude | Should -Be $testParameters.MembersToInclude - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state, parameter MembersToExclude is assigned a value and ensure is set to Present' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - ServerRoleName = $mockSqlServerRole - MembersToExclude = $mockSqlServerLoginTwo - } - - It 'Should return the state as absent when the members in the role are present' { - $result = Get-TargetResource @testParameters - $result.Ensure | Should -Be 'Absent' - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should return the same values as passed as parameters' { - $result = Get-TargetResource @testParameters - $result.SQLServer | Should -Be $testParameters.SQLServer - $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName - $result.ServerRoleName | Should -Be $testParameters.ServerRoleName - $result.MembersToExclude | Should -Be $testParameters.MembersToExclude - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerRole\Test-TargetResource" -Tag 'Test'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When the system is not in the desired state and ensure is set to Absent' { - It 'Should return false when desired server role exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Absent' - ServerRoleName = $mockSqlServerRole - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state and ensure is set to Absent' { - It 'Should return true when desired server role does not exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Absent' - ServerRoleName = 'newServerRole' - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is in the desired state and ensure is set to Present' { - It 'Should return true when desired server role exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure parameter is set to Present' { - It 'Should return false when desired members are not in desired server role' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - Members = @($mockSqlServerLoginTree,$mockSqlServerLoginFour) - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When both the parameters Members and MembersToInclude are assigned a value and ensure is set to Present' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - Members = $mockEnumMemberNames - MembersToInclude = $mockSqlServerLoginTree - } - - $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` - 'MembersToExclude must not be set, or be set ' + ` - 'to $null, when parameter Members are used.') - - { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should return true when desired server role exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToInclude = $mockSqlServerLoginTwo - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should return false when desired server role does not exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToInclude = $mockSqlServerLoginTree - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When both the parameters Members and MembersToExclude are assigned a value and ensure is set to Present' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - Members = $mockEnumMemberNames - MembersToExclude = $mockSqlServerLoginTwo - } - - $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` - 'MembersToExclude must not be set, or be set ' + ` - 'to $null, when parameter Members are used.') - - { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should return true when desired server role does not exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToExclude = $mockSqlServerLoginTree - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $true - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should return false when desired server role exist' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToExclude = $mockSqlServerLoginTwo - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $false - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Assert-VerifiableMock - } - - Describe "MSFT_xSQLServerRole\Set-TargetResource" -Tag 'Set'{ - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - Mock -CommandName New-Object -MockWith $mockNewObjectServerRole -ParameterFilter { - $TypeName -eq 'Microsoft.SqlServer.Management.Smo.ServerRole' - } - } - - Context 'When the system is not in the desired state and ensure is set to Absent' { - It 'Should not throw when calling the drop method' { - $mockSqlServerRole = 'ServerRoleToDrop' - $mockExpectedServerRoleToDrop = 'ServerRoleToDrop' - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Absent' - ServerRoleName = $mockSqlServerRole - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure is set to Absent' { - It 'Should throw the correct error when calling the drop method' { - $mockInvalidOperationForDropMethod = $true - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Absent' - ServerRoleName = $mockSqlServerRole - } - - $throwInvalidOperation = ('Failed to drop the server role named AdminSqlforBI on ' + ` - 'localhost\MSSQLSERVER. InnerException: Exception calling ' + ` - '"Drop" with "0" argument(s): "Mock Drop Method ' + ` - 'was called with invalid operation."') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When the system is not in the desired state and ensure is set to Present' { - It 'Should not throw when calling the create method' { - $mockSqlServerRoleAdd = 'ServerRoleToAdd' - $mockExpectedServerRoleToCreate = 'ServerRoleToAdd' - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRoleAdd - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should call the mock function New-Object with TypeName equal to Microsoft.SqlServer.Management.Smo.ServerRole' { - Assert-MockCalled New-Object -Exactly -Times 1 -ParameterFilter { - $TypeName -eq 'Microsoft.SqlServer.Management.Smo.ServerRole' - } -Scope Context - } - } - - Context 'When the system is not in the desired state and ensure is set to Present' { - It 'Should throw the correct error when calling the create method' { - $mockSqlServerRoleAdd = 'ServerRoleToAdd' - $mockExpectedServerRoleToCreate = 'ServerRoleToAdd' - $mockInvalidOperationForCreateMethod = $true - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRoleAdd - } - - $throwInvalidOperation = ('Failed to create the server role named ServerRoleToAdd on ' + ` - 'localhost\MSSQLSERVER. InnerException: Exception calling ' + ` - '"Create" with "0" argument(s): "Mock Create Method ' + ` - 'was called with invalid operation."') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - - It 'Should call the mock function New-Object with TypeName equal to Microsoft.SqlServer.Management.Smo.ServerRole' { - Assert-MockCalled New-Object -Exactly -Times 1 -ParameterFilter { - $TypeName -eq 'Microsoft.SqlServer.Management.Smo.ServerRole' - } -Scope Context - } - } - - Context 'When both the parameters Members and MembersToInclude are assigned a value and ensure is set to Present' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - Members = $mockEnumMemberNames - MembersToInclude = $mockSqlServerLoginTree - } - - $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` - 'MembersToExclude must not be set, or be set ' + ` - 'to $null, when parameter Members are used.') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When both the parameters Members and MembersToExclude are assigned a value and ensure is set to Present' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - Members = $mockEnumMemberNames - MembersToExclude = $mockSqlServerLoginTwo - } - - $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` - 'MembersToExclude must not be set, or be set ' + ` - 'to $null, when parameter Members are used.') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should not thrown when calling the AddMember method' { - $mockExpectedMemberToAdd = $mockSqlServerLoginTree - $mockSqlServerLoginToAdd = $mockSqlServerLoginTree - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToInclude = $mockSqlServerLoginTree - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should throw the correct error when calling the AddMember method' { - $mockInvalidOperationForAddMemberMethod = $true - $mockExpectedMemberToAdd = $mockSqlServerLoginTree - $mockSqlServerLoginToAdd = $mockSqlServerLoginTree - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToInclude = $mockSqlServerLoginTree - } - - $throwInvalidOperation = ('Failed to add member CONTOSO\Lucy to the server role named AdminSqlforBI ' + ` - 'on localhost\MSSQLSERVER. InnerException: Exception calling "AddMember" ' + ` - 'with "1" argument(s): "Mock AddMember Method was called with invalid operation."') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should throw the correct error when login does not exist' { - $mockExpectedMemberToAdd = $mockSqlServerLoginTree - $mockSqlServerLoginToAdd = $mockSqlServerLoginTree - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToInclude = 'KingJulian' - } - - $throwInvalidOperation = ("Login 'KingJulian' does not exist on SQL server 'localhost\MSSQLSERVER'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should not throw when calling the DropMember method' { - $mockExpectedMemberToAdd = $mockSqlServerLoginTwo - $mockSqlServerLoginToAdd = $mockSqlServerLoginTwo - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToExclude = $mockSqlServerLoginTwo - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should throw the correct error when calling the DropMember method' { - $mockInvalidOperationForDropMemberMethod = $true - $mockExpectedMemberToDrop = $mockSqlServerLoginTwo - $mockSqlServerLoginToDrop = $mockSqlServerLoginTwo - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToExclude = $mockSqlServerLoginTwo - } - - $throwInvalidOperation = ('Failed to drop member CONTOSO\Kelly to the server role named AdminSqlforBI ' + ` - 'on localhost\MSSQLSERVER. InnerException: Exception calling "DropMember" ' + ` - 'with "1" argument(s): "Mock DropMember Method was called with invalid operation."') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { - It 'Should throw the correct error when login does not exist' { - $mockEnumMemberNames = @('KingJulian',$mockSqlServerLoginOne,$mockSqlServerLoginTwo) - $mockExpectedMemberToAdd = $mockSqlServerLoginTree - $mockSqlServerLoginToAdd = $mockSqlServerLoginTree - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - MembersToExclude = 'KingJulian' - } - - $throwInvalidOperation = ("Login 'KingJulian' does not exist on SQL server 'localhost\MSSQLSERVER'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When parameter Members is assigned a value and ensure is set to Present' { - It 'Should throw the correct error when login does not exist' { - $mockExpectedMemberToAdd = $mockSqlServerLoginTree - $mockSqlServerLoginToAdd = $mockSqlServerLoginTree - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - Members = @('KingJulian',$mockSqlServerLoginOne,$mockSqlServerLoginTree) - } - - $throwInvalidOperation = ("Login 'KingJulian' does not exist on SQL server 'localhost\MSSQLSERVER'.") - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Context 'When Members parameter is set and ensure parameter is set to Present' { - It 'Should not throw when calling both the AddMember and DropMember methods' { - $mockExpectedMemberToAdd = $mockSqlServerLoginTree - $mockSqlServerLoginToAdd = $mockSqlServerLoginTree - $mockExpectedMemberToDrop = $mockSqlServerLoginTwo - $mockSqlServerLoginToDrop = $mockSqlServerLoginTwo - $testParameters = $mockDefaultParameters - $testParameters += @{ - Ensure = 'Present' - ServerRoleName = $mockSqlServerRole - Members = @($mockSqlServerLoginOne,$mockSqlServerLoginTree) - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - - Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It - } - } - - Assert-VerifiableMock - } - } -} -finally -{ - Invoke-TestCleanup -} - +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServerRole' + +#region HEADER + +# Unit Test Template Version: 1.2.0 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +{ + & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) +} + +Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force + +$TestEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:DSCModuleName ` + -DSCResourceName $script:DSCResourceName ` + -TestType Unit + +#endregion HEADER + +function Invoke-TestSetup { +} + +function Invoke-TestCleanup { + Restore-TestEnvironment -TestEnvironment $TestEnvironment +} + +# Begin Testing +try +{ + Invoke-TestSetup + + InModuleScope $script:DSCResourceName { + $mockSqlServerName = 'localhost' + $mockSqlServerInstanceName = 'MSSQLSERVER' + $mockSqlServerRole = 'AdminSqlforBI' + $mockSqlServerLoginOne = 'CONTOSO\John' + $mockSqlServerLoginTwo = 'CONTOSO\Kelly' + $mockSqlServerLoginTree = 'CONTOSO\Lucy' + $mockSqlServerLoginFour = 'CONTOSO\Steve' + $mockEnumMemberNames = @($mockSqlServerLoginOne,$mockSqlServerLoginTwo) + $mockSqlServerLoginType = 'WindowsUser' + $mockExpectedServerRoleToDrop = 'ServerRoleToDrop' + + # Default parameters that are used for the It-blocks + $mockDefaultParameters = @{ + SQLInstanceName = $mockSqlServerInstanceName + SQLServer = $mockSqlServerName + } + + #region Function mocks + + $mockConnectSQL = { + return @( + ( + New-Object Object | + Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockSqlServerInstanceName -PassThru | + Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockSqlServerName -PassThru | + Add-Member -MemberType ScriptProperty -Name Roles -Value { + return @{ + $mockSqlServerRole = ( New-Object Object | + Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlServerRole -PassThru | + Add-Member -MemberType ScriptMethod -Name EnumMemberNames -Value { + if ($mockInvalidOperationForEnumMethod) + { + throw 'Mock EnumMemberNames Method was called with invalid operation.' + } + else + { + $mockEnumMemberNames + } + } -PassThru | + Add-Member -MemberType ScriptMethod -Name Drop -Value { + if ($mockInvalidOperationForDropMethod) + { + throw 'Mock Drop Method was called with invalid operation.' + } + + if ( $this.Name -ne $mockExpectedServerRoleToDrop ) + { + throw "Called mocked drop() method without dropping the right server role. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedServerRoleToDrop, $this.Name + } + } -PassThru | + Add-Member -MemberType ScriptMethod -Name AddMember -Value { + if ($mockInvalidOperationForAddMemberMethod) + { + throw 'Mock AddMember Method was called with invalid operation.' + } + + if ( $mockSqlServerLoginToAdd -ne $mockExpectedMemberToAdd ) + { + throw "Called mocked AddMember() method without adding the right login. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedMemberToAdd, $mockSqlServerLoginToAdd + } + } -PassThru | + Add-Member -MemberType ScriptMethod -Name DropMember -Value { + if ($mockInvalidOperationForDropMemberMethod) + { + throw 'Mock DropMember Method was called with invalid operation.' + } + + if ( $mockSqlServerLoginToDrop -ne $mockExpectedMemberToDrop ) + { + throw "Called mocked DropMember() method without removing the right login. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedMemberToDrop, $mockSqlServerLoginToDrop + } + } -PassThru + ) + } + } -PassThru | + Add-Member -MemberType ScriptProperty -Name Logins -Value { + return @{ + $mockSqlServerLoginOne = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru + )) + $mockSqlServerLoginTwo = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru + )) + $mockSqlServerLoginTree = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru + )) + $mockSqlServerLoginFour = @(( + New-Object Object | + Add-Member -MemberType NoteProperty -Name LoginType -Value $mockSqlServerLoginType -PassThru + )) + } + } -PassThru -Force + ) + ) + } + + $mockNewObjectServerRole = { + return @( + ( + New-Object Object | + Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlServerRoleAdd -PassThru | + Add-Member -MemberType ScriptMethod -Name Create -Value { + if ($mockInvalidOperationForCreateMethod) + { + throw 'Mock Create Method was called with invalid operation.' + } + + if ( $this.Name -ne $mockExpectedServerRoleToCreate ) + { + throw "Called mocked Create() method without adding the right server role. Expected '{0}'. But was '{1}'." ` + -f $mockExpectedServerRoleToCreate, $this.Name + } + } -PassThru -Force + ) + ) + } + #endregion + + Describe "MSFT_SqlServerRole\Get-TargetResource" -Tag 'Get'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + } + + Context 'When the system is in the desired state and ensure is set to Absent' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = 'UnknownRoleName' + } + + It 'Should return the state as absent when the role does not exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the members as null' { + $result = Get-TargetResource @testParameters + $result.Members | Should -Be $null + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure is set to Absent' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + } + + It 'Should not return the state as absent when the role exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Not -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the members as not null' { + $result = Get-TargetResource @testParameters + $result.Members | Should -Not -Be $null + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When passing values to parameters and throwing with EnumMemberNames method' { + It 'Should throw the correct error' { + $mockInvalidOperationForEnumMethod = $true + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + } + + $throwInvalidOperation = ('Failed to enumerate members of the server role ' + ` + 'named AdminSqlforBI on localhost\MSSQLSERVER. InnerException: ' + ` + 'Exception calling "EnumMemberNames" with "0" argument(s): ' + ` + '"Mock EnumMemberNames Method was called with invalid operation."') + + { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is in the desired state, parameter Members is assigned a value and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + Members = $mockEnumMemberNames + } + + It 'Should return the state as present when the members are correct' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Present' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the members as not null' { + $result = Get-TargetResource @testParameters + $result.Members | Should -Be $testParameters.Members + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state, parameter MembersToInclude is assigned a value and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + MembersToInclude = $mockSqlServerLoginTwo + } + + It 'Should return the state as present when the correct members exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Present' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the members as not null' { + $result = Get-TargetResource @testParameters + $result.Members | Should -Not -Be $null + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + $result.MembersToInclude | Should -Be $testParameters.MembersToInclude + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state, parameter MembersToExclude is assigned a value and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + MembersToExclude = $mockSqlServerLoginTree + } + + It 'Should return the state as present when the members does not exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Present' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + $result.MembersToExclude | Should -Be $testParameters.MembersToExclude + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state, parameter MembersToInclude is assigned a value, parameter Members is assigned a value, and ensure is set to Present' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + Members = $mockEnumMemberNames + MembersToInclude = $mockSqlServerLoginTree + } + + $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` + 'MembersToExclude must not be set, or be set ' + ` + 'to $null, when parameter Members are used.') + + { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + + } + + Context 'When the system is not in the desired state, parameter MembersToExclude is assigned a value, parameter Members is assigned a value, and ensure is set to Present' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + Members = $mockEnumMemberNames + MembersToExclude = $mockSqlServerLoginTree + } + + $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` + 'MembersToExclude must not be set, or be set ' + ` + 'to $null, when parameter Members are used.') + + { Get-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + } + + It 'Should call the mock function Connect-SQL' { + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope Context + } + } + + Context 'When the system is not in the desired state and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = 'UnknownRoleName' + } + + It 'Should return the state as absent when the role does not exist' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the members as null' { + $result = Get-TargetResource @testParameters + $result.Members | Should -Be $null + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state, parameter Members is assigned a value and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + Members = @($mockSqlServerLoginOne,$mockSqlServerLoginTree) + } + + It 'Should return the state as absent when the members in the role are wrong' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the members as not null' { + $result = Get-TargetResource @testParameters + $result.Members | Should -Not -Be $null + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state, parameter MembersToInclude is assigned a value and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + MembersToInclude = $mockSqlServerLoginTree + } + + It 'Should return the state as absent when the members in the role are missing' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the members as not null' { + $result = Get-TargetResource @testParameters + $result.Members | Should -Not -Be $null + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + $result.MembersToInclude | Should -Be $testParameters.MembersToInclude + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state, parameter MembersToExclude is assigned a value and ensure is set to Present' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + ServerRoleName = $mockSqlServerRole + MembersToExclude = $mockSqlServerLoginTwo + } + + It 'Should return the state as absent when the members in the role are present' { + $result = Get-TargetResource @testParameters + $result.Ensure | Should -Be 'Absent' + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should return the same values as passed as parameters' { + $result = Get-TargetResource @testParameters + $result.SQLServer | Should -Be $testParameters.SQLServer + $result.SQLInstanceName | Should -Be $testParameters.SQLInstanceName + $result.ServerRoleName | Should -Be $testParameters.ServerRoleName + $result.MembersToExclude | Should -Be $testParameters.MembersToExclude + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlServerRole\Test-TargetResource" -Tag 'Test'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + } + + Context 'When the system is not in the desired state and ensure is set to Absent' { + It 'Should return false when desired server role exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Absent' + ServerRoleName = $mockSqlServerRole + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state and ensure is set to Absent' { + It 'Should return true when desired server role does not exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Absent' + ServerRoleName = 'newServerRole' + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is in the desired state and ensure is set to Present' { + It 'Should return true when desired server role exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure parameter is set to Present' { + It 'Should return false when desired members are not in desired server role' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + Members = @($mockSqlServerLoginTree,$mockSqlServerLoginFour) + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When both the parameters Members and MembersToInclude are assigned a value and ensure is set to Present' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + Members = $mockEnumMemberNames + MembersToInclude = $mockSqlServerLoginTree + } + + $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` + 'MembersToExclude must not be set, or be set ' + ` + 'to $null, when parameter Members are used.') + + { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should return true when desired server role exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToInclude = $mockSqlServerLoginTwo + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should return false when desired server role does not exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToInclude = $mockSqlServerLoginTree + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When both the parameters Members and MembersToExclude are assigned a value and ensure is set to Present' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + Members = $mockEnumMemberNames + MembersToExclude = $mockSqlServerLoginTwo + } + + $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` + 'MembersToExclude must not be set, or be set ' + ` + 'to $null, when parameter Members are used.') + + { Test-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should return true when desired server role does not exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToExclude = $mockSqlServerLoginTree + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should return false when desired server role exist' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToExclude = $mockSqlServerLoginTwo + } + + $result = Test-TargetResource @testParameters + $result | Should -Be $false + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Assert-VerifiableMock + } + + Describe "MSFT_SqlServerRole\Set-TargetResource" -Tag 'Set'{ + BeforeEach { + Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable + Mock -CommandName New-Object -MockWith $mockNewObjectServerRole -ParameterFilter { + $TypeName -eq 'Microsoft.SqlServer.Management.Smo.ServerRole' + } + } + + Context 'When the system is not in the desired state and ensure is set to Absent' { + It 'Should not throw when calling the drop method' { + $mockSqlServerRole = 'ServerRoleToDrop' + $mockExpectedServerRoleToDrop = 'ServerRoleToDrop' + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Absent' + ServerRoleName = $mockSqlServerRole + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure is set to Absent' { + It 'Should throw the correct error when calling the drop method' { + $mockInvalidOperationForDropMethod = $true + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Absent' + ServerRoleName = $mockSqlServerRole + } + + $throwInvalidOperation = ('Failed to drop the server role named AdminSqlforBI on ' + ` + 'localhost\MSSQLSERVER. InnerException: Exception calling ' + ` + '"Drop" with "0" argument(s): "Mock Drop Method ' + ` + 'was called with invalid operation."') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When the system is not in the desired state and ensure is set to Present' { + It 'Should not throw when calling the create method' { + $mockSqlServerRoleAdd = 'ServerRoleToAdd' + $mockExpectedServerRoleToCreate = 'ServerRoleToAdd' + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRoleAdd + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should call the mock function New-Object with TypeName equal to Microsoft.SqlServer.Management.Smo.ServerRole' { + Assert-MockCalled New-Object -Exactly -Times 1 -ParameterFilter { + $TypeName -eq 'Microsoft.SqlServer.Management.Smo.ServerRole' + } -Scope Context + } + } + + Context 'When the system is not in the desired state and ensure is set to Present' { + It 'Should throw the correct error when calling the create method' { + $mockSqlServerRoleAdd = 'ServerRoleToAdd' + $mockExpectedServerRoleToCreate = 'ServerRoleToAdd' + $mockInvalidOperationForCreateMethod = $true + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRoleAdd + } + + $throwInvalidOperation = ('Failed to create the server role named ServerRoleToAdd on ' + ` + 'localhost\MSSQLSERVER. InnerException: Exception calling ' + ` + '"Create" with "0" argument(s): "Mock Create Method ' + ` + 'was called with invalid operation."') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + + It 'Should call the mock function New-Object with TypeName equal to Microsoft.SqlServer.Management.Smo.ServerRole' { + Assert-MockCalled New-Object -Exactly -Times 1 -ParameterFilter { + $TypeName -eq 'Microsoft.SqlServer.Management.Smo.ServerRole' + } -Scope Context + } + } + + Context 'When both the parameters Members and MembersToInclude are assigned a value and ensure is set to Present' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + Members = $mockEnumMemberNames + MembersToInclude = $mockSqlServerLoginTree + } + + $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` + 'MembersToExclude must not be set, or be set ' + ` + 'to $null, when parameter Members are used.') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When both the parameters Members and MembersToExclude are assigned a value and ensure is set to Present' { + It 'Should throw the correct error' { + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + Members = $mockEnumMemberNames + MembersToExclude = $mockSqlServerLoginTwo + } + + $throwInvalidOperation = ('The parameter MembersToInclude and/or ' + ` + 'MembersToExclude must not be set, or be set ' + ` + 'to $null, when parameter Members are used.') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should not thrown when calling the AddMember method' { + $mockExpectedMemberToAdd = $mockSqlServerLoginTree + $mockSqlServerLoginToAdd = $mockSqlServerLoginTree + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToInclude = $mockSqlServerLoginTree + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should throw the correct error when calling the AddMember method' { + $mockInvalidOperationForAddMemberMethod = $true + $mockExpectedMemberToAdd = $mockSqlServerLoginTree + $mockSqlServerLoginToAdd = $mockSqlServerLoginTree + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToInclude = $mockSqlServerLoginTree + } + + $throwInvalidOperation = ('Failed to add member CONTOSO\Lucy to the server role named AdminSqlforBI ' + ` + 'on localhost\MSSQLSERVER. InnerException: Exception calling "AddMember" ' + ` + 'with "1" argument(s): "Mock AddMember Method was called with invalid operation."') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToInclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should throw the correct error when login does not exist' { + $mockExpectedMemberToAdd = $mockSqlServerLoginTree + $mockSqlServerLoginToAdd = $mockSqlServerLoginTree + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToInclude = 'KingJulian' + } + + $throwInvalidOperation = ("Login 'KingJulian' does not exist on SQL server 'localhost\MSSQLSERVER'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should not throw when calling the DropMember method' { + $mockExpectedMemberToAdd = $mockSqlServerLoginTwo + $mockSqlServerLoginToAdd = $mockSqlServerLoginTwo + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToExclude = $mockSqlServerLoginTwo + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should throw the correct error when calling the DropMember method' { + $mockInvalidOperationForDropMemberMethod = $true + $mockExpectedMemberToDrop = $mockSqlServerLoginTwo + $mockSqlServerLoginToDrop = $mockSqlServerLoginTwo + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToExclude = $mockSqlServerLoginTwo + } + + $throwInvalidOperation = ('Failed to drop member CONTOSO\Kelly to the server role named AdminSqlforBI ' + ` + 'on localhost\MSSQLSERVER. InnerException: Exception calling "DropMember" ' + ` + 'with "1" argument(s): "Mock DropMember Method was called with invalid operation."') + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter MembersToExclude is assigned a value, parameter Members is not assigned a value, and ensure is set to Present' { + It 'Should throw the correct error when login does not exist' { + $mockEnumMemberNames = @('KingJulian',$mockSqlServerLoginOne,$mockSqlServerLoginTwo) + $mockExpectedMemberToAdd = $mockSqlServerLoginTree + $mockSqlServerLoginToAdd = $mockSqlServerLoginTree + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + MembersToExclude = 'KingJulian' + } + + $throwInvalidOperation = ("Login 'KingJulian' does not exist on SQL server 'localhost\MSSQLSERVER'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When parameter Members is assigned a value and ensure is set to Present' { + It 'Should throw the correct error when login does not exist' { + $mockExpectedMemberToAdd = $mockSqlServerLoginTree + $mockSqlServerLoginToAdd = $mockSqlServerLoginTree + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + Members = @('KingJulian',$mockSqlServerLoginOne,$mockSqlServerLoginTree) + } + + $throwInvalidOperation = ("Login 'KingJulian' does not exist on SQL server 'localhost\MSSQLSERVER'.") + + { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Context 'When Members parameter is set and ensure parameter is set to Present' { + It 'Should not throw when calling both the AddMember and DropMember methods' { + $mockExpectedMemberToAdd = $mockSqlServerLoginTree + $mockSqlServerLoginToAdd = $mockSqlServerLoginTree + $mockExpectedMemberToDrop = $mockSqlServerLoginTwo + $mockSqlServerLoginToDrop = $mockSqlServerLoginTwo + $testParameters = $mockDefaultParameters + $testParameters += @{ + Ensure = 'Present' + ServerRoleName = $mockSqlServerRole + Members = @($mockSqlServerLoginOne,$mockSqlServerLoginTree) + } + + { Set-TargetResource @testParameters } | Should -Not -Throw + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + } + + Assert-VerifiableMock + } + } +} +finally +{ + Invoke-TestCleanup +} + diff --git a/Tests/Unit/MSFT_xSQLServerServiceAccount.Tests.ps1 b/Tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_xSQLServerServiceAccount.Tests.ps1 rename to Tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 index 68a08fc16..dec24cb26 100644 --- a/Tests/Unit/MSFT_xSQLServerServiceAccount.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerServiceAccount' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlServiceAccount' #region HEADER @@ -223,7 +223,7 @@ try Verifiable = $true } - Describe 'MSFT_xSQLServerServiceAccount\ConvertTo-ManagedServiceType' -Tag 'Helper' { + Describe 'MSFT_SqlServerServiceAccount\ConvertTo-ManagedServiceType' -Tag 'Helper' { Context 'Translating service types' { $testCases = @( @{ @@ -286,7 +286,7 @@ try } } - Describe 'MSFT_xSQLServerServiceAccount\Get-ServiceObject' -Tag 'Helper' { + Describe 'MSFT_SqlServerServiceAccount\Get-ServiceObject' -Tag 'Helper' { Mock -CommandName Import-SQLPSModule -Verifiable $defaultGetServiceObjectParameters = @{ @@ -328,7 +328,7 @@ try } } - Describe 'MSFT_xSQLServerServiceAccount\Get-TargetResource' -Tag 'Get' { + Describe 'MSFT_SqlServerServiceAccount\Get-TargetResource' -Tag 'Get' { Mock -CommandName Import-SQLPSModule -Verifiable Context 'When getting the service information for a default instance' { @@ -433,7 +433,7 @@ try } } - Describe 'MSFT_xSQLServerServiceAccount\Test-TargetResource' -Tag 'Test' { + Describe 'MSFT_SqlServerServiceAccount\Test-TargetResource' -Tag 'Test' { Mock -CommandName Import-SQLPSModule -Verifiable Context 'When the system is not in the desired state for a default instance' { @@ -552,7 +552,7 @@ try } } - Describe 'MSFT_xSQLServerServiceAccount\Set-TargetResource' -Tag 'Set' { + Describe 'MSFT_SqlServerServiceAccount\Set-TargetResource' -Tag 'Set' { Mock -CommandName Import-SQLPSModule -Verifiable Context 'When changing the service account for the default instance' { diff --git a/Tests/Unit/MSFT_xSQLServerSetup.Tests.ps1 b/Tests/Unit/MSFT_SqlSetup.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerSetup.Tests.ps1 rename to Tests/Unit/MSFT_SqlSetup.Tests.ps1 index 26d9096c8..a21083628 100644 --- a/Tests/Unit/MSFT_xSQLServerSetup.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlSetup.Tests.ps1 @@ -2,8 +2,8 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param() -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerSetup' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlSetup' #region HEADER @@ -935,7 +935,7 @@ try Features = 'SQLEngine' } - Describe "xSQLServerSetup\Get-TargetResource" -Tag 'Get' { + Describe "SqlSetup\Get-TargetResource" -Tag 'Get' { #region Setting up TestDrive:\ # Local path to TestDrive:\ @@ -2262,7 +2262,7 @@ try Assert-VerifiableMock } - Describe "xSQLServerSetup\Test-TargetResource" -Tag 'Test' { + Describe "SqlSetup\Test-TargetResource" -Tag 'Test' { #region Setting up TestDrive:\ # Local path to TestDrive:\ @@ -2884,7 +2884,7 @@ try Assert-VerifiableMock } - Describe "xSQLServerSetup\Set-TargetResource" -Tag 'Set' { + Describe "SqlSetup\Set-TargetResource" -Tag 'Set' { #region Setting up TestDrive:\ # Local path to TestDrive:\ diff --git a/Tests/Unit/MSFT_xWaitForAvailabilityGroup.Tests.ps1 b/Tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_xWaitForAvailabilityGroup.Tests.ps1 rename to Tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 index 42a9d2beb..226dd6a65 100644 --- a/Tests/Unit/MSFT_xWaitForAvailabilityGroup.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xWaitForAvailabilityGroup' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlWaitForAG' #region HEADER @@ -78,7 +78,7 @@ try RetryCount = $mockRetryCount } - Describe 'MSFT_xWaitForAvailabilityGroup\Get-TargetResource' -Tag 'Get' { + Describe 'MSFT_SqlWaitForAG\Get-TargetResource' -Tag 'Get' { BeforeEach { $testParameters = $mockDefaultParameters.Clone() @@ -142,7 +142,7 @@ try } - Describe 'MSFT_xWaitForAvailabilityGroup\Test-TargetResource' -Tag 'Test'{ + Describe 'MSFT_SqlWaitForAG\Test-TargetResource' -Tag 'Test'{ BeforeEach { $testParameters = $mockDefaultParameters.Clone() @@ -191,7 +191,7 @@ try Assert-VerifiableMock } - Describe 'MSFT_xWaitForAvailabilityGroup\Set-TargetResource' -Tag 'Set'{ + Describe 'MSFT_SqlWaitForAG\Set-TargetResource' -Tag 'Set'{ BeforeEach { $testParameters = $mockDefaultParameters.Clone() diff --git a/Tests/Unit/MSFT_xSQLServerFirewall.Tests.ps1 b/Tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_xSQLServerFirewall.Tests.ps1 rename to Tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 index 9eefeee7b..d92e485d8 100644 --- a/Tests/Unit/MSFT_xSQLServerFirewall.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 @@ -2,8 +2,8 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param() -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerFirewall' +$script:DSCModuleName = 'SqlServerDsc' +$script:DSCResourceName = 'MSFT_SqlWindowsFirewall' #region HEADER @@ -405,7 +405,7 @@ try SourceCredential = $mockSourceCredential } - Describe "xSQLServerFirewall\Get-TargetResource" -Tag 'Get' { + Describe "SqlWindowsFirewall\Get-TargetResource" -Tag 'Get' { # Local path to TestDrive:\ $mockSourcePath = $TestDrive.FullName @@ -951,7 +951,7 @@ try } } - Describe "xSQLServerFirewall\Set-TargetResource" -Tag 'Set' { + Describe "SqlWindowsFirewall\Set-TargetResource" -Tag 'Set' { # Local path to TestDrive:\ $mockSourcePath = $TestDrive.FullName @@ -1192,7 +1192,7 @@ try } } - Describe "xSQLServerFirewall\Test-TargetResource" -Tag 'Test' { + Describe "SqlWindowsFirewall\Test-TargetResource" -Tag 'Test' { # Local path to TestDrive:\ $mockSourcePath = $TestDrive.FullName diff --git a/Tests/Unit/xSQLServerHelper.Tests.ps1 b/Tests/Unit/SqlServerDSCHelper.Tests.ps1 similarity index 99% rename from Tests/Unit/xSQLServerHelper.Tests.ps1 rename to Tests/Unit/SqlServerDSCHelper.Tests.ps1 index e8fb6d30b..8f2cdd52c 100644 --- a/Tests/Unit/xSQLServerHelper.Tests.ps1 +++ b/Tests/Unit/SqlServerDSCHelper.Tests.ps1 @@ -4,7 +4,7 @@ param () # Unit Test Template Version: 1.1.0 -$script:moduleName = 'xSQLServerHelper' +$script:moduleName = 'SqlServerDscHelper' [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` @@ -14,7 +14,7 @@ if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCR } Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent | Split-Path -Parent) -ChildPath 'xSQLServerHelper.psm1') -Scope Global -Force +Import-Module (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent | Split-Path -Parent) -ChildPath 'SqlServerDscHelper.psm1') -Scope Global -Force # Loading mocked classes Add-Type -Path ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SMO.cs ) @@ -786,7 +786,7 @@ InModuleScope $script:moduleName { Assert-VerifiableMock } - $mockApplicationDomainName = 'xSQLServerHelperTests' + $mockApplicationDomainName = 'SqlServerDscHelperTests' $mockApplicationDomainObject = [System.AppDomain]::CreateDomain($mockApplicationDomainName) <# @@ -836,7 +836,7 @@ InModuleScope $script:moduleName { } -Verifiable Mock -CommandName Register-SqlSmo -MockWith { - [System.AppDomain]::CreateDomain('xSQLServerHelper') + [System.AppDomain]::CreateDomain('SqlServerDscHelper') } -ParameterFilter { $SQLInstanceName -eq $mockInstanceName } -Verifiable diff --git a/Tests/Unit/Stubs/SMO.cs b/Tests/Unit/Stubs/SMO.cs index 00e4789d1..9155fc29e 100644 --- a/Tests/Unit/Stubs/SMO.cs +++ b/Tests/Unit/Stubs/SMO.cs @@ -14,7 +14,7 @@ namespace Microsoft.SqlServer.Management.Smo // TypeName: Microsoft.SqlServer.Management.Smo.LoginCreateOptions // Used by: - // MSFT_xSQLServerLogin.Tests.ps1 + // MSFT_SqlServerLogin.Tests.ps1 public enum LoginCreateOptions { None = 0, @@ -25,7 +25,7 @@ public enum LoginCreateOptions // TypeName: Microsoft.SqlServer.Management.Smo.LoginType // BaseType: Microsoft.SqlServer.Management.Smo.ScriptNameObjectBase // Used by: - // MSFT_xSQLServerLogin + // MSFT_SqlServerLogin public enum LoginType { AsymmetricKey = 4, @@ -60,7 +60,7 @@ public enum AvailabilityReplicaAvailabilityMode // TypeName: Microsoft.SqlServer.Management.Smo.EndpointType // Used by: - // xSQLServerEndpoint + // SqlServerEndpoint public enum EndpointType { DatabaseMirroring, @@ -71,7 +71,7 @@ public enum EndpointType // TypeName: Microsoft.SqlServer.Management.Smo.ProtocolType // Used by: - // xSQLServerEndpoint + // SqlServerEndpoint public enum ProtocolType { Http, @@ -83,7 +83,7 @@ public enum ProtocolType // TypeName: Microsoft.SqlServer.Management.Smo.ServerMirroringRole // Used by: - // xSQLServerEndpoint + // SqlServerEndpoint public enum ServerMirroringRole { All, @@ -94,7 +94,7 @@ public enum ServerMirroringRole // TypeName: Microsoft.SqlServer.Management.Smo.EndpointEncryption // Used by: - // xSQLServerEndpoint + // SqlServerEndpoint public enum EndpointEncryption { Disabled, @@ -104,7 +104,7 @@ public enum EndpointEncryption // TypeName: Microsoft.SqlServer.Management.Smo.EndpointEncryptionAlgorithm // Used by: - // xSQLServerEndpoint + // SqlServerEndpoint public enum EndpointEncryptionAlgorithm { Aes, @@ -127,7 +127,7 @@ public class Globals // Typename: Microsoft.SqlServer.Management.Smo.ObjectPermissionSet // BaseType: Microsoft.SqlServer.Management.Smo.PermissionSetBase // Used by: - // xSQLServerEndpointPermission.Tests.ps1 + // SqlServerEndpointPermission.Tests.ps1 public class ObjectPermissionSet { public ObjectPermissionSet(){} @@ -144,7 +144,7 @@ public ObjectPermissionSet( // TypeName: Microsoft.SqlServer.Management.Smo.ServerPermissionSet // BaseType: Microsoft.SqlServer.Management.Smo.PermissionSetBase // Used by: - // xSQLServerPermission.Tests.ps1 + // SqlServerPermission.Tests.ps1 public class ServerPermissionSet { public ServerPermissionSet(){} @@ -170,7 +170,7 @@ public ServerPermissionSet( // TypeName: Microsoft.SqlServer.Management.Smo.ServerPermissionInfo // BaseType: Microsoft.SqlServer.Management.Smo.PermissionInfo // Used by: - // xSQLServerPermission.Tests.ps1 + // SqlServerPermission.Tests.ps1 public class ServerPermissionInfo { public ServerPermissionInfo() @@ -192,7 +192,7 @@ public ServerPermissionInfo( // TypeName: Microsoft.SqlServer.Management.Smo.DatabasePermissionSet // BaseType: Microsoft.SqlServer.Management.Smo.PermissionSetBase // Used by: - // xSQLServerDatabasePermission.Tests.ps1 + // SqlDatabasePermission.Tests.ps1 public class DatabasePermissionSet { public DatabasePermissionSet(){} @@ -210,7 +210,7 @@ public DatabasePermissionSet( bool connect, bool update ) // TypeName: Microsoft.SqlServer.Management.Smo.DatabasePermissionInfo // BaseType: Microsoft.SqlServer.Management.Smo.PermissionInfo // Used by: - // xSQLServerDatabasePermission.Tests.ps1 + // SqlDatabasePermission.Tests.ps1 public class DatabasePermissionInfo { public DatabasePermissionInfo() @@ -231,8 +231,8 @@ public DatabasePermissionInfo( Microsoft.SqlServer.Management.Smo.DatabasePermis // TypeName: Microsoft.SqlServer.Management.Smo.Server // BaseType: Microsoft.SqlServer.Management.Smo.SqlSmoObject // Used by: - // xSQLServerPermission - // MSFT_xSQLServerLogin + // SqlServerPermission + // MSFT_SqlServerLogin public class Server { public string MockGranteeName; @@ -340,7 +340,7 @@ public void Revoke( Microsoft.SqlServer.Management.Smo.ServerPermissionSet permi // TypeName: Microsoft.SqlServer.Management.Smo.Login // BaseType: Microsoft.SqlServer.Management.Smo.ScriptNameObjectBase // Used by: - // MSFT_xSQLServerLogin + // MSFT_SqlServerLogin public class Login { private bool _mockPasswordPassed = false; @@ -524,7 +524,7 @@ public void Drop() // TypeName: Microsoft.SqlServer.Management.Smo.ServerRole // BaseType: Microsoft.SqlServer.Management.Smo.ScriptNameObjectBase // Used by: - // MSFT_xSQLServerRole + // MSFT_SqlServerRole public class ServerRole { public ServerRole( Server server, string name ) { @@ -542,9 +542,9 @@ public ServerRole( Object server, string name ) { // TypeName: Microsoft.SqlServer.Management.Smo.Database // BaseType: Microsoft.SqlServer.Management.Smo.ScriptNameObjectBase // Used by: - // MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership - // MSFT_xSQLServerDatabase - // MSFT_xSQLServerDatabasePermission + // MSFT_SqlAGDatabase + // MSFT_SqlDatabase + // MSFT_SqlDatabasePermission public class Database { public bool AutoClose = false; @@ -630,7 +630,7 @@ public void Deny( Microsoft.SqlServer.Management.Smo.DatabasePermissionSet permi // TypeName: Microsoft.SqlServer.Management.Smo.User // BaseType: Microsoft.SqlServer.Management.Smo.ScriptNameObjectBase // Used by: - // xSQLServerDatabaseRole.Tests.ps1 + // SqlDatabaseRole.Tests.ps1 public class User { public User( Server server, string name ) @@ -697,7 +697,7 @@ public FailedOperationException (string message, SmoException inner) : base (mes // TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityGroup // BaseType: Microsoft.SqlServer.Management.Smo.NamedSmoObject // Used by: - // xSQLServerAlwaysOnAvailabilityGroup + // SqlAG public class AvailabilityGroup { public AvailabilityGroup() @@ -748,7 +748,7 @@ public AvailabilityGroup Clone() // TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityReplica // BaseType: Microsoft.SqlServer.Management.Smo.NamedSmoObject // Used by: - // xSQLServerAlwaysOnAvailabilityGroup + // SqlAG public class AvailabilityReplica { public AvailabilityReplica() @@ -782,7 +782,7 @@ public void Create() // TypeName: Microsoft.SqlServer.Management.Common.ServerConnection // Used by: - // xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + // SqlAGDatabase public class ConnectionContext { public string TrueLogin; @@ -793,7 +793,7 @@ public void Create() // TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityDatabase // Used by: - // xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + // SqlAGDatabase public class AvailabilityDatabase { public string Name; @@ -803,7 +803,7 @@ public void Create() {} // TypeName: Microsoft.SqlServer.Management.Smo.DatabaseCollection // Used by: - // xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + // SqlAGDatabase public class DatabaseCollection : Collection { public Database this[string name] @@ -825,7 +825,7 @@ public Database this[string name] // TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityReplicaCollection // Used by: - // xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + // SqlAGDatabase public class AvailabilityReplicaCollection : Collection { public AvailabilityReplica this[string name] @@ -847,7 +847,7 @@ public AvailabilityReplica this[string name] // TypeName: Microsoft.SqlServer.Management.Smo.DatabaseEncryptionKey // Used by: - // xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + // SqlAGDatabase public class DatabaseEncryptionKey { public string EncryptorName; @@ -856,7 +856,7 @@ public class DatabaseEncryptionKey // TypeName: Microsoft.SqlServer.Management.Smo.Certificate // Used by: - // xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + // SqlAGDatabase public class Certificate { public byte[] Thumbprint; @@ -864,7 +864,7 @@ public class Certificate // TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityDatabaseCollection // Used by: - // xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + // SqlAGDatabase public class AvailabilityDatabaseCollection : Collection { public AvailabilityDatabase this[string name] @@ -886,7 +886,7 @@ public AvailabilityDatabase this[string name] // TypeName: Microsoft.SqlServer.Management.Smo.AvailabilityGroupCollection // Used by: - // xSQLServerAlwaysOnAvailabilityGroup + // SqlAG public class AvailabilityGroupCollection : Collection { public AvailabilityGroup this[string name] @@ -908,7 +908,7 @@ public AvailabilityGroup this[string name] // TypeName: Microsoft.SqlServer.Management.Smo.Endpoint // Used by: - // xSQLServerAlwaysOnAvailabilityGroup + // SqlAG public class Endpoint { public string Name; @@ -918,7 +918,7 @@ public class Endpoint // TypeName: Microsoft.SqlServer.Management.Smo.EndpointCollection // Used by: - // xSQLServerAlwaysOnAvailabilityGroup + // SqlAG public class EndpointCollection : Collection { public Endpoint this[string name] @@ -947,7 +947,7 @@ namespace Microsoft.SqlServer.Management.Smo.Wmi // TypeName: Microsoft.SqlServer.Management.Smo.Wmi.ManagedServiceType // Used by: - // MSFT_xSQLServerServiceAccount.Tests.ps1 + // MSFT_SqlServiceAccount.Tests.ps1 public enum ManagedServiceType { SqlServer = 1, diff --git a/appveyor.yml b/appveyor.yml index bbd5098b9..d890750f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ #---------------------------------# # environment configuration # #---------------------------------# -version: 6.0.{build}.0 +version: 9.0.{build}.0 image: Visual Studio 2017 install: - git clone https://github.com/PowerShell/DscResource.Tests diff --git a/en-US/xSQLServerHelper.strings.psd1 b/en-US/SqlServerDscHelper.strings.psd1 similarity index 98% rename from en-US/xSQLServerHelper.strings.psd1 rename to en-US/SqlServerDscHelper.strings.psd1 index 58c7a27af..2f940d248 100644 --- a/en-US/xSQLServerHelper.strings.psd1 +++ b/en-US/SqlServerDscHelper.strings.psd1 @@ -1,4 +1,4 @@ -# Localized resources for helper module xSQLServerHelper. +# Localized resources for helper module SqlServerDscHelper. ConvertFrom-StringData @' ConnectedToDatabaseEngineInstance = Connected to SQL instance '{0}'. @@ -17,7 +17,7 @@ ConvertFrom-StringData @' 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. PropertyThatDoesNotMatch = {0} - {1} ValueOfTypeDoesNotMatch = {0} value for property {1} does not match. Current state is '{2}' and desired state is '{3}'. - UnableToCompareProperty = Unable to compare property {0} as the type {1} is not handled by the Test-SQLDscParameterState cmdlet. + UnableToCompareProperty = Unable to compare property {0} as the type {1} is not handled by the Test-SQLDSCParameterState cmdlet. PreferredModuleFound = Preferred module SqlServer found. PreferredModuleNotFound = Information: PowerShell module SqlServer not found, trying to use older SQLPS module. ImportingPowerShellModule = Importing PowerShell module {0}. @@ -46,7 +46,7 @@ ConvertFrom-StringData @' # - NOTE! # - Below strings are used by helper functions New-TerminatingError and New-WarningMessage. - # - These strings were merged from old xSQLServer.strings.psd1. These will be moved to it's individual + # - These strings were merged from old SqlServerDsc.strings.psd1. These will be moved to it's individual # - resource when that resources get moved over to the new localization. # - NOTE! diff --git a/sv-SE/xSQLServerHelper.strings.psd1 b/sv-SE/SqlServerDscHelper.strings.psd1 similarity index 98% rename from sv-SE/xSQLServerHelper.strings.psd1 rename to sv-SE/SqlServerDscHelper.strings.psd1 index 78ac75278..947a96889 100644 --- a/sv-SE/xSQLServerHelper.strings.psd1 +++ b/sv-SE/SqlServerDscHelper.strings.psd1 @@ -1,4 +1,4 @@ -# Swedish localized resources for helper module xSQLServerHelper. +# Swedish localized resources for helper module SqlServerDscHelper. ConvertFrom-StringData @' ConnectedToDatabaseEngineInstance = Ansluten till SQL instans '{0}'. @@ -41,7 +41,7 @@ ConvertFrom-StringData @' # - NOTE! # - Below strings are used by helper functions New-TerminatingError and New-WarningMessage. - # - These strings were merged from old xSQLServer.strings.psd1. These will be moved to it's individual + # - These strings were merged from old SqlServerDsc.strings.psd1. These will be moved to it's individual # - resource when that resources get moved over to the new localization. # - NOTE! diff --git a/xSQLServer.psd1 b/xSQLServer.psd1 deleted file mode 100644 index 53c0f0e7a..000000000 --- a/xSQLServer.psd1 +++ /dev/null @@ -1,128 +0,0 @@ -@{ -# Version number of this module. -ModuleVersion = '9.0.0.0' - -# ID used to uniquely identify this module -GUID = '74e9ddb5-4cbc-4fa2-a222-2bcfb533fd66' - -# Author of this module -Author = 'Microsoft Corporation' - -# Company or vendor of this module -CompanyName = 'Microsoft Corporation' - -# Copyright statement for this module -Copyright = '(c) 2017 Microsoft Corporation. All rights reserved.' - -# Description of the functionality provided by this module -Description = 'Module with DSC Resources for deployment and configuration of Microsoft SQL Server.' - -# Minimum version of the Windows PowerShell engine required by this module -PowerShellVersion = '5.0' - -# Minimum version of the common language runtime (CLR) required by this module -CLRVersion = '4.0' - -# Functions to export from this module -FunctionsToExport = '*' - -# Cmdlets to export from this module -CmdletsToExport = '*' - -RequiredAssemblies = @() - -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') - - # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/xSQLServer/blob/master/LICENSE' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShell/xSQLServer' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - ReleaseNotes = '- Changes to xSQLServer - - Updated Pester syntax to v4 - - Fixes broken links to issues in the CHANGELOG.md. -- Changes to xSQLServerDatabase - - Added parameter to specify collation for a database to be different from server - collation ([issue 767](https://github.com/PowerShell/xSQLServer/issues/767)). - - Fixed unit tests for Get-TargetResource to ensure correctly testing return - values ([issue 849](https://github.com/PowerShell/xSQLServer/issues/849)) -- Changes to xSQLServerAlwaysOnAvailabilityGroup - - Refactored the unit tests to allow them to be more user friendly and to test - additional SQLServer variations. - - Each test will utilize the Import-SQLModuleStub to ensure the correct - module is loaded ([issue 784](https://github.com/PowerShell/xSQLServer/issues/784)). - - Fixed an issue when setting the SQLServer parameter to a Fully Qualified - Domain Name (FQDN) ([issue 468](https://github.com/PowerShell/xSQLServer/issues/468)). - - Fixed the logic so that if a parameter is not supplied to the resource, the - resource will not attempt to apply the defaults on subsequent checks - ([issue 517](https://github.com/PowerShell/xSQLServer/issues/517)). - - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, - the resource will only determine if a change is needed if the target node - is the active host of the SQL Server instance ([issue 868](https://github.com/PowerShell/xSQLServer/issues/868)). -- Changes to xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership - - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, - the resource will only determine if a change is needed if the target node - is the active host of the SQL Server instance ([issue 869](https://github.com/PowerShell/xSQLServer/issues/869)). -- Changes to xSQLServerAlwaysOnAvailabilityGroupReplica - - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, - the resource will only determine if a change is needed if the target node is - the active host of the SQL Server instance ([issue 870](https://github.com/PowerShell/xSQLServer/issues/870)). -- Added the CommonTestHelper.psm1 to store common testing functions. - - Added the Import-SQLModuleStub function to ensure the correct version of the - module stubs are loaded ([issue 784](https://github.com/PowerShell/xSQLServer/issues/784)). -- Changes to xSQLServerMemory - - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, - the resource will only determine if a change is needed if the target node - is the active host of the SQL Server instance ([issue 867](https://github.com/PowerShell/xSQLServer/issues/867)). -- Changes to xSQLServerNetwork - - BREAKING CHANGE: Renamed parameter TcpDynamicPorts to TcpDynamicPort and - changed type to Boolean ([issue 534](https://github.com/PowerShell/xSQLServer/issues/534)). - - Resolved issue when switching from dynamic to static port. - configuration ([issue 534](https://github.com/PowerShell/xSQLServer/issues/534)). - - Added localization (en-US) for all strings in resource and unit tests - ([issue 618](https://github.com/PowerShell/xSQLServer/issues/618)). - - Updated examples to reflect new parameters. -- Changes to xSQLServerRSConfig - - Added examples -- Added resource - - xSQLServerDatabaseDefaultLocation - ([issue 656](https://github.com/PowerShell/xSQLServer/issues/656)) -- Changes to xSQLServerEndpointPermission - - Fixed a problem when running the tests locally in a PowerShell console it - would ask for parameters ([issue 897](https://github.com/PowerShell/xSQLServer/issues/897)). -- Changes to xSQLServerAvailabilityGroupListener - - Fixed a problem when running the tests locally in a PowerShell console it - would ask for parameters ([issue 897](https://github.com/PowerShell/xSQLServer/issues/897)). -- Changes to xSQLServerMaxDop - - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified, - the resource will only determine if a change is needed if the target node - is the active host of the SQL Server instance ([issue 882](https://github.com/PowerShell/xSQLServer/issues/882)). - -' - - } # End of PSData hashtable - -} # End of PrivateData hashtable -} - - - - - - - - - - -