From ba47facd7467bf7ba19d7a76a51004fe202823c4 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 1 Jan 2020 18:57:33 +0100 Subject: [PATCH] Added continuous delivery with a new CI pipeline (#1454) --- .MetaTestOptIn.json | 13 - .codecov.yml | 24 - .gitattributes | 6 + .../ISSUE_TEMPLATE/Problem_with_resource.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 27 +- .gitignore | 6 +- .vscode/analyzersettings.psd1 | 15 +- .vscode/settings.json | 28 +- .vscode/tasks.json | 125 + Assert-TestEnvironment.ps1 | 105 - CHANGELOG.md | 1974 +--------------- CODE_OF_CONDUCT.md | 7 +- CONTRIBUTING.md | 285 +-- .../SqlAG/2-RemoveAvailabilityGroup.ps1 | 44 - .../3-CreateAvailabilityGroupDetailed.ps1 | 121 - .../1-AddDatabaseToAvailabilityGroup.ps1 | 130 -- .../2-RemoveDatabaseFromAvailabilityGroup.ps1 | 114 - ...atchDefinedDatabaseInAvailabilityGroup.ps1 | 125 - .../1-CreateAvailabilityGroupReplica.ps1 | 117 - .../2-RemoveAvailabilityGroupReplica.ps1 | 100 - .../Resources/SqlAgentAlert/1-AddAlert.ps1 | 33 - .../Resources/SqlAgentAlert/2-RemoveAlert.ps1 | 31 - .../SqlAgentFailsafe/1-AddFailsafe.ps1 | 21 - .../SqlAgentFailsafe/2-RemoveFailsafe.ps1 | 20 - .../SqlAgentOperator/1-AddOperator.ps1 | 21 - .../SqlAgentOperator/2-RemoveOperator.ps1 | 20 - .../SqlDatabase/1-CreateDatabase.ps1 | 43 - .../SqlDatabase/2-DeleteDatabase.ps1 | 29 - .../SqlRS/1-DefaultConfiguration.ps1 | 22 - .../Resources/SqlRS/2-CustomConfiguration.ps1 | 33 - .../SqlRS/3-CustomConfigurationUsingSsl.ps1 | 29 - .../SqlRS/4-CompleteWithTwoInstances.ps1 | 139 -- .../3-RunScriptCompleteExample.ps1 | 66 - ...TwoInstancesOnTheSameServerToEnableClr.ps1 | 35 - ...ConfigureInstanceToEnablePriorityBoost.ps1 | 24 - .../1-EnableDatabaseMail.ps1 | 67 - .../3-SecureConnectionAbsent.ps1 | 18 - .../4-SecureConnectionUsingSYSTEMAccount.ps1 | 21 - ...ConfigureServiceAccount-VirtualAccount.ps1 | 31 - GitVersion.yml | 26 + HISTORIC_CHANGELOG.md | 2022 +++++++++++++++++ LICENSE | 2 +- README.md | 362 ++- RequiredModules.psd1 | 28 + Resolve-Dependency.ps1 | 289 +++ Resolve-Dependency.psd1 | 5 + SqlServerDsc.psd1 | 86 - appveyor.yml | 130 -- azure-pipelines.yml | 255 +++ build.ps1 | 353 +++ build.yaml | 88 + source/Build.psd1 | 5 + .../DSCResources}/MSFT_SqlAG/MSFT_SqlAG.psm1 | 0 .../MSFT_SqlAG/MSFT_SqlAG.schema.mof | 0 .../MSFT_SqlAG/en-US/MSFT_SqlAG.strings.psd1 | 0 .../MSFT_SqlAGDatabase.psm1 | 0 .../MSFT_SqlAGDatabase.schema.mof | 0 .../en-US/MSFT_SqlAGDatabase.strings.psd1 | 0 .../en-US/about_SqlAGDatabase.help.txt | 0 .../MSFT_SqlAGListener.psm1 | 0 .../MSFT_SqlAGListener.schema.mof | 0 .../en-US/MSFT_SqlAGListener.strings.psd1 | 0 .../MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 | 0 .../MSFT_SqlAGReplica.schema.mof | 0 .../en-US/MSFT_SqlAGReplica.strings.psd1 | 0 .../MSFT_SqlAgentAlert.psm1 | 0 .../MSFT_SqlAgentAlert.schema.mof | 0 .../en-US/MSFT_SqlAgentAlert.strings.psd1 | 0 .../MSFT_SqlAgentFailsafe.psm1 | 0 .../MSFT_SqlAgentFailsafe.schema.mof | 0 .../en-US/MSFT_SqlAgentFailsafe.strings.psd1 | 0 .../MSFT_SqlAgentOperator.psm1 | 0 .../MSFT_SqlAgentOperator.schema.mof | 0 .../en-US/MSFT_SqlAgentOperator.strings.psd1 | 0 .../MSFT_SqlAlias/MSFT_SqlAlias.psm1 | 0 .../MSFT_SqlAlias/MSFT_SqlAlias.schema.mof | 0 .../en-US/MSFT_SqlAlias.strings.psd1 | 0 .../MSFT_SqlAlwaysOnService.psm1 | 4 +- .../MSFT_SqlAlwaysOnService.schema.mof | 0 .../MSFT_SqlAlwaysOnService.strings.psd1 | 0 .../MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 | 0 .../MSFT_SqlDatabase.schema.mof | 0 .../en-US/MSFT_SqlDatabase.strings.psd1 | 0 .../MSFT_SqlDatabaseDefaultLocation.psm1 | 0 ...MSFT_SqlDatabaseDefaultLocation.schema.mof | 0 ...FT_SqlDatabaseDefaultLocation.strings.psd1 | 0 .../MSFT_SqlDatabaseOwner.psm1 | 0 .../MSFT_SqlDatabaseOwner.schema.mof | 0 .../en-US/MSFT_SqlDatabaseOwner.strings.psd1 | 0 .../MSFT_SqlDatabasePermission.psm1 | 0 .../MSFT_SqlDatabasePermission.schema.mof | 0 .../MSFT_SqlDatabasePermission.strings.psd1 | 0 .../MSFT_SqlDatabaseRecoveryModel.psm1 | 0 .../MSFT_SqlDatabaseRecoveryModel.schema.mof | 0 ...MSFT_SqlDatabaseRecoveryModel.strings.psd1 | 0 .../MSFT_SqlDatabaseRole.psm1 | 0 .../MSFT_SqlDatabaseRole.schema.mof | 0 .../en-US/MSFT_SqlDatabaseRole.strings.psd1 | 0 .../MSFT_SqlDatabaseUser.psm1 | 0 .../MSFT_SqlDatabaseUser.schema.mof | 0 .../en-US/MSFT_SqlDatabaseUser.strings.psd1 | 0 .../DSCResources}/MSFT_SqlRS/MSFT_SqlRS.psm1 | 0 .../MSFT_SqlRS/MSFT_SqlRS.schema.mof | 0 .../MSFT_SqlRS/en-US/MSFT_SqlRS.strings.psd1 | 0 .../MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 | 2 +- .../MSFT_SqlRSSetup.schema.mof | 0 .../en-US/MSFT_SqlRSSetup.strings.psd1 | 0 .../MSFT_SqlScript/MSFT_SqlScript.psm1 | 0 .../MSFT_SqlScript/MSFT_SqlScript.schema.mof | 0 .../en-US/MSFT_SqlScript.strings.psd1 | 0 .../MSFT_SqlScriptQuery.psm1 | 0 .../MSFT_SqlScriptQuery.schema.mof | 0 .../en-US/MSFT_SqlScriptQuery.strings.psd1 | 0 .../MSFT_SqlServerConfiguration.psm1 | 0 .../MSFT_SqlServerConfiguration.schema.mof | 0 .../MSFT_SqlServerConfiguration.strings.psd1 | 0 .../MSFT_SqlServerDatabaseMail.psm1 | 0 .../MSFT_SqlServerDatabaseMail.schema.mof | 0 .../MSFT_SqlServerDatabaseMail.strings.psd1 | 0 .../MSFT_SqlServerEndpoint.psm1 | 0 .../MSFT_SqlServerEndpoint.schema.mof | 0 .../en-US/MSFT_SqlServerEndpoint.strings.psd1 | 0 .../MSFT_SqlServerEndpointPermission.psm1 | 0 ...SFT_SqlServerEndpointPermission.schema.mof | 0 ...T_SqlServerEndpointPermission.strings.psd1 | 0 .../MSFT_SqlServerEndpointState.psm1 | 0 .../MSFT_SqlServerEndpointState.schema.mof | 0 .../MSFT_SqlServerEndpointState.strings.psd1 | 0 .../MSFT_SqlServerLogin.psm1 | 0 .../MSFT_SqlServerLogin.schema.mof | 0 .../en-US/MSFT_SqlServerLogin.strings.psd1 | 0 .../MSFT_SqlServerMaxDop.psm1 | 0 .../MSFT_SqlServerMaxDop.schema.mof | 0 .../en-US/MSFT_SqlServerMaxDop.strings.psd1 | 0 .../MSFT_SqlServerMemory.psm1 | 0 .../MSFT_SqlServerMemory.schema.mof | 0 .../en-US/MSFT_SqlServerMemory.strings.psd1 | 0 .../MSFT_SqlServerNetwork.psm1 | 0 .../MSFT_SqlServerNetwork.schema.mof | 0 .../en-US/MSFT_SqlServerNetwork.strings.psd1 | 0 .../MSFT_SqlServerPermission.psm1 | 0 .../MSFT_SqlServerPermission.schema.mof | 0 .../MSFT_SqlServerPermission.strings.psd1 | 0 .../MSFT_SqlServerReplication.psm1 | 0 .../MSFT_SqlServerReplication.schema.mof | 0 .../MSFT_SqlServerReplication.strings.psd1 | 0 .../MSFT_SqlServerRole.psm1 | 0 .../MSFT_SqlServerRole.schema.mof | 0 .../en-US/MSFT_SqlServerRole.strings.psd1 | 0 .../MSFT_SqlServerSecureConnection.psm1 | 0 .../MSFT_SqlServerSecureConnection.schema.mof | 0 ...SFT_SqlServerSecureConnection.strings.psd1 | 0 .../MSFT_SqlServiceAccount.psm1 | 0 .../MSFT_SqlServiceAccount.schema.mof | 0 .../en-US/MSFT_SqlServiceAccount.strings.psd1 | 0 .../MSFT_SqlSetup/MSFT_SqlSetup.psm1 | 2 +- .../MSFT_SqlSetup/MSFT_SqlSetup.schema.mof | 0 .../en-US/MSFT_SqlSetup.strings.psd1 | 0 .../sv-SE/MSFT_SqlSetup.strings.psd1 | 0 .../MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 | 0 .../MSFT_SqlWaitForAG.schema.mof | 0 .../en-US/MSFT_SqlWaitForAG.strings.psd1 | 0 .../MSFT_SqlWindowsFirewall.psm1 | 6 +- .../MSFT_SqlWindowsFirewall.schema.mof | 0 .../MSFT_SqlWindowsFirewall.strings.psd1 | 0 {Examples => source/Examples}/README.md | 0 .../SqlAG/1-CreateAvailabilityGroup.ps1 | 64 +- .../SqlAG/2-RemoveAvailabilityGroup.ps1 | 30 + .../3-CreateAvailabilityGroupDetailed.ps1 | 92 + .../1-AddDatabaseToAvailabilityGroup.ps1 | 38 + .../2-RemoveDatabaseFromAvailabilityGroup.ps1 | 32 + ...atchDefinedDatabaseInAvailabilityGroup.ps1 | 33 + ...labilityGroupListenerWithSameNameAsVCO.ps1 | 9 +- ...ityGroupListenerWithDifferentNameAsVCO.ps1 | 9 +- ...labilityGroupListenerWithSameNameAsVCO.ps1 | 9 +- ...ityGroupListenerWithDifferentNameAsVCO.ps1 | 9 +- ...stenerUsingDHCPWithDefaultServerSubnet.ps1 | 15 +- ...oupListenerUsingDHCPWithSpecificSubnet.ps1 | 8 +- .../1-CreateAvailabilityGroupReplica.ps1 | 88 + .../2-RemoveAvailabilityGroupReplica.ps1 | 34 + .../Resources/SqlAgentAlert/1-AddAlert.ps1 | 32 + .../Resources/SqlAgentAlert/2-RemoveAlert.ps1 | 29 + .../SqlAgentFailsafe/1-AddFailsafe.ps1 | 22 + .../SqlAgentFailsafe/2-RemoveFailsafe.ps1 | 21 + .../SqlAgentOperator/1-AddOperator.ps1 | 22 + .../SqlAgentOperator/2-RemoveOperator.ps1 | 22 + .../Resources/SqlAlias/1-AddSqlAlias.ps1 | 23 +- .../Resources/SqlAlias/2-RemoveSqlAlias.ps1 | 20 +- .../SqlAlwaysOnService/1-EnableAlwaysOn.ps1 | 8 +- .../SqlAlwaysOnService/2-DisableAlwaysOn.ps1 | 8 +- .../SqlDatabase/1-CreateDatabase.ps1 | 43 + .../SqlDatabase/2-DeleteDatabase.ps1 | 29 + .../1-SetDatabaseDefaultLocation.ps1 | 23 +- .../SqlDatabaseOwner/1-SetDatabaseOwner.ps1 | 20 +- .../1-GrantDatabasePermissions.ps1 | 29 +- .../2-RevokeDatabasePermissions.ps1 | 20 +- .../3-DenyDatabasePermissions.ps1 | 29 +- .../1-SetDatabaseRecoveryModel.ps1 | 20 +- .../SqlDatabaseRole/1-AddDatabaseRole.ps1 | 15 +- .../SqlDatabaseRole/2-RemoveDatabaseRole.ps1 | 12 +- .../3-EnforceDatabaseRoleMembers.ps1 | 19 +- .../4-MembersToIncludeInDatabaseRole.ps1 | 19 +- .../5-MembersToExcludeFromDatabaseRole.ps1 | 19 +- ...mbersToIncludeAndExcludeInDatabaseRole.ps1 | 19 +- .../1-AddDatabaseUserWithLogin.ps1 | 10 +- .../2-AddDatabaseUserWithoutLogin.ps1 | 6 +- ...3-AddDatabaseUserMappedToAsymmetricKey.ps1 | 6 +- .../4-AddDatabaseUserMappedToCertificate.ps1 | 6 +- .../SqlDatabaseUser/5-RemoveDatabaseUser.ps1 | 6 +- .../SqlRS/1-DefaultConfiguration.ps1 | 23 + .../Resources/SqlRS/2-CustomConfiguration.ps1 | 34 + .../SqlRS/3-CustomConfigurationUsingSsl.ps1 | 30 + .../SqlRS/4-CompleteWithTwoInstances.ps1 | 120 + .../SqlRSSetup/1-InstallReportingServices.ps1 | 4 +- .../2-UninstallReportingServices.ps1 | 4 +- .../1-RunScriptUsingSQLAuthentication.ps1 | 9 +- .../2-RunScriptUsingWindowsAuthentication.ps1 | 12 +- .../SqlScript/3-RunScriptCompleteExample.ps1 | 13 +- .../1-RunScriptUsingSQLAuthentication.ps1 | 9 +- .../2-RunScriptUsingWindowsAuthentication.ps1 | 12 +- .../3-RunScriptCompleteExample.ps1 | 53 + ...TwoInstancesOnTheSameServerToEnableClr.ps1 | 28 + ...ConfigureInstanceToEnablePriorityBoost.ps1 | 27 + .../1-EnableDatabaseMail.ps1 | 50 + .../2-DisableDatabaseMail.ps1 | 36 +- .../1-CreateEndpointWithDefaultValues.ps1 | 11 +- ...EndpointWithSpecificPortIPAddressOwner.ps1 | 9 +- .../SqlServerEndpoint/3-RemoveEndpoint.ps1 | 13 +- .../1-AddConnectPermission.ps1 | 10 +- .../2-RemoveConnectPermission.ps1 | 10 +- ...eplicasEachWithDifferentServiceAccount.ps1 | 20 +- ...eplicasEachWithDifferentServiceAccount.ps1 | 15 +- .../1-MakeSureEndpointIsStarted.ps1 | 27 +- .../2-MakeSureEndpointIsStopped.ps1 | 9 +- .../Resources/SqlServerLogin/1-AddLogin.ps1 | 27 +- .../SqlServerLogin/2-RemoveLogin.ps1 | 22 +- .../SqlServerMaxDop/1-SetMaxDopToOne.ps1 | 10 +- .../SqlServerMaxDop/2-SetMaxDopToAuto.ps1 | 18 +- .../SqlServerMaxDop/3-SetMaxDopToDefault.ps1 | 10 +- .../SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 | 11 +- .../SqlServerMemory/2-SetMaxMemoryToAuto.ps1 | 21 +- ...inMemoryToFixedValueAndMaxMemoryToAuto.ps1 | 11 +- .../4-SetMaxMemoryToDefault.ps1 | 11 +- .../1-EnableTcpIpWithStaticPort.ps1 | 11 +- .../2-EnableTcpIpWithDynamicPort.ps1 | 11 +- .../1-AddServerPermissionForLogin.ps1 | 4 +- .../2-RemoveServerPermissionForLogin.ps1 | 6 +- .../1-ConfigureInstanceAsDistributor.ps1 | 8 +- .../2-ConfigureInstanceAsPublisher.ps1 | 8 +- .../SqlServerRole/1-AddServerRole.ps1 | 22 +- .../SqlServerRole/2-RemoveServerRole.ps1 | 17 +- .../3-AddMembersToServerRole.ps1 | 19 +- .../4-MembersToIncludeInServerRole.ps1 | 19 +- .../5-MembersToExcludeInServerRole.ps1 | 19 +- .../1-ForceSecureConnection.ps1 | 11 +- .../2-SecureConnectionNotForced.ps1 | 11 +- .../3-SecureConnectionAbsent.ps1 | 19 + .../4-SecureConnectionUsingSYSTEMAccount.ps1 | 22 + .../1-ConfigureServiceAccount-UserAccount.ps1 | 16 +- ...ConfigureServiceAccount-VirtualAccount.ps1 | 33 + .../1-InstallDefaultInstanceSingleServer.ps1 | 13 +- .../2-InstallNamedInstanceSingleServer.ps1 | 13 +- ...ServerFromUncPathUsingSourceCredential.ps1 | 13 +- ...amedInstanceInFailoverClusterFirstNode.ps1 | 19 +- ...medInstanceInFailoverClusterSecondNode.ps1 | 15 +- ...gleServerWithAgtSvcStartupTypeDisabled.ps1 | 14 +- ...DefaultInstanceSingleServer2016OrLater.ps1 | 12 +- .../1-WaitForASingleClusterGroup.ps1 | 6 +- .../2-WaitForMultipleClusterGroups.ps1 | 8 +- .../1-CreateInboundFirewallRules.ps1 | 10 +- .../2-RemoveInboundFirewallRules.ps1 | 10 +- .../SqlServerDsc.Common.psd1 | 78 + .../SqlServerDsc.Common.psm1 | 39 +- .../en-US/SqlServerDsc.Common.strings.psd1 | 0 .../sv-SE/SqlServerDsc.Common.strings.psd1 | 0 source/SqlServerDsc.psd1 | 105 + source/en-US/about_SqlServerDsc.help.txt | 25 + .../MSFT_SqlAgentAlert.Integration.Tests.ps1 | 32 +- .../Integration/MSFT_SqlAgentAlert.config.ps1 | 0 ...SFT_SqlAgentFailsafe.Integration.Tests.ps1 | 32 +- .../MSFT_SqlAgentFailsafe.config.ps1 | 0 ...SFT_SqlAgentOperator.Integration.Tests.ps1 | 32 +- .../MSFT_SqlAgentOperator.config.ps1 | 0 ...T_SqlAlwaysOnService.Integration.Tests.ps1 | 30 +- .../MSFT_SqlAlwaysOnService.config.ps1 | 6 +- .../MSFT_SqlDatabase.Integration.Tests.ps1 | 30 +- .../Integration/MSFT_SqlDatabase.config.ps1 | 0 ...abaseDefaultLocation.Integration.Tests.ps1 | 30 +- ...MSFT_SqlDatabaseDefaultLocation.config.ps1 | 0 ...MSFT_SqlDatabaseUser.Integration.Tests.ps1 | 30 +- .../MSFT_SqlDatabaseUser.config.ps1 | 0 .../MSFT_SqlRS.Integration.Tests.ps1 | 30 +- .../Integration/MSFT_SqlRS.config.ps1 | 6 +- .../MSFT_SqlRSSetup.Integration.Tests.ps1 | 38 +- .../Integration/MSFT_SqlRSSetup.config.ps1 | 2 +- .../MSFT_SqlScript.Integration.Tests.ps1 | 35 +- .../Integration/MSFT_SqlScript.config.ps1 | 2 +- .../MSFT_SqlScriptQuery.Integration.Tests.ps1 | 47 +- .../MSFT_SqlScriptQuery.config.ps1 | 0 ...qlServerDatabaseMail.Integration.Tests.ps1 | 30 +- .../MSFT_SqlServerDatabaseMail.config.ps1 | 0 ...FT_SqlServerEndPoint.Integration.Tests.ps1 | 30 +- .../MSFT_SqlServerEndPoint.config.ps1 | 0 .../MSFT_SqlServerLogin.Integration.Tests.ps1 | 30 +- .../MSFT_SqlServerLogin.config.ps1 | 2 +- ...SFT_SqlServerNetwork.Integration.Tests.ps1 | 30 +- .../MSFT_SqlServerNetwork.config.ps1 | 0 .../MSFT_SqlServerRole.Integration.Tests.ps1 | 30 +- .../Integration/MSFT_SqlServerRole.config.ps1 | 0 ...rverSecureConnection.Integration.Tests.ps1 | 37 +- .../MSFT_SqlServerSecureConnection.config.ps1 | 0 ...FT_SqlServiceAccount.Integration.Tests.ps1 | 30 +- .../MSFT_SqlServiceAccount.config.ps1 | 4 +- .../MSFT_SqlSetup.Integration.Tests.ps1 | 47 +- .../Integration/MSFT_SqlSetup.config.ps1 | 12 +- {Tests => tests}/Integration/README.md | 3 + .../TestHelpers/CommonTestHelper.psm1 | 60 +- {Tests => tests}/Tests.depend.psd1 | 0 {Tests => tests}/Unit/MSFT_SqlAG.Tests.ps1 | 36 +- .../Unit/MSFT_SqlAGDatabase.Tests.ps1 | 43 +- .../Unit/MSFT_SqlAGListener.Tests.ps1 | 41 +- .../Unit/MSFT_SqlAGReplica.Tests.ps1 | 41 +- .../Unit/MSFT_SqlAgentAlert.Tests.ps1 | 39 +- .../Unit/MSFT_SqlAgentFailsafe.Tests.ps1 | 39 +- .../Unit/MSFT_SqlAgentOperator.Tests.ps1 | 39 +- {Tests => tests}/Unit/MSFT_SqlAlias.Tests.ps1 | 40 +- .../Unit/MSFT_SqlAlwaysOnService.Tests.ps1 | 28 +- .../Unit/MSFT_SqlDatabase.Tests.ps1 | 38 +- .../MSFT_SqlDatabaseDefaultLocation.Tests.ps1 | 43 +- .../Unit/MSFT_SqlDatabaseOwner.Tests.ps1 | 38 +- .../Unit/MSFT_SqlDatabasePermission.Tests.ps1 | 37 +- .../MSFT_SqlDatabaseRecoveryModel.Tests.ps1 | 38 +- .../Unit/MSFT_SqlDatabaseRole.Tests.ps1 | 37 +- .../Unit/MSFT_SqlDatabaseUser.Tests.ps1 | 37 +- {Tests => tests}/Unit/MSFT_SqlRS.Tests.ps1 | 41 +- .../Unit/MSFT_SqlRSSetup.Tests.ps1 | 38 +- .../Unit/MSFT_SqlScript.Tests.ps1 | 38 +- .../Unit/MSFT_SqlScriptQuery.Tests.ps1 | 42 +- .../MSFT_SqlServerConfiguration.Tests.ps1 | 21 +- .../Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 | 38 +- .../Unit/MSFT_SqlServerEndpoint.Tests.ps1 | 39 +- ...MSFT_SqlServerEndpointPermission.Tests.ps1 | 37 +- .../MSFT_SqlServerEndpointState.Tests.ps1 | 41 +- .../Unit/MSFT_SqlServerLogin.Tests.ps1 | 41 +- .../Unit/MSFT_SqlServerMaxDop.Tests.ps1 | 37 +- .../Unit/MSFT_SqlServerMemory.Tests.ps1 | 37 +- .../Unit/MSFT_SqlServerNetwork.Tests.ps1 | 40 +- .../Unit/MSFT_SqlServerPermission.Tests.ps1 | 37 +- .../Unit/MSFT_SqlServerReplication.Tests.ps1 | 24 +- .../Unit/MSFT_SqlServerRole.Tests.ps1 | 38 +- .../MSFT_SqlServerSecureConnection.Tests.ps1 | 41 +- .../Unit/MSFT_SqlServiceAccount.Tests.ps1 | 37 +- {Tests => tests}/Unit/MSFT_SqlSetup.Tests.ps1 | 40 +- .../Unit/MSFT_SqlWaitForAG.Tests.ps1 | 40 +- .../Unit/MSFT_SqlWindowsFirewall.Tests.ps1 | 42 +- .../Unit/SqlServerDsc.Common.Tests.ps1 | 27 +- {Tests => tests}/Unit/Stubs/SMO.cs | 0 {Tests => tests}/Unit/Stubs/SQLPSStub.psm1 | 2 +- .../Unit/Stubs/SQLServerStub.psm1 | 2 +- .../SqlPowerShellSqlExecutionException.cs | 0 .../Unit/Stubs/Write-ModuleStubFile.ps1 | 0 361 files changed, 6195 insertions(+), 6094 deletions(-) delete mode 100644 .MetaTestOptIn.json delete mode 100644 .codecov.yml create mode 100644 .vscode/tasks.json delete mode 100644 Assert-TestEnvironment.ps1 delete mode 100644 Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 delete mode 100644 Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 delete mode 100644 Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 delete mode 100644 Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 delete mode 100644 Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 delete mode 100644 Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 delete mode 100644 Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 delete mode 100644 Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 delete mode 100644 Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 delete mode 100644 Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 delete mode 100644 Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 delete mode 100644 Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 delete mode 100644 Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 delete mode 100644 Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 delete mode 100644 Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 delete mode 100644 Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 delete mode 100644 Examples/Resources/SqlRS/2-CustomConfiguration.ps1 delete mode 100644 Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 delete mode 100644 Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 delete mode 100644 Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 delete mode 100644 Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 delete mode 100644 Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 delete mode 100644 Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 delete mode 100644 Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 delete mode 100644 Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 delete mode 100644 Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 create mode 100644 GitVersion.yml create mode 100644 HISTORIC_CHANGELOG.md create mode 100644 RequiredModules.psd1 create mode 100644 Resolve-Dependency.ps1 create mode 100644 Resolve-Dependency.psd1 delete mode 100644 SqlServerDsc.psd1 delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.yml create mode 100644 build.ps1 create mode 100644 build.yaml create mode 100644 source/Build.psd1 rename {DSCResources => source/DSCResources}/MSFT_SqlAG/MSFT_SqlAG.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAG/MSFT_SqlAG.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAG/en-US/MSFT_SqlAG.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGDatabase/en-US/about_SqlAGDatabase.help.txt (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGListener/en-US/MSFT_SqlAGListener.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAGReplica/en-US/MSFT_SqlAGReplica.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentAlert/en-US/MSFT_SqlAgentAlert.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentFailsafe/en-US/MSFT_SqlAgentFailsafe.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAgentOperator/en-US/MSFT_SqlAgentOperator.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAlias/MSFT_SqlAlias.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAlias/en-US/MSFT_SqlAlias.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 (98%) rename {DSCResources => source/DSCResources}/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlAlwaysOnService/en-US/MSFT_SqlAlwaysOnService.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabase/en-US/MSFT_SqlDatabase.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseOwner/en-US/MSFT_SqlDatabaseOwner.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabasePermission/en-US/MSFT_SqlDatabasePermission.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseRole/en-US/MSFT_SqlDatabaseRole.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlDatabaseUser/en-US/MSFT_SqlDatabaseUser.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlRS/MSFT_SqlRS.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlRS/MSFT_SqlRS.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlRS/en-US/MSFT_SqlRS.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 (99%) rename {DSCResources => source/DSCResources}/MSFT_SqlRSSetup/MSFT_SqlRSSetup.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlRSSetup/en-US/MSFT_SqlRSSetup.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlScript/MSFT_SqlScript.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlScript/MSFT_SqlScript.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlScript/en-US/MSFT_SqlScript.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlScriptQuery/en-US/MSFT_SqlScriptQuery.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerDatabaseMail/en-US/MSFT_SqlServerDatabaseMail.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerLogin/en-US/MSFT_SqlServerLogin.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerMaxDop/en-US/MSFT_SqlServerMaxDop.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerMemory/en-US/MSFT_SqlServerMemory.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerPermission/en-US/MSFT_SqlServerPermission.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerReplication/en-US/MSFT_SqlServerReplication.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerRole/en-US/MSFT_SqlServerRole.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServerSecureConnection/en-US/MSFT_SqlServerSecureConnection.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlSetup/MSFT_SqlSetup.psm1 (99%) rename {DSCResources => source/DSCResources}/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlWaitForAG/en-US/MSFT_SqlWaitForAG.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 (99%) rename {DSCResources => source/DSCResources}/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SqlWindowsFirewall/en-US/MSFT_SqlWindowsFirewall.strings.psd1 (100%) rename {Examples => source/Examples}/README.md (100%) rename {Examples => source/Examples}/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 (53%) create mode 100644 source/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 create mode 100644 source/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 create mode 100644 source/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 create mode 100644 source/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 create mode 100644 source/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 rename {Examples => source/Examples}/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 (72%) rename {Examples => source/Examples}/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 (72%) rename {Examples => source/Examples}/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 (67%) rename {Examples => source/Examples}/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 (67%) rename {Examples => source/Examples}/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 (56%) rename {Examples => source/Examples}/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 (74%) create mode 100644 source/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 create mode 100644 source/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 create mode 100644 source/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 create mode 100644 source/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 create mode 100644 source/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 create mode 100644 source/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 create mode 100644 source/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 create mode 100644 source/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 rename {Examples => source/Examples}/Resources/SqlAlias/1-AddSqlAlias.ps1 (76%) rename {Examples => source/Examples}/Resources/SqlAlias/2-RemoveSqlAlias.ps1 (71%) rename {Examples => source/Examples}/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 (73%) rename {Examples => source/Examples}/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 (73%) create mode 100644 source/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 create mode 100644 source/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 rename {Examples => source/Examples}/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 (65%) rename {Examples => source/Examples}/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 (76%) rename {Examples => source/Examples}/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 (77%) rename {Examples => source/Examples}/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 (70%) rename {Examples => source/Examples}/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 (78%) rename {Examples => source/Examples}/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 (74%) rename {Examples => source/Examples}/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 (70%) rename {Examples => source/Examples}/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 (64%) rename {Examples => source/Examples}/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1 (56%) rename {Examples => source/Examples}/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1 (56%) rename {Examples => source/Examples}/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1 (57%) rename {Examples => source/Examples}/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1 (55%) rename {Examples => source/Examples}/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1 (87%) rename {Examples => source/Examples}/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1 (86%) rename {Examples => source/Examples}/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1 (87%) rename {Examples => source/Examples}/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1 (87%) rename {Examples => source/Examples}/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1 (85%) create mode 100644 source/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 create mode 100644 source/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 create mode 100644 source/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 create mode 100644 source/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 rename {Examples => source/Examples}/Resources/SqlRSSetup/1-InstallReportingServices.ps1 (91%) rename {Examples => source/Examples}/Resources/SqlRSSetup/2-UninstallReportingServices.ps1 (92%) rename {Examples => source/Examples}/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 (79%) rename {Examples => source/Examples}/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 (84%) rename {Examples => source/Examples}/Resources/SqlScript/3-RunScriptCompleteExample.ps1 (92%) rename {Examples => source/Examples}/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1 (77%) rename {Examples => source/Examples}/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1 (80%) create mode 100644 source/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 create mode 100644 source/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 create mode 100644 source/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 create mode 100644 source/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 rename {Examples => source/Examples}/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1 (51%) rename {Examples => source/Examples}/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 (72%) rename {Examples => source/Examples}/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1 (79%) rename {Examples => source/Examples}/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 (70%) rename {Examples => source/Examples}/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 (77%) rename {Examples => source/Examples}/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 (77%) rename {Examples => source/Examples}/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 (80%) rename {Examples => source/Examples}/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 (84%) rename {Examples => source/Examples}/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 (65%) rename {Examples => source/Examples}/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 (75%) rename {Examples => source/Examples}/Resources/SqlServerLogin/1-AddLogin.ps1 (79%) rename {Examples => source/Examples}/Resources/SqlServerLogin/2-RemoveLogin.ps1 (63%) rename {Examples => source/Examples}/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 (67%) rename {Examples => source/Examples}/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 (50%) rename {Examples => source/Examples}/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 (63%) rename {Examples => source/Examples}/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 (68%) rename {Examples => source/Examples}/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 (51%) rename {Examples => source/Examples}/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 (65%) rename {Examples => source/Examples}/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 (63%) rename {Examples => source/Examples}/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 (64%) rename {Examples => source/Examples}/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 (62%) rename {Examples => source/Examples}/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 (95%) rename {Examples => source/Examples}/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 (85%) rename {Examples => source/Examples}/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 (73%) rename {Examples => source/Examples}/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 (75%) rename {Examples => source/Examples}/Resources/SqlServerRole/1-AddServerRole.ps1 (65%) rename {Examples => source/Examples}/Resources/SqlServerRole/2-RemoveServerRole.ps1 (60%) rename {Examples => source/Examples}/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 (57%) rename {Examples => source/Examples}/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 (57%) rename {Examples => source/Examples}/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 (57%) rename {Examples => source/Examples}/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1 (53%) rename {Examples => source/Examples}/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1 (52%) create mode 100644 source/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 create mode 100644 source/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 rename {Examples => source/Examples}/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 (59%) create mode 100644 source/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 rename {Examples => source/Examples}/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 (94%) rename {Examples => source/Examples}/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 (94%) rename {Examples => source/Examples}/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 (95%) rename {Examples => source/Examples}/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 (92%) rename {Examples => source/Examples}/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 (93%) rename {Examples => source/Examples}/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1 (94%) rename {Examples => source/Examples}/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1 (95%) rename {Examples => source/Examples}/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 (80%) rename {Examples => source/Examples}/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 (81%) rename {Examples => source/Examples}/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 (74%) rename {Examples => source/Examples}/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 (74%) create mode 100644 source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 rename {Modules => source/Modules}/SqlServerDsc.Common/SqlServerDsc.Common.psm1 (98%) rename {Modules => source/Modules}/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 (100%) rename {Modules => source/Modules}/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 (100%) create mode 100644 source/SqlServerDsc.psd1 create mode 100644 source/en-US/about_SqlServerDsc.help.txt rename {Tests => tests}/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1 (80%) rename {Tests => tests}/Integration/MSFT_SqlAgentAlert.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1 (80%) rename {Tests => tests}/Integration/MSFT_SqlAgentFailsafe.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1 (80%) rename {Tests => tests}/Integration/MSFT_SqlAgentOperator.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 (86%) rename {Tests => tests}/Integration/MSFT_SqlAlwaysOnService.config.ps1 (97%) rename {Tests => tests}/Integration/MSFT_SqlDatabase.Integration.Tests.ps1 (86%) rename {Tests => tests}/Integration/MSFT_SqlDatabase.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 (85%) rename {Tests => tests}/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1 (95%) rename {Tests => tests}/Integration/MSFT_SqlDatabaseUser.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlRS.Integration.Tests.ps1 (92%) rename {Tests => tests}/Integration/MSFT_SqlRS.config.ps1 (97%) rename {Tests => tests}/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1 (75%) rename {Tests => tests}/Integration/MSFT_SqlRSSetup.config.ps1 (97%) rename {Tests => tests}/Integration/MSFT_SqlScript.Integration.Tests.ps1 (86%) rename {Tests => tests}/Integration/MSFT_SqlScript.config.ps1 (99%) rename {Tests => tests}/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1 (76%) rename {Tests => tests}/Integration/MSFT_SqlScriptQuery.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1 (84%) rename {Tests => tests}/Integration/MSFT_SqlServerDatabaseMail.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1 (81%) rename {Tests => tests}/Integration/MSFT_SqlServerEndPoint.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1 (92%) rename {Tests => tests}/Integration/MSFT_SqlServerLogin.config.ps1 (99%) rename {Tests => tests}/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1 (82%) rename {Tests => tests}/Integration/MSFT_SqlServerNetwork.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlServerRole.Integration.Tests.ps1 (93%) rename {Tests => tests}/Integration/MSFT_SqlServerRole.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1 (79%) rename {Tests => tests}/Integration/MSFT_SqlServerSecureConnection.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1 (94%) rename {Tests => tests}/Integration/MSFT_SqlServiceAccount.config.ps1 (98%) rename {Tests => tests}/Integration/MSFT_SqlSetup.Integration.Tests.ps1 (95%) rename {Tests => tests}/Integration/MSFT_SqlSetup.config.ps1 (97%) rename {Tests => tests}/Integration/README.md (98%) rename {Tests => tests}/TestHelpers/CommonTestHelper.psm1 (82%) rename {Tests => tests}/Tests.depend.psd1 (100%) rename {Tests => tests}/Unit/MSFT_SqlAG.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlAGDatabase.Tests.ps1 (99%) rename {Tests => tests}/Unit/MSFT_SqlAGListener.Tests.ps1 (97%) rename {Tests => tests}/Unit/MSFT_SqlAGReplica.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlAgentAlert.Tests.ps1 (96%) rename {Tests => tests}/Unit/MSFT_SqlAgentFailsafe.Tests.ps1 (94%) rename {Tests => tests}/Unit/MSFT_SqlAgentOperator.Tests.ps1 (95%) rename {Tests => tests}/Unit/MSFT_SqlAlias.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 (92%) rename {Tests => tests}/Unit/MSFT_SqlDatabase.Tests.ps1 (95%) rename {Tests => tests}/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 (92%) rename {Tests => tests}/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 (93%) rename {Tests => tests}/Unit/MSFT_SqlDatabasePermission.Tests.ps1 (97%) rename {Tests => tests}/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 (92%) rename {Tests => tests}/Unit/MSFT_SqlDatabaseRole.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlDatabaseUser.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlRS.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlRSSetup.Tests.ps1 (97%) rename {Tests => tests}/Unit/MSFT_SqlScript.Tests.ps1 (89%) rename {Tests => tests}/Unit/MSFT_SqlScriptQuery.Tests.ps1 (87%) rename {Tests => tests}/Unit/MSFT_SqlServerConfiguration.Tests.ps1 (93%) rename {Tests => tests}/Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 (97%) rename {Tests => tests}/Unit/MSFT_SqlServerEndpoint.Tests.ps1 (97%) rename {Tests => tests}/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 (93%) rename {Tests => tests}/Unit/MSFT_SqlServerEndpointState.Tests.ps1 (92%) rename {Tests => tests}/Unit/MSFT_SqlServerLogin.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlServerMaxDop.Tests.ps1 (95%) rename {Tests => tests}/Unit/MSFT_SqlServerMemory.Tests.ps1 (97%) rename {Tests => tests}/Unit/MSFT_SqlServerNetwork.Tests.ps1 (96%) rename {Tests => tests}/Unit/MSFT_SqlServerPermission.Tests.ps1 (93%) rename {Tests => tests}/Unit/MSFT_SqlServerReplication.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlServerRole.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlServerSecureConnection.Tests.ps1 (97%) rename {Tests => tests}/Unit/MSFT_SqlServiceAccount.Tests.ps1 (98%) rename {Tests => tests}/Unit/MSFT_SqlSetup.Tests.ps1 (99%) rename {Tests => tests}/Unit/MSFT_SqlWaitForAG.Tests.ps1 (90%) rename {Tests => tests}/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 (98%) rename {Tests => tests}/Unit/SqlServerDsc.Common.Tests.ps1 (99%) rename {Tests => tests}/Unit/Stubs/SMO.cs (100%) rename {Tests => tests}/Unit/Stubs/SQLPSStub.psm1 (99%) rename {Tests => tests}/Unit/Stubs/SQLServerStub.psm1 (99%) rename {Tests => tests}/Unit/Stubs/SqlPowerShellSqlExecutionException.cs (100%) rename {Tests => tests}/Unit/Stubs/Write-ModuleStubFile.ps1 (100%) diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json deleted file mode 100644 index 0fc407ad5..000000000 --- a/.MetaTestOptIn.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - "Common Tests - Validate Markdown Files", - "Common Tests - Validate Module Files", - "Common Tests - Validate Script Files", - "Common Tests - Validate Example Files", - "Common Tests - Required Script Analyzer Rules", - "Common Tests - New Error-Level Script Analyzer Rules", - "Common Tests - Custom Script Analyzer Rules", - "Common Tests - Validate Markdown Links", - "Common Tests - Relative Path Length", - "Common Tests - Validate Localization", - "Common Tests - Flagged Script Analyzer Rules" -] diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 29a05dd15..000000000 --- a/.codecov.yml +++ /dev/null @@ -1,24 +0,0 @@ -codecov: - notify: - require_ci_to_pass: no - -comment: - layout: "reach, diff" - behavior: default - -coverage: - range: 50..80 - round: down - precision: 0 - - status: - project: - default: - # Set the overall project code coverage requirement to 70% - target: 70 - patch: - default: - # Set the pull request requirement to not regress overall coverage by more than 5% - # and let codecov.io set the goal for the code changed in the patch. - target: auto - threshold: 5 diff --git a/.gitattributes b/.gitattributes index 5613d5331..d49b050c9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,8 @@ # Needed for publishing of examples, build worker defaults to core.autocrlf=input. * text eol=crlf + +# Ensure any exe files are treated as binary +*.exe binary +*.jpg binary +*.xl* binary +*.pfx binary diff --git a/.github/ISSUE_TEMPLATE/Problem_with_resource.md b/.github/ISSUE_TEMPLATE/Problem_with_resource.md index f87ecb529..115745876 100644 --- a/.github/ISSUE_TEMPLATE/Problem_with_resource.md +++ b/.github/ISSUE_TEMPLATE/Problem_with_resource.md @@ -66,7 +66,7 @@ about: If you have a problem, bug, or enhancement with a resource in this resour $PSVersionTable --> -#### Version of the DSC module that was used ('dev' if using current dev branch) +#### Version of the DSC module that was used #### This Pull Request (PR) fixes the following issues #### Task list @@ -37,14 +38,16 @@ Change to [x] for each task in the task list that applies to your PR. For those task that don't apply to you PR, leave those as is. --> -- [ ] Added an entry under the Unreleased section of the change log in the CHANGELOG.md. - Entry should say what was changed, and how that affects users (if applicable). +- [ ] Added an entry to the change log under the Unreleased section of the + file CHANGELOG.md. Entry should say what was changed and how that + affects users (if applicable), and reference the issue being resolved + (if applicable). - [ ] Resource documentation added/updated in README.md. - [ ] Resource parameter descriptions added/updated in README.md, schema.mof and comment-based help. - [ ] Comment-based help added/updated. - [ ] Localization strings added/updated in all localization files as appropriate. - [ ] Examples appropriately added/updated. -- [ ] Unit tests added/updated. See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). -- [ ] Integration tests added/updated (where possible). See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). -- [ ] New/changed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md). +- [ ] Unit tests added/updated. See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] Integration tests added/updated (where possible). See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] New/changed code adheres to [DSC Community Style Guidelines](https://dsccommunity.org/styleguidelines). diff --git a/.gitignore b/.gitignore index 6094d6df2..1733276fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -DscResource.Tests -DSCResource.Tests -.vs .vscode -node_modules +.vs +output/ diff --git a/.vscode/analyzersettings.psd1 b/.vscode/analyzersettings.psd1 index 8e184abcd..b1bdba876 100644 --- a/.vscode/analyzersettings.psd1 +++ b/.vscode/analyzersettings.psd1 @@ -1,11 +1,6 @@ @{ - <# - For the custom rules to work, the DscResource.Tests repo must be - cloned. It is automatically clone as soon as any unit or - integration tests are run. - #> - CustomRulePath = '.\DSCResource.Tests\DscResource.AnalyzerRules' - + CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules' + IncludeDefaultRules = $true IncludeRules = @( # DSC Resource Kit style guideline rules. 'PSAvoidDefaultValueForMandatoryParameter', @@ -43,13 +38,7 @@ 'PSUseDeclaredVarsMoreThanAssignments', 'PSUsePSCredentialType', - <# - This is to test all the DSC Resource Kit custom rules. - The name of the function-blocks of each custom rule start - with 'Measure*'. - #> 'Measure-*' ) - IncludeDefaultRules = $true } diff --git a/.vscode/settings.json b/.vscode/settings.json index 0969e57b0..93d9aae73 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "powershell.codeFormatting.openBraceOnSameLine": false, - "powershell.codeFormatting.newLineAfterOpenBrace": false, + "powershell.codeFormatting.newLineAfterOpenBrace": true, "powershell.codeFormatting.newLineAfterCloseBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenParen": true, @@ -8,7 +8,31 @@ "powershell.codeFormatting.whitespaceAfterSeparator": true, "powershell.codeFormatting.ignoreOneLineBlock": false, "powershell.codeFormatting.preset": "Custom", + "powershell.codeFormatting.alignPropertyValuePairs": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1" + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1", + "powershell.scriptAnalysis.enable": true, + "files.associations": { + "*.ps1xml": "xml" + }, + "cSpell.words": [ + "COMPANYNAME", + "ICONURI", + "LICENSEURI", + "PROJECTURI", + "RELEASENOTES", + "buildhelpers", + "endregion", + "gitversion", + "icontains", + "keepachangelog", + "notin", + "pscmdlet", + "steppable" + ], + "[markdown]": { + "files.trimTrailingWhitespace": false, + "files.encoding": "utf8" + } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..4085e3e72 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,125 @@ +{ + "version": "2.0.0", + "_runner": "terminal", + "windows": { + "options": { + "shell": { + "executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "args": [ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-Command" + ] + } + } + }, + "linux": { + "options": { + "shell": { + "executable": "/usr/bin/pwsh", + "args": [ + "-NoProfile", + "-Command" + ] + } + } + }, + "osx": { + "options": { + "shell": { + "executable": "/usr/local/bin/pwsh", + "args": [ + "-NoProfile", + "-Command" + ] + } + } + }, + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "&${cwd}/build.ps1", + "args": ["-AutoRestore"], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "new", + "clear": false + }, + "runOptions": { + "runOn": "default" + }, + "problemMatcher": [ + { + "owner": "powershell", + "fileLocation": [ + "absolute" + ], + "severity": "error", + "pattern": [ + { + "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", + "message": 1 + }, + { + "regexp": "(.*)", + "code": 1 + }, + { + "regexp": "" + }, + { + "regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*", + "file": 1, + "line": 2 + } + ] + } + ] + }, + { + "label": "test", + "type": "shell", + "command": "&${cwd}/build.ps1", + "args": ["-AutoRestore","-Tasks","test"], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [ + { + "owner": "powershell", + "fileLocation": [ + "absolute" + ], + "severity": "error", + "pattern": [ + { + "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", + "message": 1 + }, + { + "regexp": "(.*)", + "code": 1 + }, + { + "regexp": "" + }, + { + "regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*", + "file": 1, + "line": 2 + } + ] + } + ] + } + ] +} diff --git a/Assert-TestEnvironment.ps1 b/Assert-TestEnvironment.ps1 deleted file mode 100644 index 1c3201125..000000000 --- a/Assert-TestEnvironment.ps1 +++ /dev/null @@ -1,105 +0,0 @@ -<# - .SYNOPSIS - Assert that the test environment is properly setup and loaded into the - PowerShell session. - - .DESCRIPTION - Assert that the test environment is properly setup and loaded into the - PowerShell session. - - .EXAMPLE - .\Assert-testEnvironment.ps1 - - Will assert that the current PowerShell session is ready to run tests. -#> - -[CmdletBinding(SupportsShouldProcess = $true)] -param -( -) - -#region Verify prerequisites Pester -$pesterModuleName = 'Pester' - -# This is the minimum version that can be used with the tests in this repo. -$pesterModuleMinimumVersion = '4.0.2' - -<# - Pester v4.4.0 has a fix for '-Not -Throw' so it shows the actual error - message if an unexpected exception does occur. It will help when debugging - tests. - If no Pester module exist, then use this as the minimum version. -#> -$pesterModuleRecommendedMinimumVersion = '4.4.0' - -$pesterModule = Get-Module $pesterModuleName -ListAvailable -Verbose:$false | - Where-Object -Property 'Version' -GE -Value $pesterModuleMinimumVersion | - Sort-Object -Property 'Version' -Descending | - Select-Object -First 1 - -$dependencyMissing = $false - -if (-not $pesterModule) -{ - <# - Not installing the module here because it's not known what scope the - user want (can) to install the module in. - #> - $message = 'Missing a compatible version of the {0} module. Minimum version of {0} module can be ''{2}'', but the recommended minimum version is ''{1}''.' -f $pesterModuleName, $pesterModuleRecommendedMinimumVersion, $pesterModuleMinimumVersion - Write-Warning -Message $message - $dependencyMissing = $true -} -else -{ - Write-Verbose -Message ('A compatible {0} module is already installed (v{1}). If you want to use a newer version of {0} module, please install it manually.' -f $pesterModule.Name, $pesterModule.Version) -} -#endregion Verify prerequisites Pester - -#region Verify prerequisites PSDepend -$psDependModuleName = 'PSDepend' - -# This is the minimum version that can be used with the tests in this repo. -$psDependModuleMinimumVersion = '0.3.0' -$psDependModuleRecommendedMinimumVersion = 'latest' - -$psDependModule = Get-Module $psDependModuleName -ListAvailable -Verbose:$false | - Where-Object -Property 'Version' -GE -Value $psDependModuleMinimumVersion | - Sort-Object -Property 'Version' -Descending | - Select-Object -First 1 - -if (-not $psDependModule) -{ - <# - Not installing the module here because it's not known what scope the - user want (can) to install the module in. - #> - $message = 'Missing a compatible version of the {0} module. Minimum version of {0} module can be ''{2}'', but the recommended minimum version is ''{1}''. Please install {0} module manually, then run this script again.' -f $psDependModuleName, $psDependModuleRecommendedMinimumVersion, $psDependModuleMinimumVersion - Write-Warning -Message $message - $dependencyMissing = $true -} -else -{ - Write-Verbose -Message ('A compatible {0} module is already installed (v{1}). If you want to use a newer version of {0} module, please install it manually.' -f $psDependModule.Name, $psDependModule.Version) -} -#endregion Verify prerequisites PSDepend - -if ($dependencyMissing) -{ - Write-Output -InputObject 'Please install the necessary dependencies manually, then run this script again.' - return -} - -$dependenciesPath = Join-Path $PSScriptRoot -ChildPath 'Tests' - -Write-Verbose -Message ('Running Invoke-PSDepend using dependencies found under the path ''{0}''.' -f $dependenciesPath) - -if ($PSBoundParameters.ContainsKey('Confirm')) -{ - $invokePSDependConfirmation = $ConfirmPreference -} -else -{ - $invokePSDependConfirmation = $false -} - -Invoke-PSDepend -Path $dependenciesPath -Confirm:$invokePSDependConfirmation diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ba1e472c..2307c82da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,1959 +1,35 @@ # Change log for SqlServerDsc -## Unreleased +The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -- Changes to SqlServerDsc - - Add .gitattributes file to checkout file correctly with CRLF. - - Updated .vscode/analyzersettings.psd1 file to correct use PSSA rules - and custom rules in VS Code. - - Fix hashtables to align with style guideline ([issue #1437](https://github.com/PowerShell/SqlServerDsc/issues/1437)). -- Changes to SqlServerMaxDop - - Fix line endings in code which did not use the correct format. - -## 13.2.0.0 - -- Changes to SqlServerDsc - - Fix keywords to lower-case to align with guideline. - - Fix keywords to have space before a parenthesis to align with guideline. - - Fix typo in SqlSetup strings ([issue #1419](https://github.com/PowerShell/SqlServerDsc/issues/1419)). - -## 13.1.0.0 - -- Changes to SqlServerDsc - - New DSC resource SqlAgentFailsafe - - New DSC resource SqlDatabaseUser ([issue #846](https://github.com/PowerShell/SqlServerDsc/issues/846)). - - Adds ability to create database users with more fine-grained control, - e.g. re-mapping of orphaned logins or a different login. Supports - creating a user with or without login name, and database users mapped - to a certificate or asymmetric key. - - Changes to helper function Invoke-Query - - Fixes issues in [issue #1355](https://github.com/PowerShell/SqlServerDsc/issues/1355). - - Works together with Connect-SQL now. - - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). - - Can now pass in credentials. - - Can now pass in 'Microsoft.SqlServer.Management.Smo.Server' object. - - Can also pipe in 'Microsoft.SqlServer.Management.Smo.Server' object. - - Can pipe Connect-SQL | Invoke-Query. - - Added default values to Invoke-Query. - - Now it will output verbose messages of the query that is run, so it - not as quiet of what it is doing when a user asks for verbose output - ([issue #1404](https://github.com/PowerShell/SqlServerDsc/issues/1404)). - - It is possible to redact text in the verbose output by providing - strings in the new parameter `RedactText`. - - Minor style fixes in unit tests. - - Changes to helper function Connect-SQL - - When impersonating WindowsUser credential use the NetworkCredential UserName. - - Added additional verbose logging. - - Connect-SQL now uses parameter sets to more intuitive evaluate that - the correct parameters are used in different scenarios - ([issue #1403](https://github.com/PowerShell/SqlServerDsc/issues/1403)). - - Changes to helper function Connect-SQLAnalysis - - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). - - Changes to helper function Restart-SqlService - - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). - - Changes to helper function Restart-ReportingServicesService - - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). - - Changes to helper function Split-FullSqlInstanceName - - Parameters and function name changed to use correct casing. - - Changes to helper function Get-SqlInstanceMajorVersion - - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). - - Changes to helper function Test-LoginEffectivePermissions - - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). - - Changes to helper function Test-AvailabilityReplicaSeedingModeAutomatic - - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). -- Changes to SqlServerSecureConnection - - Forced $Thumbprint to lowercase to fix [issue #1350](https://github.com/PowerShell/SqlServerDsc/issues/1350). - - Add parameter SuppressRestart with default value false. - This allows users to suppress restarts after changes have been made. - Changes will not take effect until the service has been restarted. -- Changes to SqlSetup - - Correct minor style violation [issue #1387](https://github.com/PowerShell/SqlServerDsc/issues/1387). -- Changes to SqlDatabase - - Get-TargetResource now correctly return `$null` for the collation property - when the database does not exist ([issue #1395](https://github.com/PowerShell/SqlServerDsc/issues/1395)). - - No longer enforces the collation property if the Collation parameter - is not part of the configuration ([issue #1396](https://github.com/PowerShell/SqlServerDsc/issues/1396)). - - Updated resource description in README.md - - Fix examples to use `PsDscRunAsCredential` ([issue #760](https://github.com/PowerShell/SqlServerDsc/issues/760)). - - Added integration tests ([issue #739](https://github.com/PowerShell/SqlServerDsc/issues/739)). - - Updated unit tests to the latest template ([issue #1068](https://github.com/PowerShell/SqlServerDsc/issues/1068)). - -## 13.0.0.0 - -- Changes to SqlServerDsc - - Added SqlAgentAlert resource. - - Opt-in to the common test 'Common Test - Validation Localization'. - - Opt-in to the common test 'Common Test - Flagged Script Analyzer Rules' - ([issue #1101](https://github.com/PowerShell/SqlServerDsc/issues/1101)). - - Removed the helper function `New-TerminatingError`, `New-WarningMessage` - and `New-VerboseMessage` in favor of the the new - [localization helper functions](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#localization). - - Combine DscResource.LocalizationHelper and DscResource.Common into - SqlServerDsc.Common ([issue #1357](https://github.com/PowerShell/SqlServerDsc/issues/1357)). - - Update Assert-TestEnvironment.ps1 to not error if strict mode is enabled - and there are no missing dependencies ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). -- Changes to SqlServerDsc.Common - - Added StatementTimeout to function 'Connect-SQL' with default 600 seconds (10mins). - - Added StatementTimeout to function 'Invoke-Query' with default 600 seconds (10mins) - ([issue #1358](https://github.com/PowerShell/SqlServerDsc/issues/1358)). - - Changes to helper function Connect-SQL - - The function now make it more clear that when using the parameter - `SetupCredential` is impersonates that user, and by default it does - not impersonates a user but uses the credential that the resource - is run as (for example the built-in credential parameter - `PsDscRunAsCredential`). [@kungfu71186](https://github.com/kungfu71186) - - Added parameter alias `-DatabaseCredential` for the parameter - `-SetupCredential`. [@kungfu71186](https://github.com/kungfu71186) -- Changes to SqlAG - - Added en-US localization. -- Changes to SqlAGReplica - - Added en-US localization. - - Improved verbose message output when creating availability group replica, - removing a availability group replica, and joining the availability - group replica to the availability group. -- Changes to SqlAlwaysOnService - - Now outputs the correct verbose message when restarting the service. -- Changes to SqlServerMemory - - Now outputs the correct verbose messages when calculating the dynamic - memory, and when limiting maximum memory. -- Changes to SqlServerRole - - Now outputs the correct verbose message when the members of a role is - not in desired state. -- Changes to SqlAgentOperator - - Fix minor issue that when unable to connect to an instance. Instead - of showing a message saying that connect failed another unrelated - error message could have been shown, because of an error in the code. - - Fix typo in test it block. -- Changes to SqlDatabaseRole - - BREAKING CHANGE: Refactored to enable creation/deletion of the database role - itself as well as management of the role members. *Note that the resource no - longer adds database users.* ([issue #845](https://github.com/PowerShell/SqlServerDsc/issues/845), - [issue #847](https://github.com/PowerShell/SqlServerDsc/issues/847), - [issue #1252](https://github.com/PowerShell/SqlServerDsc/issues/1252), - [issue #1339](https://github.com/PowerShell/SqlServerDsc/issues/1339)). - [Paul Shamus @pshamus](https://github.com/pshamus) -- Changes to SqlSetup - - Add an Action type of 'Upgrade'. This will ask setup to do a version - upgrade where possible ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). - - Fix an error when testing for DQS installation ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). - - Changed the logic of how default value of FailoverClusterGroupName is - set since that was preventing the resource to be able to be debugged - ([issue #448](https://github.com/PowerShell/SqlServerDsc/issues/448)). - - Added RSInstallMode parameter ([issue #1163](https://github.com/PowerShell/SqlServerDsc/issues/1163)). -- Changes to SqlWindowsFirewall - - Where a version upgrade has changed paths for a database engine, the - existing firewall rule for that instance will be updated rather than - another one created ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). - Other firewall rules can be fixed to work in the same way later. -- Changes to SqlAGDatabase - - Added new parameter 'ReplaceExisting' with default false. - This allows forced restores when a database already exists on secondary. - - Added StatementTimeout to Invoke-Query to fix Issue#1358 - - Fix issue where calling Get would return an error because the database - name list may have been returned as a string instead of as a string array - ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). - -## 12.5.0.0 - -- Changes to SqlServerSecureConnection - - Updated README and added example for SqlServerSecureConnection, - instructing users to use the 'SYSTEM' service account instead of - 'LocalSystem'. -- Changes to SqlScript - - Correctly passes the `$VerbosePreference` to the helper function - `Invoke-SqlScript` so that `PRINT` statements is outputted correctly - when verbose output is requested, e.g - `Start-DscConfiguration -Verbose`. - - Added en-US localization ([issue #624](https://github.com/PowerShell/SqlServerDsc/issues/624)). - - Added additional unit tests for code coverage. -- Changes to SqlScriptQuery - - Correctly passes the `$VerbosePreference` to the helper function - `Invoke-SqlScript` so that `PRINT` statements is outputted correctly - when verbose output is requested, e.g - `Start-DscConfiguration -Verbose`. - - Added en-US localization. - - Added additional unit tests for code coverage. -- Changes to SqlSetup - - Concatenated Robocopy localization strings ([issue #694](https://github.com/PowerShell/SqlServerDsc/issues/694)). - - Made the error message more descriptive when the Set-TargetResource - function calls the Test-TargetResource function to verify the desired - state. -- Changes to SqlWaitForAG - - Added en-US localization ([issue #625](https://github.com/PowerShell/SqlServerDsc/issues/625)). -- Changes to SqlServerPermission - - Added en-US localization ([issue #619](https://github.com/PowerShell/SqlServerDsc/issues/619)). -- Changes to SqlServerMemory - - Added en-US localization ([issue #617](https://github.com/PowerShell/SqlServerDsc/issues/617)). - - No longer will the resource set the MinMemory value if it was provided - in a configuration that also set the `Ensure` parameter to 'Absent' - ([issue #1329](https://github.com/PowerShell/SqlServerDsc/issues/1329)). - - Refactored unit tests to simplify them add add slightly more code - coverage. -- Changes to SqlServerMaxDop - - Added en-US localization ([issue #616](https://github.com/PowerShell/SqlServerDsc/issues/616)). -- Changes to SqlRS - - Reporting Services are restarted after changing settings, unless - `$SuppressRestart` parameter is set ([issue #1331](https://github.com/PowerShell/SqlServerDsc/issues/1331)). - `$SuppressRestart` will also prevent Reporting Services restart after initialization. - - Fixed one of the error handling to use localization, and made the - error message more descriptive when the Set-TargetResource function - calls the Test-TargetResource function to verify the desired - state. *This was done prior to adding full en-US localization.* - - Fixed ([issue #1258](https://github.com/PowerShell/SqlServerDsc/issues/1258)). - When initializing Reporting Services, there is no need to execute `InitializeReportServer` - CIM method, since executing `SetDatabaseConnection` CIM method initializes - Reporting Services. - - [issue #864](https://github.com/PowerShell/SqlServerDsc/issues/864) SqlRs - can now initialise SSRS 2017 instances -- Changes to SqlServerLogin - - Added en-US localization ([issue #615](https://github.com/PowerShell/SqlServerDsc/issues/615)). - - Added unit tests to improved code coverage. -- Changes to SqlWindowsFirewall - - Added en-US localization ([issue #614](https://github.com/PowerShell/SqlServerDsc/issues/614)). -- Changes to SqlServerEndpoint - - Added en-US localization ([issue #611](https://github.com/PowerShell/SqlServerDsc/issues/611)). -- Changes to SqlServerEndpointPermission - - Added en-US localization ([issue #612](https://github.com/PowerShell/SqlServerDsc/issues/612)). -- Changes to SqlServerEndpointState - - Added en-US localization ([issue #613](https://github.com/PowerShell/SqlServerDsc/issues/613)). -- Changes to SqlDatabaseRole - - Added en-US localization ([issue #610](https://github.com/PowerShell/SqlServerDsc/issues/610)). -- Changes to SqlDatabaseRecoveryModel - - Added en-US localization ([issue #609](https://github.com/PowerShell/SqlServerDsc/issues/609)). -- Changes to SqlDatabasePermission - - Added en-US localization ([issue #608](https://github.com/PowerShell/SqlServerDsc/issues/608)). -- Changes to SqlDatabaseOwner - - Added en-US localization ([issue #607](https://github.com/PowerShell/SqlServerDsc/issues/607)). -- Changes to SqlDatabase - - Added en-US localization ([issue #606](https://github.com/PowerShell/SqlServerDsc/issues/606)). -- Changes to SqlAGListener - - Added en-US localization ([issue #604](https://github.com/PowerShell/SqlServerDsc/issues/604)). -- Changes to SqlAlwaysOnService - - Added en-US localization ([issue #603](https://github.com/PowerShell/SqlServerDsc/issues/608)). -- Changes to SqlAlias - - Added en-US localization ([issue #602](https://github.com/PowerShell/SqlServerDsc/issues/602)). - - Removed ShouldProcess for the code, since it has no purpose in a DSC - resource ([issue #242](https://github.com/PowerShell/SqlServerDsc/issues/242)). -- Changes to SqlServerReplication - - Added en-US localization ([issue #620](https://github.com/PowerShell/SqlServerDsc/issues/620)). - - Refactored Get-TargetResource slightly so it provide better verbose - messages. - -## 12.4.0.0 - -- Changes to SqlServerDsc - - Added new resources. - - SqlRSSetup - - Added helper module DscResource.Common from the repository - DscResource.Template. - - Moved all helper functions from SqlServerDscHelper.psm1 to DscResource.Common. - - Renamed Test-SqlDscParameterState to Test-DscParameterState. - - New-TerminatingError error text for a missing localized message now matches - the output even if the "missing localized message" localized message is - also missing. - - Added helper module DscResource.LocalizationHelper from the repository - DscResource.Template, this replaces the helper module CommonResourceHelper.psm1. - - Cleaned up unit tests, mostly around loading cmdlet stubs and loading - classes stubs, but also some tests that were using some odd variants. - - Fix all integration tests according to issue [PowerShell/DscResource.Template#14](https://github.com/PowerShell/DscResource.Template/issues/14). -- Changes to SqlServerMemory - - Updated Cim Class to Win32_ComputerSystem (instead of Win32_PhysicalMemory) - because the correct memory size was not being detected correctly on Azure VMs - ([issue #914](https://github.com/PowerShell/SqlServerDsc/issues/914)). -- Changes to SqlSetup - - Split integration tests into two jobs, one for running integration tests - for SQL Server 2016 and another for running integration test for - SQL Server 2017 ([issue #858](https://github.com/PowerShell/SqlServerDsc/issues/858)). - - Localized messages for Master Data Services no longer start and end with - single quote. - - When installing features a verbose message is written if a feature is found - to already be installed. It no longer quietly removes the feature from the - `/FEATURES` argument. - - Cleaned up a bit in the tests, removed excessive piping. - - Fixed minor typo in examples. - - A new optional parameter `FeatureFlag` parameter was added to control - breaking changes. Functionality added under a feature flag can be - toggled on or off, and could be changed later to be the default. - This way we can also make more of the new functionalities the default - in the same breaking change release ([issue #1105](https://github.com/PowerShell/SqlServerDsc/issues/1105)). - - Added a new way of detecting if the shared feature CONN (Client Tools - Connectivity, and SQL Client Connectivity SDK), BC (Client Tools - Backwards Compatibility), and SDK (Client Tools SDK) is installed or - not. The new functionality is used when the parameter `FeatureFlag` - is set to `'DetectionSharedFeatures'` ([issue #1105](https://github.com/PowerShell/SqlServerDsc/issues/1105)). - - Added a new helper function `Get-InstalledSharedFeatures` to move out - some of the code from the `Get-TargetResource` to make unit testing - easier and faster. - - Changed the logic of 'Build the argument string to be passed to setup' to - not quote the value if root directory is specified - ([issue #1254](https://github.com/PowerShell/SqlServerDsc/issues/1254)). - - Moved some resource specific helper functions to the new helper module - DscResource.Common so they can be shared with the new resource SqlRSSetup. - - Improved verbose messages in Test-TargetResource function to more - clearly tell if features are already installed or not. - - Refactored unit tests for the functions Test-TargetResource and - Set-TargetResource to improve testing speed. - - Modified the Test-TargetResource and Set-TargetResource to not be - case-sensitive when comparing feature names. *This was handled - correctly in real-world scenarios, but failed when running the unit - tests (and testing casing).* -- Changes to SqlAGDatabase - - Fix MatchDatabaseOwner to check for CONTROL SERVER, IMPERSONATE LOGIN, or - CONTROL LOGIN permission in addition to IMPERSONATE ANY LOGIN. - - Update and fix MatchDatabaseOwner help text. -- Changes to SqlAG - - Updated documentation on the behaviour of defaults as they only apply when - creating a group. -- Changes to SqlAGReplica - - AvailabilityMode, BackupPriority, and FailoverMode defaults only apply when - creating a replica not when making changes to an existing replica. Explicit - parameters will still change existing replicas ([issue #1244](https://github.com/PowerShell/SqlServerDsc/issues/1244)). - - ReadOnlyRoutingList now gets updated without throwing an error on the first - run ([issue #518](https://github.com/PowerShell/SqlServerDsc/issues/518)). - - Test-Resource fixed to report whether ReadOnlyRoutingList desired state - has been reached correctly ([issue #1305](https://github.com/PowerShell/SqlServerDsc/issues/1305)). -- Changes to SqlDatabaseDefaultLocation - - No longer does the Test-TargetResource fail on the second test run - when the backup file path was changed, and the path was ending with - a backslash ([issue #1307](https://github.com/PowerShell/SqlServerDsc/issues/1307)). - -## 12.3.0.0 - -- Changes to SqlServerDsc - - Reverting the change that was made as part of the - [issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260) - in the previous release, as it only mitigated the issue, it did not - solve the issue. - - Removed the container testing since that broke the integration tests, - possible due to using excessive amount of memory on the AppVeyor build - worker. This will make the unit tests to take a bit longer to run - ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). - - The unit tests and the integration tests are now run in two separate - build workers in AppVeyor. One build worker runs the integration tests, - while a second build worker runs the unit tests. The build workers runs - in parallel on paid accounts, but sequentially on free accounts - ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). - - Clean up error handling in some of the integration tests that was - part of a workaround for a bug in Pester. The bug is resolved, and - the error handling is not again built into Pester. - - Speeding up the AppVeyor tests by splitting the common tests in a - separate build job. - - Updated the appveyor.yml to have the correct build step, and also - correct run the build step only in one of the jobs. - - Update integration tests to use the new integration test template. - - Added SqlAgentOperator resource. -- Changes to SqlServiceAccount - - Fixed Get-ServiceObject when searching for Integration Services service. - Unlike the rest of SQL Server services, the Integration Services service - cannot be instanced, however you can have multiple versions installed. - Get-Service object would return the correct service name that you - are looking for, but it appends the version number at the end. Added - parameter VersionNumber so the search would return the correct - service name. - - Added code to allow for using Managed Service Accounts. - - Now the correct service type string value is returned by the function - `Get-TargetResource`. Previously one value was passed in as a parameter - (e.g. `DatabaseEngine`), but a different string value as returned - (e.g. `SqlServer`). Now `Get-TargetResource` return the same values - that can be passed as values in the parameter `ServiceType` - ([issue #981](https://github.com/PowerShell/SqlServerDsc/issues/981)). -- Changes to SqlServerLogin - - Fixed issue in Test-TargetResource to valid password on disabled accounts - ([issue #915](https://github.com/PowerShell/SqlServerDsc/issues/915)). - - Now when adding a login of type SqlLogin, and the SQL Server login mode - is set to `'Integrated'`, an error is correctly thrown - ([issue #1179](https://github.com/PowerShell/SqlServerDsc/issues/1179)). -- Changes to SqlSetup - - Updated the integration test to stop the named instance while installing - the other instances to mitigate - [issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260). - - Add parameters to configure the Tempdb files during the installation of - the instance. The new parameters are SqlTempdbFileCount, SqlTempdbFileSize, - SqlTempdbFileGrowth, SqlTempdbLogFileSize and SqlTempdbLogFileGrowth - ([issue #1167](https://github.com/PowerShell/SqlServerDsc/issues/1167)). -- Changes to SqlServerEndpoint - - Add the optional parameter Owner. The default owner remains the login used - for the creation of the endpoint - ([issue #1251](https://github.com/PowerShell/SqlServerDsc/issues/1251)). - [Maxime Daniou (@mdaniou)](https://github.com/mdaniou) - - Add integration tests - ([issue #744](https://github.com/PowerShell/SqlServerDsc/issues/744)). - [Maxime Daniou (@mdaniou)](https://github.com/mdaniou) - -## 12.2.0.0 - -- Changes to SqlServerDsc - - During testing in AppVeyor the Build Worker is restarted in the install - step to make sure the are no residual changes left from a previous SQL - Server install on the Build Worker done by the AppVeyor Team - ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). - - Code cleanup: Change parameter names of Connect-SQL to align with resources. - - Updated README.md in the Examples folder. - - Added a link to the new xADObjectPermissionEntry examples in - ActiveDirectory, fixed a broken link and a typo. - [Adam Rush (@adamrushuk)](https://github.com/adamrushuk) -- Change to SqlServerLogin so it doesn't check properties for absent logins. - - Fix for ([issue #1096](https://github.com/PowerShell/SqlServerDsc/issues/1096)) - -## 12.1.0.0 - -- Changes to SqlServerDsc - - Add support for validating the code with the DSC ResourceKit - Script Analyzer rules, both in Visual Studio Code and directly using - `Invoke-ScriptAnalyzer`. - - Opt-in for common test "Common Tests - Validate Markdown Links". - - Updated broken links in `\README.md` and in `\Examples\README.md` - - Opt-in for common test 'Common Tests - Relative Path Length'. - - Updated the Installation section in the README.md. - - Updated the Contributing section in the README.md after - [Style Guideline and Best Practices guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) - has merged into one document. - - To speed up testing in AppVeyor, unit tests are now run in two containers. - - Adding the PowerShell script `Assert-TestEnvironment.ps1` which - must be run prior to running any unit tests locally with - `Invoke-Pester`. - Read more in the specific contributing guidelines, under the section - [Unit Tests](https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md#unit-tests). -- Changes to SqlServerDscHelper - - Fix style guideline lint errors. - - Changes to Connect-SQL - - Adding verbose message in Connect-SQL so it - now shows the username that is connecting. - - Changes to Import-SQLPS - - Fixed so that when importing SQLPS it imports - using the path (and not the .psd1 file). - - Fixed so that the verbose message correctly - shows the name, version and path when importing - the module SQLPS (it did show correctly for the - SqlServer module). -- Changes to SqlAg, SqlAGDatabase, and SqlAGReplica examples - - Included configuration for SqlAlwaysOnService to enable - HADR on each node to avoid confusion - ([issue #1182](https://github.com/PowerShell/SqlServerDsc/issues/1182)). -- Changes to SqlServerDatabaseMail - - Minor update to Ensure parameter description in the README.md. -- Changes to Write-ModuleStubFile.ps1 - - Create aliases for cmdlets in the stubbed module which have aliases - ([issue #1224](https://github.com/PowerShell/SqlServerDsc/issues/1224)). - [Dan Reist (@randomnote1)](https://github.com/randomnote1) - - Use a string builder to build the function stubs. - - Fixed formatting issues for the function to work with modules other - than SqlServer. -- New DSC resource SqlServerSecureConnection - - New resource to configure a SQL Server instance for encrypted SQL - connections. -- Changes to SqlAlwaysOnService - - Updated integration tests to use NetworkingDsc - ([issue #1129](https://github.com/PowerShell/SqlServerDsc/issues/1129)). -- Changes to SqlServiceAccount - - Fix unit tests that didn't mock some of the calls. It no longer fail - when a SQL Server installation is not present on the node running the - unit test ([issue #983](https://github.com/PowerShell/SqlServerDsc/issues/983)). - -## 12.0.0.0 - -- Changes to SqlServerDatabaseMail - - DisplayName is now properly treated as display name - for the originating email address ([issue #1200](https://github.com/PowerShell/SqlServerDsc/issue/1200)). - [Nick Reilingh (@NReilingh)](https://github.com/NReilingh) - - DisplayName property now defaults to email address instead of server name. - - Minor improvements to documentation. -- Changes to SqlAGDatabase - - Corrected reference to "PsDscRunAsAccount" in documentation - ([issue #1199](https://github.com/PowerShell/SqlServerDsc/issues/1199)). - [Nick Reilingh (@NReilingh)](https://github.com/NReilingh) -- Changes to SqlDatabaseOwner - - BREAKING CHANGE: Support multiple instances on the same node. - The parameter InstanceName is now Key and cannot be omitted - ([issue #1197](https://github.com/PowerShell/SqlServerDsc/issues/1197)). -- Changes to SqlSetup - - Added new parameters to allow to define the startup types for the Sql Engine - service, the Agent service, the Analysis service and the Integration Service. - The new optional parameters are respectively SqlSvcStartupType, AgtSvcStartupType, - AsSvcStartupType, IsSvcStartupType and RsSvcStartupType ([issue #1165](https://github.com/PowerShell/SqlServerDsc/issues/1165). - [Maxime Daniou (@mdaniou)](https://github.com/mdaniou) - -## 11.4.0.0 - -- Changes to SqlServerDsc - - Updated helper function Restart-SqlService to have to new optional parameters - `SkipClusterCheck` and `SkipWaitForOnline`. This was to support more aspects - of the resource SqlServerNetwork. - - Updated helper function `Import-SQLPSModule` - - To only import module if the - module does not exist in the session. - - To always import the latest version of 'SqlServer' or 'SQLPS' module, if - more than one version exist on the target node. It will still prefer to - use 'SqlServer' module. - - Updated all the examples and integration tests to not use - `PSDscAllowPlainTextPassword`, so examples using credentials or - passwords by default are secure. -- Changes to SqlAlwaysOnService - - Integration tests was updated to handle new IPv6 addresses on the AppVeyor - build worker ([issue #1155](https://github.com/PowerShell/SqlServerDsc/issues/1155)). -- Changes to SqlServerNetwork - - Refactor SqlServerNetwork to not load assembly from GAC ([issue #1151](https://github.com/PowerShell/SqlServerDsc/issues/1151)). - - The resource now supports restarting the SQL Server service when both - enabling and disabling the protocol. - - Added integration tests for this resource - ([issue #751](https://github.com/PowerShell/SqlServerDsc/issues/751)). -- Changes to SqlAG - - Removed excess `Import-SQLPSModule` call. -- Changes to SqlSetup - - Now after a successful install the "SQL PowerShell module" is reevaluated and - forced to be reimported into the session. This is to support that a never - version of SQL Server was installed side-by-side so that SQLPS module should - be used instead. - -## 11.3.0.0 - -- Changes to SqlServerDsc - - Moved decoration for integration test to resolve a breaking change in - DscResource.Tests. - - Activated the GitHub App Stale on the GitHub repository. - - Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md - [issue #939](https://github.com/PowerShell/SqlServerDsc/issues/939). - - New resources: - - Added SqlScriptQueryResource. [Chase Wilson (@chasewilson)](https://github.com/chasewilson) - - Fix for issue #779 [Paul Kelly (@prkelly)](https://github.com/prkelly) - -## 11.2.0.0 - -- Changes to SqlServerDsc - - Added new test helper functions in the CommonTestHelpers module. These are used - by the integration tests. - - **New-IntegrationLoopbackAdapter:** Installs the PowerShell module - 'LoopbackAdapter' from PowerShell Gallery and creates a new network - loopback adapter. - - **Remove-IntegrationLoopbackAdapter:** Removes a new network loopback adapter. - - **Get-NetIPAddressNetwork:** Returns the IP network address from an IPv4 address - and prefix length. - - Enabled PSSA rule violations to fail build in the CI environment. - - Renamed SqlServerDsc.psd1 to be consistent - ([issue #1116](https://github.com/PowerShell/SqlServerDsc/issues/1116)). - [Glenn Sarti (@glennsarti)](https://github.com/glennsarti) -- Changes to Unit Tests - - Updated - the following resources unit test template to version 1.2.1 - - SqlWaitForAG ([issue #1088](https://github.com/PowerShell/SqlServerDsc/issues/1088)). - [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode) -- Changes to SqlAlwaysOnService - - Updated the integration tests to use a loopback adapter to be less intrusive - in the build worker environment. - - Minor code cleanup in integration test, fixed the scope on variable. -- Changes to SqlSetup - - Updated the integration tests to stop some services after each integration test. - This is to save memory on the AppVeyor build worker. - - Updated the integration tests to use a SQL Server 2016 Service Pack 1. - - Fixed Script Analyzer rule error. -- Changes to SqlRS - - Updated the integration tests to stop the Reporting Services service after - the integration test. This is to save memory on the AppVeyor build worker. - - The helper function `Restart-ReportingServicesService` should no longer timeout - when restarting the service ([issue #1114](https://github.com/PowerShell/SqlServerDsc/issues/1114)). -- Changes to SqlServiceAccount - - Updated the integration tests to stop some services after each integration test. - This is to save memory on the AppVeyor build worker. -- Changes to SqlServerDatabaseMail - - Fixed Script Analyzer rule error. - -## 11.1.0.0 - -- Changes to SqlServerDsc - - Updated the PULL\_REQUEST\_TEMPLATE with an improved task list and modified - some text to be clearer ([issue #973](https://github.com/PowerShell/SqlServerDsc/issues/973)). - - Updated the ISSUE_TEMPLATE to hopefully be more intuitive and easier to use. - - Added information to ISSUE_TEMPLATE that issues must be reproducible in - SqlServerDsc resource module (if running the older xSQLServer resource module) - ([issue #1036](https://github.com/PowerShell/SqlServerDsc/issues/1036)). - - Updated ISSUE_TEMPLATE.md with a note about sensitive information ([issue #1092](https://github.com/PowerShell/SqlServerDsc/issues/1092)). -- Changes to SqlServerLogin - - [Claudio Spizzi (@claudiospizzi)](https://github.com/claudiospizzi): Fix password - test fails for nativ sql users ([issue #1048](https://github.com/PowerShell/SqlServerDsc/issues/1048)). -- Changes to SqlSetup - - [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode): Clarify usage - of 'SecurityMode' along with adding parameter validations for the only 2 - supported values ([issue #1010](https://github.com/PowerShell/SqlServerDsc/issues/1010)). - - Now accounts containing '$' will be able to be used for installing - SQL Server. Although, if the account ends with '$' it is considered a - Managed Service Account ([issue #1055](https://github.com/PowerShell/SqlServerDsc/issues/1055)). -- Changes to Integration Tests - - [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode): Replace xStorage - dsc resource module with StorageDsc ([issue #1038](https://github.com/PowerShell/SqlServerDsc/issues/1038)). -- Changes to Unit Tests - - [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode): Updated - the following resources unit test template to version 1.2.1 - - SqlAlias ([issue #999](https://github.com/PowerShell/SqlServerDsc/issues/999)). - - SqlWindowsFirewall ([issue #1089](https://github.com/PowerShell/SqlServerDsc/issues/1089)). - -## 11.0.0.0 - -- Changes to SqlServerDsc - - BREAKING CHANGE: Resource SqlRSSecureConnectionLevel was remove - ([issue #990](https://github.com/PowerShell/SqlServerDsc/issues/990)). - The parameter that was set using that resource has been merged into resource - SqlRS as the parameter UseSsl. The UseSsl parameter is of type boolean. This - change was made because from SQL Server 2008 R2 this value is made an on/off - switch. Read more in the article [ConfigurationSetting Method - SetSecureConnectionLevel](https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/configurationsetting-method-setsecureconnectionlevel). - - Updated so that named parameters are used for New-Object cmdlet. This was - done to follow the style guideline. - - Updated manifest and license to reflect the new year - ([issue #965](https://github.com/PowerShell/SqlServerDsc/issues/965)). - - Added a README.md under Tests\Integration to help contributors to write - integration tests. - - Added 'Integration tests' section in the CONTRIBUTING.md. - - The complete examples were removed. They were no longer accurate and some - referenced resources that no longer exist. Accurate examples can be found - in each specific resource example folder. Examples for installing Failover Cluster - can be found in the resource examples folders in the xFailOverCluster - resource module ([issue #462](https://github.com/PowerShell/SqlServerDsc/issues/462)). - - A README.md was created under the Examples folder to be used as reference how - to install certain scenarios ([issue #462](https://github.com/PowerShell/SqlServerDsc/issues/462)). - - Removed the local specific common test for compiling examples in this repository - and instead opted-in for the common test in the 'DscResource.Tests' repository - ([issue #669](https://github.com/PowerShell/SqlServerDsc/issues/669)). - - Added new resource SqlServerDatabaseMail for configuring SQL Server - Database Mail ([issue #155](https://github.com/PowerShell/SqlServerDsc/issues/155)). - - Updated the helper function Test-SQLDscParameterState to handle the - data type UInt16. - - Fixed typo in SqlServerDscCommon.Tests. - - Updated README.md with known issue section for each resource. - - Resources that did not have a description in the README.md now has one. - - Resources that missed links to the examples in the README.md now has those - links. - - Style changes in all examples, removing type [System.Management.Automation.Credential()] - from credential parameters ([issue #1003](https://github.com/PowerShell/SqlServerDsc/issues/1003)), - and renamed the credential parameter so it is not using abbreviation. - - Updated the security token for AppVeyor status badge in README.md. When we - renamed the repository the security token was changed - ([issue #1012](https://github.com/PowerShell/SqlServerDsc/issues/1012)). - - Now the helper function Restart-SqlService, after restarting the SQL Server - service, does not return until it can connect to the SQL Server instance, and - the instance returns status 'Online' ([issue #1008](https://github.com/PowerShell/SqlServerDsc/issues/1008)). - If it fails to connect within the timeout period (defaults to 120 seconds) it - throws an error. - - Fixed typo in comment-base help for helper function Test-AvailabilityReplicaSeedingModeAutomatic. - - Style cleanup in helper functions and tests. -- Changes to SqlAG - - Fixed typos in tests. - - Style cleanup in code and tests. -- Changes to SqlAGDatabase - - Style cleanup in code and tests. -- Changes to SqlAGListener - - Fixed typo in comment-based help. - - Style cleanup in code and tests. -- Changes to SqlAGReplica - - Minor code style cleanup. Removed unused variable and instead piped the cmdlet - Join-SqlAvailabilityGroup to Out-Null. - - Fixed minor typos in comment-based help. - - Fixed minor typos in comment. - - Style cleanup in code and tests. - - Updated description for parameter Name in README.md and in comment-based help - ([issue #1034](https://github.com/PowerShell/SqlServerDsc/issues/1034)). -- Changes to SqlAlias - - Fixed issue where exception was thrown if reg keys did not exist - ([issue #949](https://github.com/PowerShell/SqlServerDsc/issues/949)). - - Style cleanup in tests. -- Changes to SqlAlwaysOnService - - Refactor integration tests slightly to improve run time performance - ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). - - Style cleanup in code and tests. -- Changes to SqlDatabase - - Fix minor Script Analyzer warning. -- Changes to SqlDatabaseDefaultLocation - - Refactor integration tests slightly to improve run time performance - ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). - - Minor style cleanup of code in tests. -- Changes to SqlDatabaseRole - - Style cleanup in tests. -- Changes to SqlRS - - Replaced Get-WmiObject with Get-CimInstance to fix Script Analyzer warnings - ([issue #264](https://github.com/PowerShell/SqlServerDsc/issues/264)). - - Refactored the resource to use Invoke-CimMethod. - - Added parameter UseSsl which when set to $true forces connections to the - Reporting Services to use SSL when connecting ([issue #990](https://github.com/PowerShell/SqlServerDsc/issues/990)). - - Added complete example for SqlRS (based on the integration tests) - ([issue #634](https://github.com/PowerShell/SqlServerDsc/issues/634)). - - Refactor integration tests slightly to improve run time performance - ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). - - Style cleanup in code and tests. -- Changes to SqlScript - - Style cleanup in tests. - - Updated examples. - - Added integration tests. - - Fixed minor typos in comment-based help. - - Added new example based on integration test. -- Changes to SqlServerConfiguration - - Fixed minor typos in comment-based help. - - Now the verbose message say what option is changing and to what value - ([issue #1014](https://github.com/PowerShell/SqlServerDsc/issues/1014)). - - Changed the RestartTimeout parameter from type SInt32 to type UInt32. - - Added localization ([issue #605](https://github.com/PowerShell/SqlServerDsc/issues/605)). - - Style cleanup in code and tests. -- Changes to SqlServerEndpoint - - Updated README.md with links to the examples - ([issue #504](https://github.com/PowerShell/SqlServerDsc/issues/504)). - - Style cleanup in tests. -- Changes to SqlServerLogin - - Added integration tests ([issue #748](https://github.com/PowerShell/SqlServerDsc/issues/748)). - - Minor code style cleanup. - - Removed unused variable and instead piped the helper function Connect-SQL to - Out-Null. - - Style cleanup in tests. -- Changes to SqlServerMaxDop - - Minor style changes in the helper function Get-SqlDscDynamicMaxDop. -- Changes to SqlServerMemory - - Style cleanup in code and tests. -- Changes to SqlServerPermission - - Fixed minor typos in comment-based help. - - Style cleanup in code. -- Changes to SqlServerReplication - - Fixed minor typos in verbose messages. - - Style cleanup in tests. -- Changes to SqlServerNetwork - - Added sysadmin account parameter usage to the examples. -- Changes to SqlServerReplication - - Fix Script Analyzer warning ([issue #263](https://github.com/PowerShell/SqlServerDsc/issues/263)). -- Changes to SqlServerRole - - Added localization ([issue #621](https://github.com/PowerShell/SqlServerDsc/issues/621)). - - Added integration tests ([issue #756](https://github.com/PowerShell/SqlServerDsc/issues/756)). - - Updated example to add two server roles in the same configuration. - - Style cleanup in tests. -- Changes to SqlServiceAccount - - Default services are now properly detected - ([issue #930](https://github.com/PowerShell/SqlServerDsc/issues/930)). - - Made the description of parameter RestartService more descriptive - ([issue #960](https://github.com/PowerShell/SqlServerDsc/issues/960)). - - Added a read-only parameter ServiceAccountName so that the service account - name is correctly returned as a string ([issue #982](https://github.com/PowerShell/SqlServerDsc/issues/982)). - - Added integration tests ([issue #980](https://github.com/PowerShell/SqlServerDsc/issues/980)). - - The timing issue that the resource returned before SQL Server service was - actually restarted has been solved by a change in the helper function - Restart-SqlService ([issue #1008](https://github.com/PowerShell/SqlServerDsc/issues/1008)). - Now Restart-SqlService waits for the instance to return status 'Online' or - throws an error saying it failed to connect within the timeout period. - - Style cleanup in code and tests. -- Changes to SqlSetup - - Added parameter `ASServerMode` to support installing Analysis Services in - Multidimensional mode, Tabular mode and PowerPivot mode - ([issue #388](https://github.com/PowerShell/SqlServerDsc/issues/388)). - - Added integration tests for testing Analysis Services Multidimensional mode - and Tabular mode. - - Cleaned up integration tests. - - Added integration tests for installing a default instance of Database Engine. - - Refactor integration tests slightly to improve run time performance - ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). - - Added PSSA rule 'PSUseDeclaredVarsMoreThanAssignments' override in the - function Set-TargetResource for the variable $global:DSCMachineStatus. - - Style cleanup in code and tests. -- Changes to SqlWaitForAG - - Style cleanup in code. -- Changes to SqlWindowsFirewall - - Fixed minor typos in comment-based help. - - Style cleanup in code. - -## 10.0.0.0 - -- BREAKING CHANGE: Resource module has been renamed to SqlServerDsc - ([issue #916](https://github.com/PowerShell/SqlServerDsc/issues/916)). -- BREAKING CHANGE: Significant rename to reduce length of resource names - - See [issue #851](https://github.com/PowerShell/SqlServerDsc/issues/851) for a - complete table mapping rename changes. - - Impact to all resources. -- Changes to CONTRIBUTING.md - - Added details to the naming convention used in SqlServerDsc. -- Changes to SqlServerDsc - - The examples in the root of the Examples folder are obsolete. A note was - added to the comment-based help in each example stating it is obsolete. - This is a temporary measure until they are replaced - ([issue #904](https://github.com/PowerShell/SqlServerDsc/issues/904)). - - Added new common test (regression test) for validating the long path - issue for compiling resources in Azure Automation. - - Fix resources in alphabetical order in README.md ([issue #908](https://github.com/PowerShell/SqlServerDsc/issues/908)). -- Changes to SqlAG - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). - - BREAKING CHANGE: The read-only property SQLServerNetName was removed in favor - of EndpointHostName ([issue #924](https://github.com/PowerShell/SqlServerDsc/issues/924)). - Get-TargetResource will now return the value of property [NetName](https://technet.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.server.netname(v=sql.105).aspx) - for the property EndpointHostName. -- Changes to SqlAGDatabase - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). - - Changed the Get-MatchingDatabaseNames function to be case insensitive when - matching database names ([issue #912](https://github.com/PowerShell/SqlServerDsc/issues/912)). -- Changes to SqlAGListener - - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlAGReplica - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). - - BREAKING CHANGE: Parameters PrimaryReplicaSQLServer and PrimaryReplicaSQLInstanceName - has been renamed to PrimaryReplicaServerName and PrimaryReplicaInstanceName - respectively ([issue #922](https://github.com/PowerShell/SqlServerDsc/issues/922)). - - BREAKING CHANGE: The read-only property SQLServerNetName was removed in favor - of EndpointHostName ([issue #924](https://github.com/PowerShell/SqlServerDsc/issues/924)). - Get-TargetResource will now return the value of property [NetName](https://technet.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.server.netname(v=sql.105).aspx) - for the property EndpointHostName. -- Changes to SqlAlwaysOnService - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlDatabase - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes SqlDatabaseDefaultLocation - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlDatabaseOwner - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlDatabasePermission - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlDatabaseRecoveryModel - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlDatabaseRole - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlRS - - BREAKING CHANGE: Parameters RSSQLServer and RSSQLInstanceName has been renamed - to DatabaseServerName and DatabaseInstanceName respectively - ([issue #923](https://github.com/PowerShell/SqlServerDsc/issues/923)). -- Changes to SqlServerConfiguration - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerEndpoint - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerEndpointPermission - - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). - - Now the examples files have a shorter name so that resources will not fail - to compile in Azure Automation ([issue #934](https://github.com/PowerShell/SqlServerDsc/issues/934)). -- Changes to SqlServerEndpointState - - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerLogin - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerMaxDop - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerMemory - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerNetwork - - BREAKING CHANGE: Parameters SQLServer has been renamed to ServerName - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerPermission - - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerRole - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). -- Changes to SqlServerServiceAccount - - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed - to ServerName and InstanceName respectively - ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). - -## 9.0.0.0 - -- 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)). +For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md). -## 8.2.0.0 +## [Unreleased] -- Changes to xSQLServer - - Updated appveyor.yml so that integration tests run in order and so that - the SQLPS module folders are renamed to not disturb the units test, but - can be renamed back by the integration tests xSQLServerSetup so that the - integration tests can run successfully - ([issue #774](https://github.com/PowerShell/xSQLServer/issues/774)). - - Changed so the maximum version to be installed is 4.0.6.0, when running unit - tests in AppVeyor. Quick fix until we can resolve the unit tests (see - [issue #807](https://github.com/PowerShell/xSQLServer/issues/807)). - - Moved the code block, that contains workarounds in appveyor.yml, so it is run - during the install phase instead of the test phase. - - Fix problem with tests breaking with Pester 4.0.7 ([issue #807](https://github.com/PowerShell/xSQLServer/issues/807)). -- Changes to xSQLServerHelper - - Changes to Connect-SQL and Import-SQLPSModule - - Now it correctly loads the correct assemblies when SqlServer module is - present ([issue #649](https://github.com/PowerShell/xSQLServer/issues/649)). - - Now SQLPS module will be correctly loaded (discovered) after installation - of SQL Server. Previously resources depending on SQLPS module could fail - because SQLPS was not found after installation because the PSModulePath - environment variable in the (LCM) PowerShell session did not contain the new - module path. - - Added new helper function "Test-ClusterPermissions" ([issue #446](https://github.com/PowerShell/xSQLServer/issues/446)). -- Changes to xSQLServerSetup - - Fixed an issue with trailing slashes in the 'UpdateSource' property - ([issue #720](https://github.com/PowerShell/xSQLServer/issues/720)). - - Fixed so that the integration test renames back the SQLPS module folders if - they was renamed by AppVeyor (in the appveyor.yml file) - ([issue #774](https://github.com/PowerShell/xSQLServer/issues/774)). - - Fixed so integration test does not write warnings when SQLPS module is loaded - ([issue #798](https://github.com/PowerShell/xSQLServer/issues/798)). - - Changes to integration tests. - - Moved the configuration block from the MSFT\_xSQLServerSetup.Integration.Tests.ps1 - to the MSFT\_xSQLServerSetup.config.ps1 to align with the other integration - test. And also get most of the configuration in one place. - - Changed the tests so that the local SqlInstall account is added as a member - of the local administrators group. - - Changed the tests so that the local SqlInstall account is added as a member - of the system administrators in SQL Server (Database Engine) - needed for the - xSQLServerAlwaysOnService integration tests. - - Changed so that only one of the Modules-folder for the SQLPS PowerShell module - for SQL Server 2016 is renamed back so it can be used with the integration - tests. There was an issue when more than one SQLPS module was present (see - more information in [issue #806](https://github.com/PowerShell/xSQLServer/issues/806)). - - Fixed wrong variable name for SQL service credential. It was using the - integration test variable name instead of the parameter name. - - Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration - ([issue #824](https://github.com/PowerShell/xSQLServer/issues/824)). -- Changes to xSQLServerAlwaysOnAvailabilityGroup - - Change the check of the values entered as parameter for - BasicAvailabilityGroup. It is a boolean, hence it was not possible to - disable the feature. - - Add possibility to enable/disable the feature DatabaseHealthTrigger - (SQL Server 2016 or later only). - - Add possibility to enable the feature DtcSupportEnabled (SQL Server 2016 or - later only). The feature currently can't be altered once the Availability - Group is created. - - Use the new helper function "Test-ClusterPermissions". - - Refactored the unit tests to allow them to be more user friendly. - - Added the following read-only properties to the schema ([issue #476](https://github.com/PowerShell/xSQLServer/issues/476)) - - EndpointPort - - EndpointURL - - SQLServerNetName - - Version - - Use the Get-PrimaryReplicaServerObject helper function. -- Changes to xSQLServerAlwaysOnAvailabilityGroupReplica - - Fixed the formatting for the AvailabilityGroupNotFound error. - - Added the following read-only properties to the schema ([issue #477](https://github.com/PowerShell/xSQLServer/issues/477)) - - EndpointPort - - EndpointURL - - Use the new helper function "Test-ClusterPermissions". - - Use the Get-PrimaryReplicaServerObject helper function -- Changes to xSQLServerHelper - - Fixed Connect-SQL by ensuring the Status property returns 'Online' prior to - returning the SQL Server object ([issue #333](https://github.com/PowerShell/xSQLServer/issues/333)). -- Changes to xSQLServerRole - - Running Get-DscConfiguration no longer throws an error saying property - Members is not an array ([issue #790](https://github.com/PowerShell/xSQLServer/issues/790)). -- Changes to xSQLServerMaxDop - - Fixed error where Measure-Object cmdlet would fail claiming it could not - find the specified property ([issue #801](https://github.com/PowerShell/xSQLServer/issues/801)) -- Changes to xSQLServerAlwaysOnService - - Added integration test ([issue #736](https://github.com/PowerShell/xSQLServer/issues/736)). - - Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration - ([issue #824](https://github.com/PowerShell/xSQLServer/issues/824)). -- Changes to SMO.cs - - Added default properties to the Server class - - AvailabilityGroups - - Databases - - EndpointCollection - - Added a new overload to the Login class - - Added default properties to the AvailabilityReplicas class - - AvailabilityDatabases - - AvailabilityReplicas -- Added new resource xSQLServerAccount ([issue #706](https://github.com/PowerShell/xSQLServer/issues/706)) - - Added localization support for all strings - - Added examples for usage -- Changes to xSQLServerRSConfig - - No longer returns a null value from Test-TargetResource when Reporting - Services has not been initialized ([issue #822](https://github.com/PowerShell/xSQLServer/issues/822)). - - Fixed so that when two Reporting Services are installed for the same major - version the resource does not throw an error ([issue #819](https://github.com/PowerShell/xSQLServer/issues/819)). - - Now the resource will restart the Reporting Services service after - initializing ([issue #592](https://github.com/PowerShell/xSQLServer/issues/592)). - This will enable the Reports site to work. - - Added integration test ([issue #753](https://github.com/PowerShell/xSQLServer/issues/753)). - - Added support for configuring URL reservations and virtual directory names - ([issue #570](https://github.com/PowerShell/xSQLServer/issues/570)) -- Added resource - - xSQLServerDatabaseDefaultLocation - ([issue #656](https://github.com/PowerShell/xSQLServer/issues/656)) +### Added -## 8.1.0.0 +- SqlServerDsc + - Added continuous delivery with a new CI pipeline. -- Changes to xSQLServer - - Added back .markdownlint.json so that lint rule MD013 is enforced. - - Change the module to use the image 'Visual Studio 2017' as the build worker - image for AppVeyor (issue #685). - - Minor style change in CommonResourceHelper. Added missing [Parameter()] on - three parameters. - - Minor style changes to the unit tests for CommonResourceHelper. - - Changes to xSQLServerHelper - - Added Swedish localization ([issue #695](https://github.com/PowerShell/xSQLServer/issues/695)). - - Opt-in for module files common tests ([issue #702](https://github.com/PowerShell/xSQLServer/issues/702)). - - Removed Byte Order Mark (BOM) from the files; CommonResourceHelper.psm1, - MSFT\_xSQLServerAvailabilityGroupListener.psm1, MSFT\_xSQLServerConfiguration.psm1, - MSFT\_xSQLServerEndpointPermission.psm1, MSFT\_xSQLServerEndpointState.psm1, - MSFT\_xSQLServerNetwork.psm1, MSFT\_xSQLServerPermission.psm1, - MSFT\_xSQLServerReplication.psm1, MSFT\_xSQLServerScript.psm1, - SQLPSStub.psm1, SQLServerStub.psm1. - - Opt-in for script files common tests ([issue #707](https://github.com/PowerShell/xSQLServer/issues/707)). - - Removed Byte Order Mark (BOM) from the files; DSCClusterSqlBuild.ps1, - DSCFCISqlBuild.ps1, DSCSqlBuild.ps1, DSCSQLBuildEncrypted.ps1, - SQLPush_SingleServer.ps1, 1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1, - 2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, - 3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1, - 4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, - 5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1, - 6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1, - 2-ConfigureInstanceToEnablePriorityBoost.ps1, 1-CreateEndpointWithDefaultValues.ps1, - 2-CreateEndpointWithSpecificPortAndIPAddress.ps1, 3-RemoveEndpoint.ps1, - 1-AddConnectPermission.ps1, 2-RemoveConnectPermission.ps1, - 3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, - 4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, - 1-MakeSureEndpointIsStarted.ps1, 2-MakeSureEndpointIsStopped.ps1, - 1-EnableTcpIpWithStaticPort.ps1, 2-EnableTcpIpWithDynamicPort.ps1, - 1-AddServerPermissionForLogin.ps1, 2-RemoveServerPermissionForLogin.ps1, - 1-ConfigureInstanceAsDistributor.ps1, 2-ConfigureInstanceAsPublisher.ps1, - 1-WaitForASingleClusterGroup.ps1, 2-WaitForMultipleClusterGroups.ps1. - - Updated year to 2017 in license file ([issue #711](https://github.com/PowerShell/xSQLServer/issues/711)). - - Code style clean-up throughout the module to align against the Style Guideline. - - Fixed typos and the use of wrong parameters in unit tests which was found - after release of new version of Pester ([issue #773](https://github.com/PowerShell/xSQLServer/issues/773)). -- Changes to xSQLServerAlwaysOnService - - Added resource description in README.md. - - Updated parameters descriptions in comment-based help, schema.mof and README.md. - - Changed the datatype of the parameter to UInt32 so the same datatype is used - in both the Get-/Test-/Set-TargetResource functions as in the schema.mof - (issue #688). - - Added read-only property IsHadrEnabled to schema.mof and the README.md - (issue #687). - - Minor cleanup of code. - - Added examples (issue #633) - - 1-EnableAlwaysOn.ps1 - - 2-DisableAlwaysOn.ps1 - - Fixed PS Script Analyzer errors ([issue #724](https://github.com/PowerShell/xSQLServer/issues/724)) - - Casting the result of the property IsHadrEnabled to [System.Boolean] so that - $null is never returned, which resulted in an exception ([issue #763](https://github.com/PowerShell/xSQLServer/issues/763)). -- Changes to xSQLServerDatabasePermission - - Fixed PS Script Analyzer errors ([issue #725](https://github.com/PowerShell/xSQLServer/issues/725)) -- Changes to xSQLServerScript - - Fixed PS Script Analyzer errors ([issue #728](https://github.com/PowerShell/xSQLServer/issues/728)) -- Changes to xSQLServerSetup - - Added Swedish localization ([issue #695](https://github.com/PowerShell/xSQLServer/issues/695)). - - Now Get-TargetResource correctly returns an array for property ASSysAdminAccounts, - and no longer throws an error when there is just one Analysis Services - administrator (issue #691). - - Added a simple integration test ([issue #709](https://github.com/PowerShell/xSQLServer/issues/709)). - - Fixed PS Script Analyzer errors ([issue #729](https://github.com/PowerShell/xSQLServer/issues/729)) +### Changed -## 8.0.0.0 - -- BREAKING CHANGE: The module now requires WMF 5. - - This is required for class-based resources -- Added new resource - - xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership - - Added localization support for all strings. - - Refactored as a MOF based resource due to challenges with Pester and testing - in Powershell 5. -- Changes to xSQLServer - - BREAKING CHANGE: xSQLServer does no longer try to support WMF 4.0 (PowerShell - 4.0) (issue #574). Minimum supported version of WMF is now 5.0 (PowerShell 5.0). - - BREAKING CHANGE: Removed deprecated resource xSQLAOGroupJoin (issue #457). - - BREAKING CHANGE: Removed deprecated resource xSQLAOGroupEnsure (issue #456). - - BREAKING CHANGE: Removed deprecated resource xSQLServerFailoverClusterSetup - (issue #336). - - Updated PULL\_REQUEST\_TEMPLATE adding comment block around text. Also - rearranged and updated texts (issue #572). - - Added common helper functions for HQRM localization, and added tests for the - helper functions. - - Get-LocalizedData - - New-InvalidResultException - - New-ObjectNotFoundException - - New-InvalidOperationException - - New-InvalidArgumentException - - Updated CONTRIBUTING.md describing the new localization helper functions. - - Fixed typos in xSQLServer.strings.psd1 - - Fixed CodeCov badge links in README.md so that they point to the correct branch. - - Added VS Code workspace settings file with formatting settings matching the - Style Guideline (issue #645). That will make it possible inside VS Code to press - SHIFT+ALT+F, or press F1 and choose 'Format document' in the list. The - PowerShell code will then be formatted according to the Style Guideline - (although maybe not complete, but would help a long way). - - Removed powershell.codeFormatting.alignPropertyValuePairs setting since - it does not align with the style guideline. - - Added powershell.codeFormatting.preset with a value of 'Custom' so that - workspace formatting settings are honored (issue #665). - - Fixed lint error MD013 and MD036 in README.md. - - Updated .markdownlint.json to enable rule MD013 and MD036 to enforce those - lint markdown rules in the common tests. - - Fixed lint error MD013 in CHANGELOG.md. - - Fixed lint error MD013 in CONTRIBUTING.md. - - Added code block around types in README.md. - - Updated copyright information in xSQLServer.psd1. - - Opt-in for markdown common tests (issue #668). - - The old markdown tests has been removed. -- Changes to xSQLServerHelper - - Removed helper function Grant-ServerPerms because the deprecated resource that - was using it was removed. - - Removed helper function Grant-CNOPerms because the deprecated resource that - was using it was removed. - - Removed helper function New-ListenerADObject because the deprecated resource - that was using it was removed. - - Added tests for those helper functions that did not have tests. - - Test-SQLDscParameterState helper function can now correctly pass a CimInstance - as DesiredValue. - - Test-SQLDscParameterState helper function will now output a warning message - if the value type of a desired value is not supported. - - Added localization to helper functions (issue #641). - - Resolved the issue when using Write-Verbose in helper functions discussed - in #641 where Write-Verbose wouldn't write out verbose messages unless using - parameter Verbose. - - Moved localization strings from xSQLServer.strings.psd1 to - xSQLServerHelper.strings.psd1. -- Changes to xSQLServerSetup - - BREAKING CHANGE: Replaced StartWin32Process helper function with the cmdlet - Start-Process (issue #41, #93 and #126). - - BREAKING CHANGE: The parameter SetupCredential has been removed since it is - no longer needed. This is because the resource now support the built-in - PsDscRunAsCredential. - - BREAKING CHANGE: Now the resource supports using built-in PsDscRunAsCredential. - If PsDscRunAsCredential is set, that username will be used as the first system - administrator. - - BREAKING CHANGE: If the parameter PsDscRunAsCredential are not assigned any - credentials then the resource will start the setup process as the SYSTEM account. - When installing as the SYSTEM account, then parameter SQLSysAdminAccounts and - ASSysAdminAccounts must be specified when installing feature Database Engine - and Analysis Services respectively. - - When setup exits with the exit code 3010 a warning message is written to console - telling that setup finished successfully, but a reboot is required (partly fixes - issue #565). - - When setup exits with an exit code other than 0 or 3010 a warning message is - written to console telling that setup finished with an error (partly fixes - issue #580). - - Added a new parameter SetupProcessTimeout which defaults to 7200 seconds (2 - hours). If the setup process has not finished before the timeout value in - SetupProcessTimeout an error will be thrown (issue #566). - - Updated all examples to match the removal of SetupCredential. - - Updated (removed) severe known issues in README.md for resource xSQLServerSetup. - - Now all major version uses the same identifier to evaluate InstallSharedDir - and InstallSharedWOWDir (issue #420). - - Now setup arguments that contain no value will be ignored, for example when - InstallSharedDir and - InstallSharedWOWDir path is already present on the target node, because of a - previous installation (issue #639). - - Updated Get-TargetResource to correctly detect BOL, Conn, BC and other tools - when they are installed without SQLENGINE (issue #591). - - Now it can detect Documentation Components correctly after the change in - issue #591 (issue #628) - - Fixed bug that prevented Get-DscConfiguration from running without error. The - return hash table fails if the $clusteredSqlIpAddress variable is not used. - The schema expects a string array but it is initialized as just a null string, - causing it to fail on Get-DscConfiguration (issue #393). - - Added localization support for all strings. - - Added a test to test some error handling for cluster installations. - - Added support for MDS feature install (issue #486) - - Fixed localization support for MDS feature (issue #671). -- Changes to xSQLServerRSConfig - - BREAKING CHANGE: Removed `$SQLAdminCredential` parameter. Use common parameter - `PsDscRunAsCredential` (WMF 5.0+) to run the resource under different credentials. - `PsDscRunAsCredential` Windows account must be a sysadmin on SQL Server (issue - #568). - - In addition, the resource no longer uses `Invoke-Command` cmdlet that was used - to impersonate the Windows user specified by `$SQLAdminCredential`. The call - also needed CredSSP authentication to be enabled and configured on the target - node, which complicated deployments in non-domain scenarios. Using - `PsDscRunAsCredential` solves this problems for us. - - Fixed virtual directory creation for SQL Server 2016 (issue #569). - - Added unit tests (issue #295). -- Changes to xSQLServerDatabase - - Changed the readme, SQLInstance should have been SQLInstanceName. -- Changes to xSQLServerScript - - Fixed bug with schema and variable mismatch for the Credential/Username parameter - in the return statement (issue #661). - - Optional QueryTimeout parameter to specify sql script query execution timeout. - Fixes issue #597 -- Changes to xSQLServerAlwaysOnService - - Fixed typos in localization strings and in tests. -- Changes to xSQLServerAlwaysOnAvailabilityGroup - - Now it utilize the value of 'FailoverMode' to set the 'FailoverMode' property - of the Availability Group instead of wrongly using the 'AvailabilityMode' - property of the Availability Group. - -## 7.1.0.0 - -- Changes to xSQLServerMemory - - Changed the way SQLServer parameter is passed from Test-TargetResource to - Get-TargetResource so that the default value isn't lost (issue #576). - - Added condition to unit tests for when no SQLServer parameter is set. -- Changes to xSQLServerMaxDop - - Changed the way SQLServer parameter is passed from Test-TargetResource to - Get-TargetResource so that the default value isn't lost (issue #576). - - Added condition to unit tests for when no SQLServer parameter is set. -- Changes to xWaitForAvailabilityGroup - - Updated README.md with a description for the resources and revised the parameter - descriptions. - - The default value for RetryIntervalSec is now 20 seconds and the default value - for RetryCount is now 30 times (issue #505). - - Cleaned up code and fixed PSSA rules warnings (issue #268). - - Added unit tests (issue #297). - - Added descriptive text to README.md that the account that runs the resource - must have permission to run the cmdlet Get-ClusterGroup (issue #307). - - Added read-only parameter GroupExist which will return $true if the cluster - role/group exist, otherwise it returns $false (issue #510). - - Added examples. -- Changes to xSQLServerPermission - - Cleaned up code, removed SupportsShouldProcess and fixed PSSA rules warnings - (issue #241 and issue #262). - - It is now possible to add permissions to two or more logins on the same instance - (issue #526). - - The parameter NodeName is no longer mandatory and has now the default value - of $env:COMPUTERNAME. - - The parameter Ensure now has a default value of 'Present'. - - Updated README.md with a description for the resources and revised the parameter - descriptions. - - Removed dependency of SQLPS provider (issue #482). - - Added ConnectSql permission. Now that permission can also be granted or revoked. - - Updated note in resource description to also mention ConnectSql permission. -- Changes to xSQLServerHelper module - - Removed helper function Get-SQLPSInstance and Get-SQLPSInstanceName because - there is no resource using it any longer. - - Added four new helper functions. - - Register-SqlSmo, Register-SqlWmiManagement and Unregister-SqlAssemblies to - handle the creation on the application domain and loading and unloading of - the SMO and SqlWmiManagement assemblies. - - Get-SqlInstanceMajorVersion to get the major SQL version for a specific instance. - - Fixed typos in comment-based help -- Changes to xSQLServer - - Fixed typos in markdown files; CHANGELOG, CONTRIBUTING, README and ISSUE_TEMPLATE. - - Fixed typos in schema.mof files (and README.md). - - Updated some parameter description in schema.mof files on those that was found - was not equal to README.md. -- Changes to xSQLServerAlwaysOnService - - Get-TargetResource should no longer fail silently with error 'Index operation - failed; the array index evaluated to null.' (issue #519). Now if the - Server.IsHadrEnabled property return neither $true or $false the - Get-TargetResource function will throw an error. -- Changes to xSQLServerSetUp - - Updated xSQLServerSetup Module Get-Resource method to fix (issue #516 and #490). - - Added change to detect DQ, DQC, BOL, SDK features. Now the function - Test-TargetResource returns true after calling set for DQ, DQC, BOL, SDK - features (issue #516 and #490). -- Changes to xSQLServerAlwaysOnAvailabilityGroup - - Updated to return the exception raised when an error is thrown. -- Changes to xSQLServerAlwaysOnAvailabilityGroupReplica - - Updated to return the exception raised when an error is thrown. - - Updated parameter description for parameter Name, so that it says it must be - in the format SQLServer\InstanceName for named instance (issue #548). -- Changes to xSQLServerLogin - - Added an optional boolean parameter Disabled. It can be used to enable/disable - existing logins or create disabled logins (new logins are created as enabled - by default). -- Changes to xSQLServerDatabaseRole - - Updated variable passed to Microsoft.SqlServer.Management.Smo.User constructor - to fix issue #530 -- Changes to xSQLServerNetwork - - Added optional parameter SQLServer with default value of $env:COMPUTERNAME - (issue #528). - - Added optional parameter RestartTimeout with default value of 120 seconds. - - Now the resource supports restarting a sql server in a cluster (issue #527 - and issue #455). - - Now the resource allows to set the parameter TcpDynamicPorts to a blank value - (partly fixes issue #534). Setting a blank value for parameter TcpDynamicPorts - together with a value for parameter TcpPort means that static port will be used. - - Now the resource will not call Alter() in the Set-TargetResource when there - is no change necessary (issue #537). - - Updated example 1-EnableTcpIpOnCustomStaticPort. - - Added unit tests (issue #294). - - Refactored some of the code, cleaned up the rest and fixed PSSA rules warnings - (issue #261). - - If parameter TcpDynamicPort is set to '0' at the same time as TcpPort is set - the resource will now throw an error (issue #535). - - Added examples (issue #536). - - When TcpDynamicPorts is set to '0' the Test-TargetResource function will no - longer fail each time (issue #564). -- Changes to xSQLServerRSConfig - - Replaced sqlcmd.exe usages with Invoke-Sqlcmd calls (issue #567). -- Changes to xSQLServerDatabasePermission - - Fixed code style, updated README.md and removed *-SqlDatabasePermission functions - from xSQLServerHelper.psm1. - - Added the option 'GrantWithGrant' with gives the user grant rights, together - with the ability to grant others the same right. - - Now the resource can revoke permission correctly (issue #454). When revoking - 'GrantWithGrant', both the grantee and all the other users the grantee has - granted the same permission to, will also get their permission revoked. - - Updated tests to cover Revoke(). -- Changes to xSQLServerHelper - - The missing helper function ('Test-SPDSCObjectHasProperty'), that was referenced - in the helper function Test-SQLDscParameterState, is now incorporated into - Test-SQLDscParameterState (issue #589). - -## 7.0.0.0 - -- Examples - - xSQLServerDatabaseRole - - 1-AddDatabaseRole.ps1 - - 2-RemoveDatabaseRole.ps1 - - xSQLServerRole - - 3-AddMembersToServerRole.ps1 - - 4-MembersToIncludeInServerRole.ps1 - - 5-MembersToExcludeInServerRole.ps1 - - xSQLServerSetup - - 1-InstallDefaultInstanceSingleServer.ps1 - - 2-InstallNamedInstanceSingleServer.ps1 - - 3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 - - 4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 - - 5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 - - xSQLServerReplication - - 1-ConfigureInstanceAsDistributor.ps1 - - 2-ConfigureInstanceAsPublisher.ps1 - - xSQLServerNetwork - - 1-EnableTcpIpOnCustomStaticPort.ps1 - - xSQLServerAvailabilityGroupListener - - 1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 - - 2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 - - 3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 - - 4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 - - 5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 - - 6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 - - xSQLServerEndpointPermission - - 1-AddConnectPermission.ps1 - - 2-RemoveConnectPermission.ps1 - - 3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 - - 4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 - - xSQLServerPermission - - 1-AddServerPermissionForLogin.ps1 - - 2-RemoveServerPermissionForLogin.ps1 - - xSQLServerEndpointState - - 1-MakeSureEndpointIsStarted.ps1 - - 2-MakeSureEndpointIsStopped.ps1 - - xSQLServerConfiguration - - 1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 - - 2-ConfigureInstanceToEnablePriorityBoost.ps1 - - xSQLServerEndpoint - - 1-CreateEndpointWithDefaultValues.ps1 - - 2-CreateEndpointWithSpecificPortAndIPAddress.ps1 - - 3-RemoveEndpoint.ps1 -- Changes to xSQLServerDatabaseRole - - Fixed code style, added updated parameter descriptions to schema.mof and README.md. -- Changes to xSQLServer - - Raised the CodeCov target to 70% which is the minimum and required target for - HQRM resource. -- Changes to xSQLServerRole - - **BREAKING CHANGE: The resource has been reworked in it's entirely.** Below - is what has changed. - - The mandatory parameters now also include ServerRoleName. - - The ServerRole parameter was before an array of server roles, now this parameter - is renamed to ServerRoleName and can only be set to one server role. - - ServerRoleName are no longer limited to built-in server roles. To add members - to a built-in server role, set ServerRoleName to the name of the built-in - server role. - - The ServerRoleName will be created when Ensure is set to 'Present' (if it - does not already exist), or removed if Ensure is set to 'Absent'. - - Three new parameters are added; Members, MembersToInclude and MembersToExclude. - - Members can be set to one or more logins, and those will _replace all_ the - memberships in the server role. - - MembersToInclude and MembersToExclude can be set to one or more logins that - will add or remove memberships, respectively, in the server role. MembersToInclude - and MembersToExclude _can not_ be used at the same time as parameter Members. - But both MembersToInclude and MembersToExclude can be used together at the - same time. -- Changes to xSQLServerSetup - - Added a note to the README.md saying that it is not possible to add or remove - features from a SQL Server failover cluster (issue #433). - - Changed so that it reports false if the desired state is not correct (issue #432). - - Added a test to make sure we always return false if a SQL Server failover - cluster is missing features. - - Helper function Connect-SQLAnalysis - - Now has correct error handling, and throw does not used the unknown named - parameter '-Message' (issue #436) - - Added tests for Connect-SQLAnalysis - - Changed to localized error messages. - - Minor changes to error handling. - - This adds better support for Addnode (issue #369). - - Now it skips cluster validation för add node (issue #442). - - Now it ignores parameters that are not allowed for action Addnode (issue #441). - - Added support for vNext CTP 1.4 (issue #472). -- Added new resource - - xSQLServerAlwaysOnAvailabilityGroupReplica -- Changes to xSQLServerDatabaseRecoveryModel - - Fixed code style, removed SQLServerDatabaseRecoveryModel functions from xSQLServerHelper. -- Changes to xSQLServerAlwaysOnAvailabilityGroup - - Fixed the permissions check loop so that it exits the loop after the function - determines the required permissions are in place. -- Changes to xSQLServerAvailabilityGroupListener - - Removed the dependency of SQLPS provider (issue #460). - - Cleaned up code. - - Added test for more coverage. - - Fixed PSSA rule warnings (issue #255). - - Parameter Ensure now defaults to 'Present' (issue #450). -- Changes to xSQLServerFirewall - - Now it will correctly create rules when the resource is used for two or more - instances on the same server (issue #461). -- Changes to xSQLServerEndpointPermission - - Added description to the README.md - - Cleaned up code (issue #257 and issue #231) - - Now the default value for Ensure is 'Present'. - - Removed dependency of SQLPS provider (issue #483). - - Refactored tests so they use less code. -- Changes to README.md - - Adding deprecated tag to xSQLServerFailoverClusterSetup, xSQLAOGroupEnsure and - xSQLAOGroupJoin in README.md so it it more clear that these resources has been - replaced by xSQLServerSetup, xSQLServerAlwaysOnAvailabilityGroup and - xSQLServerAlwaysOnAvailabilityGroupReplica respectively. -- Changes to xSQLServerEndpoint - - BREAKING CHANGE: Now SQLInstanceName is mandatory, and is a key, so - SQLInstanceName has no longer a default value (issue #279). - - BREAKING CHANGE: Parameter AuthorizedUser has been removed (issue #466, - issue #275 and issue #80). Connect permissions can be set using the resource - xSQLServerEndpointPermission. - - Optional parameter IpAddress has been added. Default is to listen on any - valid IP-address. (issue #232) - - Parameter Port now has a default value of 5022. - - Parameter Ensure now defaults to 'Present'. - - Resource now supports changing IP address and changing port. - - Added unit tests (issue #289) - - Added examples. -- Changes to xSQLServerEndpointState - - Cleaned up code, removed SupportsShouldProcess and fixed PSSA rules warnings - (issue #258 and issue #230). - - Now the default value for the parameter State is 'Started'. - - Updated README.md with a description for the resources and revised the - parameter descriptions. - - Removed dependency of SQLPS provider (issue #481). - - The parameter NodeName is no longer mandatory and has now the default value - of $env:COMPUTERNAME. - - The parameter Name is now a key so it is now possible to change the state on - more than one endpoint on the same instance. _Note: The resource still only - supports Database Mirror endpoints at this time._ -- Changes to xSQLServerHelper module - - Removing helper function Get-SQLAlwaysOnEndpoint because there is no resource - using it any longer. - - BREAKING CHANGE: Changed helper function Import-SQLPSModule to support SqlServer - module (issue #91). The SqlServer module is the preferred module so if it is - found it will be used, and if not found an attempt will be done to load SQLPS - module instead. -- Changes to xSQLServerScript - - Updated tests for this resource, because they failed when Import-SQLPSModule - was updated. - -## 6.0.0.0 - -- Changes to xSQLServerConfiguration - - BREAKING CHANGE: The parameter SQLInstanceName is now mandatory. - - Resource can now be used to define the configuration of two or more different - DB instances on the same server. -- Changes to xSQLServerRole - - xSQLServerRole now correctly reports that the desired state is present when - the login is already a member of the server roles. -- Added new resources - - xSQLServerAlwaysOnAvailabilityGroup -- Changes to xSQLServerSetup - - Properly checks for use of SQLSysAdminAccounts parameter in $PSBoundParameters. - The test now also properly evaluates the setup argument for SQLSysAdminAccounts. - - xSQLServerSetup should now function correctly for the InstallFailoverCluster - action, and also supports cluster shared volumes. Note that the AddNode action - is not currently working. - - It now detects that feature Client Connectivity Tools (CONN) and Client - Connectivity Backwards Compatibility Tools (BC) is installed. - - Now it can correctly determine the right cluster when only parameter - InstallSQLDataDir is assigned a path (issue #401). - - Now the only mandatory path parameter is InstallSQLDataDir when installing - Database Engine (issue #400). - - It now can handle mandatory parameters, and are not using wildcard to find - the variables containing paths (issue #394). - - Changed so that instead of connection to localhost it is using $env:COMPUTERNAME - as the host name to which it connects. And for cluster installation it uses - the parameter FailoverClusterNetworkName as the host name to which it connects - (issue #407). - - When called with Action = 'PrepareFailoverCluster', the SQLSysAdminAccounts - and FailoverClusterGroup parameters are no longer passed to the setup process - (issues #410 and 411). - - Solved the problem that InstanceDir and InstallSQLDataDir could not be set to - just a qualifier, i.e 'E:' (issue #418). All paths (except SourcePath) can now - be set to just the qualifier. -- Enables CodeCov.io code coverage reporting. -- Added badge for CodeCov.io to README.md. -- Examples - - xSQLServerMaxDop - - 1-SetMaxDopToOne.ps1 - - 2-SetMaxDopToAuto.ps1 - - 3-SetMaxDopToDefault.ps1 - - xSQLServerMemory - - 1-SetMaxMemoryTo12GB.ps1 - - 2-SetMaxMemoryToAuto.ps1 - - 3-SetMinMaxMemoryToAuto.ps1 - - 4-SetMaxMemoryToDefault.ps1 - - xSQLServerDatabase - - 1-CreateDatabase.ps1 - - 2-DeleteDatabase.ps1 -- Added tests for resources - - xSQLServerMaxDop - - xSQLServerMemory -- Changes to xSQLServerMemory - - BREAKING CHANGE: The mandatory parameter now include SQLInstanceName. The - DynamicAlloc parameter is no longer mandatory -- Changes to xSQLServerDatabase - - When the system is not in desired state the Test-TargetResource will now output - verbose messages saying so. -- Changes to xSQLServerDatabaseOwner - - Fixed code style, added updated parameter descriptions to schema.mof and README.md. - -## 5.0.0.0 - -- Improvements how tests are initiated in AppVeyor - - Removed previous workaround (issue #201) from unit tests. - - Changes in appveyor.yml so that SQL modules are removed before common test is - run. - - Now the deploy step are no longer failing when merging code into Dev. Neither - is the deploy step failing if a contributor had AppVeyor connected to the fork - of xSQLServer and pushing code to the fork. -- Changes to README.md - - Changed the contributing section to help new contributors. - - Added links for each resource so it is easier to navigate to the parameter list - for each resource. - - Moved the list of resources in alphabetical order. - - Moved each resource parameter list into alphabetical order. - - Removed old text mentioning System Center. - - Now the correct product name is written in the installation section, and a typo - was also fixed. - - Fixed a typo in the Requirements section. - - Added link to Examples folder in the Examples section. - - Change the layout of the README.md to closer match the one of PSDscResources - - Added more detailed text explaining what operating systems WMF5.0 can be installed - on. - - Verified all resource schema files with the README.md and fixed some errors - (descriptions was not verified). - - Added security requirements section for resource xSQLServerEndpoint and - xSQLAOGroupEnsure. -- Changes to xSQLServerSetup - - The resource no longer uses Win32_Product WMI class when evaluating if - SQL Server Management Studio is installed. See article - [kb974524](https://support.microsoft.com/en-us/kb/974524) for more information. - - Now it uses CIM cmdlets to get information from WMI classes. - - Resolved all of the PSScriptAnalyzer warnings that was triggered in the common - tests. - - Improvement for service accounts to enable support for Managed Service Accounts - as well as other nt authority accounts - - Changes to the helper function Copy-ItemWithRoboCopy - - Robocopy is now started using Start-Process and the error handling has been - improved. - - Robocopy now removes files at the destination path if they no longer exists - at the source. - - Robocopy copies using unbuffered I/O when available (recommended for large - files). - - Added a more descriptive text for the parameter `SourceCredential` to further - explain how the parameter work. - - BREAKING CHANGE: Removed parameter SourceFolder. - - BREAKING CHANGE: Removed default value "$PSScriptRoot\..\..\" from parameter - SourcePath. - - Old code, that no longer filled any function, has been replaced. - - Function `ResolvePath` has been replaced with - `[Environment]::ExpandEnvironmentVariables($SourcePath)` so that environment - variables still can be used in Source Path. - - Function `NetUse` has been replaced with `New-SmbMapping` and - `Remove-SmbMapping`. - - Renamed function `GetSQLVersion` to `Get-SqlMajorVersion`. - - BREAKING CHANGE: Renamed parameter PID to ProductKey to avoid collision with - automatic variable $PID -- Changes to xSQLServerScript - - All credential parameters now also has the type - [System.Management.Automation.Credential()] to better work with PowerShell 4.0. - - It is now possible to configure two instances on the same node, with the same - script. - - Added to the description text for the parameter `Credential` describing how - to authenticate using Windows Authentication. - - Added examples to show how to authenticate using either SQL or Windows - authentication. - - A recent issue showed that there is a known problem running this resource - using PowerShell 4.0. For more information, see [issue #273](https://github.com/PowerShell/xSQLServer/issues/273) -- Changes to xSQLServerFirewall - - BREAKING CHANGE: Removed parameter SourceFolder. - - BREAKING CHANGE: Removed default value "$PSScriptRoot\..\..\" from parameter - SourcePath. - - Old code, that no longer filled any function, has been replaced. - - Function `ResolvePath` has been replaced with - `[Environment]::ExpandEnvironmentVariables($SourcePath)` so that environment - variables still can be used in Source Path. - - Adding new optional parameter SourceCredential that can be used to authenticate - against SourcePath. - - Solved PSSA rules errors in the code. - - Get-TargetResource no longer return $true when no products was installed. -- Changes to the unit test for resource - - xSQLServerSetup - - Added test coverage for helper function Copy-ItemWithRoboCopy -- Changes to xSQLServerLogin - - Removed ShouldProcess statements - - Added the ability to enforce password policies on SQL logins -- Added common test (xSQLServerCommon.Tests) for xSQLServer module - - Now all markdown files will be style checked when tests are running in AppVeyor - after sending in a pull request. - - Now all [Examples](/Examples/Resources) will be tested by compiling to a .mof - file after sending in a pull request. -- Changes to xSQLServerDatabaseOwner - - The example 'SetDatabaseOwner' can now compile, it wrongly had a `DependsOn` - in the example. -- Changes to SQLServerRole - - The examples 'AddServerRole' and 'RemoveServerRole' can now compile, it wrongly - had a `DependsOn` in the example. -- Changes to CONTRIBUTING.md - - Added section 'Tests for examples files' - - Added section 'Tests for style check of Markdown files' - - Added section 'Documentation with Markdown' - - Added texts to section 'Tests' -- Changes to xSQLServerHelper - - added functions - - Get-SqlDatabaseRecoveryModel - - Set-SqlDatabaseRecoveryModel -- Examples - - xSQLServerDatabaseRecoveryModel - - 1-SetDatabaseRecoveryModel.ps1 - - xSQLServerDatabasePermission - - 1-GrantDatabasePermissions.ps1 - - 2-RevokeDatabasePermissions.ps1 - - 3-DenyDatabasePermissions.ps1 - - xSQLServerFirewall - - 1-CreateInboundFirewallRules - - 2-RemoveInboundFirewallRules -- Added tests for resources - - xSQLServerDatabaseRecoveryModel - - xSQLServerDatabasePermissions - - xSQLServerFirewall -- Changes to xSQLServerDatabaseRecoveryModel - - BREAKING CHANGE: Renamed xSQLDatabaseRecoveryModel to - xSQLServerDatabaseRecoveryModel to align with naming convention. - - BREAKING CHANGE: The mandatory parameters now include SQLServer, and - SQLInstanceName. -- Changes to xSQLServerDatabasePermission - - BREAKING CHANGE: Renamed xSQLServerDatabasePermissions to - xSQLServerDatabasePermission to align with naming convention. - - BREAKING CHANGE: The mandatory parameters now include PermissionState, - SQLServer, and SQLInstanceName. -- Added support for clustered installations to xSQLServerSetup - - Migrated relevant code from xSQLServerFailoverClusterSetup - - Removed Get-WmiObject usage - - Clustered storage mapping now supports asymmetric cluster storage - - Added support for multi-subnet clusters - - Added localized error messages for cluster object mapping - - Updated README.md to reflect new parameters -- Updated description for xSQLServerFailoverClusterSetup to indicate it is deprecated. -- xPDT helper module - - Function GetxPDTVariable was removed since it no longer was used by any resources. - - File xPDT.xml was removed since it was not used by any resources, and did not - provide any value to the module. -- Changes xSQLServerHelper module - - Removed the globally defined `$VerbosePreference = 'Continue'` from xSQLServerHelper. - - Fixed a typo in a variable name in the function New-ListenerADObject. - - Now Restart-SqlService will correctly show the services it restarts. Also - fixed PSSA warnings. - -## 4.0.0.0 - -- Fixes in xSQLServerConfiguration - - Added support for clustered SQL instances. - - BREAKING CHANGE: Updated parameters to align with other resources - (SQLServer / SQLInstanceName). - - Updated code to utilize CIM rather than WMI. -- Added tests for resources - - xSQLServerConfiguration - - xSQLServerSetup - - xSQLServerDatabaseRole - - xSQLAOGroupJoin - - xSQLServerHelper and moved the existing tests for Restart-SqlService to it. - - xSQLServerAlwaysOnService -- Fixes in xSQLAOGroupJoin - - Availability Group name now appears in the error message for a failed. - Availability Group join attempt. - - Get-TargetResource now works with Get-DscConfiguration. -- Fixes in xSQLServerRole - - Updated Ensure parameter to 'Present' default value. - - Renamed helper functions *-SqlServerRole to *-SqlServerRoleMember. -- Changes to xSQLAlias - - Add UseDynamicTcpPort parameter for option "Dynamically determine port". - - Change Get-WmiObject to Get-CimInstance in Resource and associated pester file. -- Added CHANGELOG.md file. -- Added issue template file (ISSUE\_TEMPLATE.md) for 'New Issue' and pull request - template file (PULL\_REQUEST\_TEMPLATE.md) for 'New Pull Request'. -- Add Contributing.md file. -- Changes to xSQLServerSetup - - Now `Features` parameter is case-insensitive. -- BREAKING CHANGE: Removed xSQLServerPowerPlan from this module. The resource has - been moved to [xComputerManagement](https://github.com/PowerShell/xComputerManagement) - and is now called xPowerPlan. -- Changes and enhancements in xSQLServerDatabaseRole - - BREAKING CHANGE: Fixed so the same user can now be added to a role in one or - more databases, and/or one or more instances. Now the parameters `SQLServer` - and `SQLInstanceName` are mandatory. - - Enhanced so the same user can now be added to more than one role -- BREAKING CHANGE: Renamed xSQLAlias to xSQLServerAlias to align with naming convention. -- Changes to xSQLServerAlwaysOnService - - Added RestartTimeout parameter - - Fixed bug where the SQL Agent service did not get restarted after the - IsHadrEnabled property was set. - - BREAKING CHANGE: The mandatory parameters now include Ensure, SQLServer, and - SQLInstanceName. SQLServer and SQLInstanceName are keys which will be used to - uniquely identify the resource which allows AlwaysOn to be enabled on multiple - instances on the same machine. -- Moved Restart-SqlService from MSFT_xSQLServerConfiguration.psm1 to xSQLServerHelper.psm1. - -## 3.0.0.0 - -- xSQLServerHelper - - added functions - - Test-SQLDscParameterState - - Get-SqlDatabaseOwner - - Set-SqlDatabaseOwner -- Examples - - xSQLServerDatabaseOwner - - 1-SetDatabaseOwner.ps1 -- Added tests for resources - - MSFT_xSQLServerDatabaseOwner - -## 2.0.0.0 - -- Added resources - - xSQLServerReplication - - xSQLServerScript - - xSQLAlias - - xSQLServerRole -- Added tests for resources - - xSQLServerPermission - - xSQLServerEndpointState - - xSQLServerEndpointPermission - - xSQLServerAvailabilityGroupListener - - xSQLServerLogin - - xSQLAOGroupEnsure - - xSQLAlias - - xSQLServerRole -- Fixes in xSQLServerAvailabilityGroupListener - - In one case the Get-method did not report that DHCP was configured. - - Now the resource will throw 'Not supported' when IP is changed between Static - and DHCP. - - Fixed an issue where sometimes the listener wasn't removed. - - Fixed the issue when trying to add a static IP to a listener was ignored. -- Fix in xSQLServerDatabase - - Fixed so dropping a database no longer throws an error - - BREAKING CHANGE: Fixed an issue where it was not possible to add the same - database to two instances on the same server. - - BREAKING CHANGE: The name of the parameter Database has changed. It is now - called Name. -- Fixes in xSQLAOGroupEnsure - - Added parameters to New-ListenerADObject to allow usage of a named instance. - - pass setup credential correctly -- Changes to xSQLServerLogin - - Fixed an issue when dropping logins. - - BREAKING CHANGE: Fixed an issue where it was not possible to add the same - login to two instances on the same server. -- Changes to xSQLServerMaxDop - - BREAKING CHANGE: Made SQLInstance parameter a key so that multiple instances - on the same server can be configured - -## 1.8.0.0 - -- Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey. -- Added Support for SQL Server 2016 -- xSQLAOGroupEnsure - - Fixed spelling mistake in AutoBackupPreference property - - Added BackupPriority property -- Added resources - - xSQLServerPermission - - xSQLServerEndpointState - - xSQLServerEndpointPermission - - xSQLServerAvailabilityGroupListener -- xSQLServerHelper - - added functions - - Import-SQLPSModule - - Get-SQLPSInstanceName - - Get-SQLPSInstance - - Get-SQLAlwaysOnEndpoint - - modified functions - - New-TerminatingError - *added optional parameter `InnerException` to be able - to give the user more information in the returned message* - -## 1.7.0.0 - -- Resources Added - - xSQLServerConfiguration - -## 1.6.0.0 - -- Resources Added - - xSQLAOGroupEnsure - - xSQLAOGroupJoin - - xWaitForAvailabilityGroup - - xSQLServerEndPoint - - xSQLServerAlwaysOnService -- xSQLServerHelper - - added functions - - Connect-SQL - - New-VerboseMessage - - Grant-ServerPerms - - Grant-CNOPerms - - New-ListenerADObject -- xSQLDatabaseRecoveryModel - - Updated Verbose statements to use new function New-VerboseMessage -- xSQLServerDatabase - - Updated Verbose statements to use new function New-VerboseMessage - - Removed ConnectSQL function and replaced with new Connect-SQL function -- xSQLServerDatabaseOwner - - Removed ConnectSQL function and replaced with new Connect-SQL function -- xSQLServerDatabasePermissions - - Removed ConnectSQL function and replaced with new Connect-SQL function -- xSQLServerDatabaseRole - - Removed ConnectSQL function and replaced with new Connect-SQL function -- xSQLServerLogin - - Removed ConnectSQL function and replaced with new Connect-SQL function -- xSQLServerMaxDop - - Updated Verbose statements to use new function New-VerboseMessage - - Removed ConnectSQL function and replaced with new Connect-SQL function -- xSQLServerMemory - - Updated Verbose statements to use new function New-VerboseMessage - - Removed ConnectSQL function and replaced with new Connect-SQL function -- xSQLServerPowerPlan - - Updated Verbose statements to use new function New-VerboseMessage -- Examples - - Added xSQLServerConfiguration resource example - -## 1.5.0.0 - -- Added new resource xSQLServerDatabase that allows adding an empty database to - a server - -## 1.4.0.0 - -- Resources Added - - xSQLDatabaseRecoveryModeAdded - - xSQLServerDatabaseOwner - - xSQLServerDatabasePermissions - - xSQLServerDatabaseRole - - xSQLServerLogin - - xSQLServerMaxDop - - xSQLServerMemory - - xSQLServerPowerPlan - - xSQLServerDatabase -- xSQLServerSetup: - - Corrected bug in GetFirstItemPropertyValue to correctly handle registry keys - with only one value. - - Added support for SQL Server - - 2008 R2 installation - - Removed default values for parameters, to avoid compatibility issues and setup - errors - - Added Replication sub feature detection - - Added setup parameter BrowserSvcStartupType - - Change SourceFolder to Source to allow for multi version Support - - Add Source Credential for accessing source files - - Add Parameters for SQL Server configuration - - Add Parameters to SuppressReboot or ForceReboot -- xSQLServerFirewall - - Removed default values for parameters, to avoid compatibility issues - - Updated firewall rule name to not use 2012 version, since package supports 2008, - 2012 and 2014 versions - - Additional of SQLHelper Function and error handling - - Change SourceFolder to Source to allow for multi version Support -- xSQLServerNetwork - - Added new resource that configures network settings. - - Currently supports only tcp network protocol - - Allows to enable and disable network protocol for specified instance service - - Allows to set custom or dynamic port values -- xSQLServerRSSecureConnectionLevel - - Additional of SQLHelper Function and error handling -- xSqlServerRSConfig -- xSQLServerFailoverClusterSetup - - Additional of SQLHelper Function and error handling - - Change SourceFolder to Source to allow for multi version Support - - Add Parameters to SuppressReboot or ForceReboot -- Examples - - Updated example files to use correct DebugMode parameter value ForceModuleImport, - this is not boolean in WMF 5.0 RTM - - Added xSQLServerNetwork example - -## 1.3.0.0 - -- xSqlServerSetup - - Make Features case-insensitive. - -## 1.2.1.0 - -- Increased timeout for setup process to start to 60 seconds. - -## 1.2.0.0 - -- Updated release with the following new resources - - xSQLServerFailoverClusterSetup - - xSQLServerRSConfig +- SqlServerDsc + - Add .gitattributes file to checkout file correctly with CRLF. + - Updated .vscode/analyzersettings.psd1 file to correct use PSSA rules + and custom rules in VS Code. + - Fix hashtables to align with style guideline ([issue #1437](https://github.com/PowerShell/SqlServerDsc/issues/1437)). + - Updated most examples to remove the need for the variable `$ConfigurationData`, + and fixed style issues. +- SqlServerMaxDop + - Fix line endings in code which did not use the correct format. +- SqlAlwaysOnService + - The integration test has been temporarily disabled because when + the cluster feature is installed it requires a reboot on the + Windows Server 2019 build worker. -## 1.1.0.0 +### Fixed -- Initial release with the following resources - - xSQLServerSetup - - xSQLServerFirewall - - xSQLServerRSSecureConnectionLevel +- SqlAlwaysOnService + - When failing to enable AlwaysOn the resource should now fail with an + error ([issue #1190](https://github.com/dsccommunity/SqlServerDsc/issues/1190)). diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 1d5c9eab1..d7589ddbb 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,6 +1,3 @@ -# Code of conduct +# Code of Conduct -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/) -or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional -questions or comments. +This project has adopted the [DSC Community Code of Conduct](https://dsccommunity.org/code_of_conduct). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 996b7d028..19b11d708 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,11 +6,9 @@ to use, and we would love to have contributions from the community. ## Core contribution guidelines -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. +Please check out common DSC Community [guidelines](https://dsccommunity.org/guidelines). -## SqlServerDsc specific guidelines +## Specific guidelines for SqlServerDsc ### Automatic formatting with VS Code @@ -101,23 +99,23 @@ naming structure using the following components. #### mof-based resource All mof-based resource (with Get/Set/Test-TargetResource) should be prefixed with -'MSFT\_Sql'. I.e. MSFT\_SqlDatabase +'DSC\_Sql'. I.e. DSC\_SqlDatabase -Please note that not all places should contain the prefix 'MSFT\_'. +Please note that not all places should contain the prefix 'DSC\_'. ##### Folder and file structure -Please note that for the examples folder we don't use the 'MSFT\_' prefix on the +Please note that for the examples folder we don't use the 'DSC\_' prefix on the resource folders. This is to make those folders more user friendly, to resemble the name the user would use in the configuration file. ```Text -DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 -DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof -DSCResources/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1 +DSCResources/DSC_SqlServerConfiguration/DSC_SqlServerConfiguration.psm1 +DSCResources/DSC_SqlServerConfiguration/DSC_SqlServerConfiguration.schema.mof +DSCResources/DSC_SqlServerConfiguration/en-US/DSC_SqlServerConfiguration.strings.psd1 -Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 +Tests/Unit/DSC_SqlServerConfiguration.Tests.ps1 Examples/Resources/SqlServerConfiguration/1-AddConfigurationOption.ps1 Examples/Resources/SqlServerConfiguration/2-RemoveConfigurationOption.ps1 @@ -126,11 +124,11 @@ Examples/Resources/SqlServerConfiguration/2-RemoveConfigurationOption.ps1 ##### Schema mof file Please note that the `FriendlyName` in the schema mof file should not contain the -prefix `MSFT\_`. +prefix `DSC\_`. ```powershell [ClassVersion("1.0.0.0"), FriendlyName("SqlServerConfiguration")] -class MSFT_SqlServerConfiguration : OMI_BaseResource +class DSC_SqlServerConfiguration : OMI_BaseResource { # Properties removed for readability. }; @@ -143,15 +141,11 @@ with just 'Sql' ### Localization -#### HQRM localization - -These should replace the old localization helper function whenever possible. - 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_SqlSetup.strings.psd1'. +'DSC_ResourceName.strings.psd1', i.e. +'DSC_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. @@ -166,186 +160,13 @@ ConvertFrom-StringData @' '@ ``` -This is an example of how to write localized verbose messages. - -```powershell -Write-Verbose -Message ($script:localizedData.InstallingUsingPathMessage -f $path) -``` - -This is an example of how to write localized warning messages. - -```powershell -Write-Warning -Message ` - ($script:localizedData.InstallationReportedProblemMessage -f $path) -``` - -This is an example of how to throw localized error messages. The helper functions -`New-InvalidArgumentException` and `New-InvalidOperationException` (see below) should -preferably be used whenever possible. - -```powershell -throw ($script:localizedData.InstallationFailedMessage -f $Path, $processId) -``` - -##### Helper functions - -There are also five helper functions to simplify localization. - -###### New-InvalidArgumentException - -```powershell -<# - .SYNOPSIS - Creates and throws an invalid argument exception - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ArgumentName - The name of the invalid argument that is causing this error to be thrown -#> -``` - -This can be used in code like this. - -```powershell -if ( -not $resultOfEvaluation ) -{ - $errorMessage = ` - $script:localizedData.ActionCannotBeUsedInThisContextMessage ` - -f $Action, $Parameter - - New-InvalidArgumentException -ArgumentName 'Action' -Message $errorMessage -} -``` - -###### New-InvalidOperationException - -```powershell -<# - .SYNOPSIS - Creates and throws an invalid operation exception - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating - error -#> -``` - -This can be used in code like this. - -```powershell -try -{ - Start-Process @startProcessArguments -} -catch -{ - $errorMessage = $script:localizedData.InstallationFailedMessage -f $Path, $processId - New-InvalidOperationException -Message $errorMessage -ErrorRecord $_ -} - -``` - -###### New-ObjectNotFoundException - -```powershell -<# - .SYNOPSIS - Creates and throws an object not found exception - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating - error -#> -``` - -This can be used in code like this. - -```powershell -try -{ - Get-ChildItem -Path $path -} -catch -{ - $errorMessage = $script:localizedData.PathNotFoundMessage -f $path - New-ObjectNotFoundException -Message $errorMessage -ErrorRecord $_ -} - -``` - -###### New-InvalidResultException - -```powershell -<# - .SYNOPSIS - Creates and throws an invalid result exception - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating - error -#> -``` - -This can be used in code like this. - -```powershell -try -{ - $numberOfObjects = Get-ChildItem -Path $path - if ($numberOfObjects -eq 0) - { - throw 'To few files.' - } -} -catch -{ - $errorMessage = $script:localizedData.TooFewFilesMessage -f $path - New-InvalidResultException -Message $errorMessage -ErrorRecord $_ -} - -``` - -###### Get-LocalizedData - -```powershell -<# - .SYNOPSIS - Retrieves the localized string data based on the machine's culture. - Falls back to en-US strings if the machine's culture is not supported. - - .PARAMETER ResourceName - The name of the resource as it appears before '.strings.psd1' of the - localized string file. -#> -``` - -This should be used at the top of each resource like this. - -```powershell -Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) ` - -ChildPath 'CommonResourceHelper.psm1') - -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlSetup' -``` - ### Helper functions -Helper functions or wrapper functions that are used by the resource can preferably +Helper functions or wrapper functions that are used only by the resource can preferably 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 -[SqlServerDscHelper.psm1](https://github.com/PowerShell/SqlServerDsc/blob/dev/SqlServerDscHelper.psm1) +one resource, then the functions can also be placed in the common module +[SqlServerDsc.Common](https://github.com/dsccommunity/SqlServerDsc/blob/master/source/Modules/SqlServerDsc.Common) module file. ### Unit tests @@ -354,52 +175,16 @@ For a review of a Pull Request (PR) to start, all tests must pass without error. If you need help to figure why some test don't pass, just write a comment in the Pull Request (PR), or submit an issue, and somebody will come along and assist. -To run all unit tests manually run the following. - -```powershell -cd '' -.\Assert-TestEnvironment.ps1 -Confirm -Verbose -cd '\Tests\Unit' -Invoke-Pester -``` - -The script `Assert-TestEnvironment.ps1` will clone the test framework -from GitHub, and load some necessary types which is needed to run some -of the tests. Read more about the bootstrap script in the section -[Bootstrap script Assert-TestEnvironment](#bootstrap-script-assert-testenvironment). - -The cmdlet `Invoke-Pester` looks for all the '*.Tests.ps1' PowerShell -script files recursively and executes the tests. - -#### Unit tests for style check of Markdown files - -When sending in a Pull Request (PR) a style check will be performed on all Markdown -files, and if the tests find any error the build will fail. -See the section [Documentation with Markdown](#documentation-with-markdown) how -these errors kan be found before sending in the PR. - -The Markdown tests can be run locally if the packet manager 'npm' is available. -To have npm available you need to install [node.js](https://nodejs.org/en/download/). -If 'npm' is not available, a warning text will print and the rest of the tests -will continue run. - #### Unit tests for examples files 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 SqlServerDsc module -deployed to a path where it can be used. -See `$env:PSModulePath` to view the existing paths. ### Integration tests Integration tests should be written for resources so they can be validated by -the automated test framework which is run in AppVeyor when commits are pushed -to a Pull Request (PR). -Please see the [Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md) -for common DSC Resource Kit testing guidelines. +the CI. + There are also configuration made by existing integration tests that can be reused to write integration tests for other resources. This is documented in [Integration tests for SqlServerDsc](https://github.com/PowerShell/SqlServerDsc/blob/dev/Tests/Integration/README.md). @@ -410,43 +195,9 @@ There are [stub classes](https://github.com/PowerShell/SqlServerDsc/blob/dev/Tes for the SMO classes which can be used and improved on when creating tests where SMO classes are used in the code being tested. -#### AppVeyor - -AppVeyor is the platform where the tests is run when sending in a Pull Request (PR). -All tests are run on a clean AppVeyor build worker for each push to the Pull -Request (PR). -The tests that are run on the build worker are common tests, unit tests and -integration tests (with some limitations). - ### Documentation with Markdown If using Visual Studio Code to edit Markdown files it can be a good idea to install the markdownlint extension. It will help to do style checking. The file [.markdownlint.json](/.markdownlint.json) is prepared with a default set of rules which will automatically be used by the extension. - -## Bootstrap script Assert-TestEnvironment - -The bootstrap script [`Assert-TestEnvironment.ps1`](Assert-TestEnvironment.ps1) -was needed when tests were updated to run in containers. -There are some custom types (`Microsoft.DscResourceKit.*`) that are needed -to be able to parse the test script files. Those types must be loaded -into the session prior to running any unit tests with `Invoke-Pester`. - -The script works without any parameters and will do the following. - ->**Note:** If you want to confirm each step, then add the `-Confirm` ->parameter. - -- Check if a compatible *Pester* version is available. -- Check if a compatible *PSDepend* version is available. -- Invoke PSDepend (using `Tests/Tests.depend.psd1`). - - Remove local cloned repository *DscResource.Tests* if it is present - (always assumes it's an older version). - - Clone *DscResource.Tests* from GitHub into the local repository - folder, and check out the branch `dev` to always be on the latest - commit available. - - Load the necessary types from the test framework *DscResource.Tests*. - -If there are no compatible Pester or PSDepend version available, you will be asked -to install it manually, and then run the script again. diff --git a/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 b/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 deleted file mode 100644 index 8fd20b834..000000000 --- a/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -<# -.EXAMPLE -This example shows how to ensure that the Availability Group 'TestAG' does not exist. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - }, - - @{ - NodeName = 'SP23-VM-SQL1' - Role = 'PrimaryReplica' - } - ) -} - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node $AllNodes.NodeName { - if ( $Node.Role -eq 'PrimaryReplica' ) - { - # Create the availability group on the instance tagged as the primary replica - SqlAG RemoveTestAG - { - Ensure = 'Absent' - Name = 'TestAG' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - } -} diff --git a/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 b/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 deleted file mode 100644 index b0b2b252a..000000000 --- a/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 +++ /dev/null @@ -1,121 +0,0 @@ -<# -.EXAMPLE - This example shows how to ensure that the Availability Group 'TestAG' exists. - - In the event this is applied to a Failover Cluster Instance (FCI), the - ProcessOnlyOnActiveNode property will tell the Test-TargetResource function - to evaluate if any changes are needed if the node is actively hosting the - SQL Server Instance. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - ProcessOnlyOnActiveNode = $true - - AutomatedBackupPreference = 'Primary' - AvailabilityMode = 'SynchronousCommit' - BackupPriority = 50 - ConnectionModeInPrimaryRole = 'AllowAllConnections' - ConnectionModeInSecondaryRole = 'AllowNoConnections' - FailoverMode = 'Automatic' - HealthCheckTimeout = 15000 - - BasicAvailabilityGroup = $false - DatabaseHealthTrigger = $true - DtcSupportEnabled = $true - }, - - @{ - NodeName = 'SP23-VM-SQL1' - Role = 'PrimaryReplica' - } - ) -} - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node $AllNodes.NodeName - { - # Adding the required service account to allow the cluster to log into SQL - SqlServerLogin AddNTServiceClusSvc - { - Ensure = 'Present' - Name = 'NT SERVICE\ClusSvc' - LoginType = 'WindowsUser' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Add the required permissions to the cluster service login - SqlServerPermission AddNTServiceClusSvcPermissions - { - DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' - Ensure = 'Present' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - Principal = 'NT SERVICE\ClusSvc' - Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Create a DatabaseMirroring endpoint - SqlServerEndpoint HADREndpoint - { - EndPointName = 'HADR' - Ensure = 'Present' - Port = 5022 - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlAlwaysOnService EnableHADR - { - Ensure = 'Present' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - # Create the availability group on the instance tagged as the primary replica - SqlAG AddTestAG - { - Ensure = 'Present' - Name = 'TestAG' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - ProcessOnlyOnActiveNode = $Node.ProcessOnlyOnActiveNode - - AutomatedBackupPreference = $Node.AutomatedBackupPreference - AvailabilityMode = $Node.AvailabilityMode - BackupPriority = $Node.BackupPriority - ConnectionModeInPrimaryRole = $Node.ConnectionModeInPrimaryRole - ConnectionModeInSecondaryRole = $Node.ConnectionModeInSecondaryRole - FailoverMode = $Node.FailoverMode - HealthCheckTimeout = $Node.HealthCheckTimeout - - # sql server 2016 or later only - BasicAvailabilityGroup = $Node.BasicAvailabilityGroup - DatabaseHealthTrigger = $Node.DatabaseHealthTrigger - DtcSupportEnabled = $Node.DtcSupportEnabled - - DependsOn = '[SqlAlwaysOnService]EnableHADR', '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - } -} diff --git a/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 deleted file mode 100644 index 679c2f452..000000000 --- a/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 +++ /dev/null @@ -1,130 +0,0 @@ -<# -.EXAMPLE - This example shows how to ensure that the databases 'DB*' and 'AdventureWorks' are members in the Availability Group 'TestAG'. - - In the event this is applied to a Failover Cluster Instance (FCI), the - ProcessOnlyOnActiveNode property will tell the Test-TargetResource function - to evaluate if any changes are needed if the node is actively hosting the - SQL Server Instance. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - AvailabilityGroupName = 'TestAG' - }, - - @{ - NodeName = 'SQL1' - Role = 'PrimaryReplica' - }, - - @{ - NodeName = 'SQL2' - Role = 'SecondaryReplica' - } - ) -} - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node $AllNodes.NodeName - { - # Adding the required service account to allow the cluster to log into SQL - SqlServerLogin AddNTServiceClusSvc - { - Ensure = 'Present' - Name = 'NT SERVICE\ClusSvc' - LoginType = 'WindowsUser' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Add the required permissions to the cluster service login - SqlServerPermission AddNTServiceClusSvcPermissions - { - DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' - Ensure = 'Present' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - Principal = 'NT SERVICE\ClusSvc' - Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Create a DatabaseMirroring endpoint - SqlServerEndpoint HADREndpoint - { - EndPointName = 'HADR' - Ensure = 'Present' - Port = 5022 - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlAlwaysOnService EnableHADR - { - Ensure = 'Present' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - # Create the availability group on the instance tagged as the primary replica - SqlAG AddTestAG - { - Ensure = 'Present' - Name = $Node.AvailabilityGroupName - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - DependsOn = '[SqlAlwaysOnService]EnableHADR', '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - - if ( $Node.Role -eq 'SecondaryReplica' ) - { - # Add the availability group replica to the availability group - SqlAGReplica AddReplica - { - Ensure = 'Present' - Name = $Node.NodeName - AvailabilityGroupName = $Node.AvailabilityGroupName - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PrimaryReplicaServerName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName - PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).InstanceName - DependsOn = '[SqlAlwaysOnService]EnableHADR' - } - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - SqlAGDatabase 'TestAGDatabaseMemberships' - { - AvailabilityGroupName = $Node.AvailabilityGroupName - BackupPath = '\\SQL1\AgInitialize' - DatabaseName = 'DB*', 'AdventureWorks' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - Ensure = 'Present' - ProcessOnlyOnActiveNode = $true - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - } -} diff --git a/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 deleted file mode 100644 index 32f22a0f1..000000000 --- a/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 +++ /dev/null @@ -1,114 +0,0 @@ -<# -.EXAMPLE - This example shows how to ensure that the databases 'DB*' and 'AdventureWorks' are not members of the Availability Group 'TestAG'. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - AvailabilityGroupName = 'TestAG' - }, - - @{ - NodeName = 'SQL1' - Role = 'PrimaryReplica' - }, - - @{ - NodeName = 'SQL2' - Role = 'SecondaryReplica' - } - ) -} - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node $AllNodes.NodeName { - # Adding the required service account to allow the cluster to log into SQL - SqlServerLogin AddNTServiceClusSvc - { - Ensure = 'Present' - Name = 'NT SERVICE\ClusSvc' - LoginType = 'WindowsUser' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Add the required permissions to the cluster service login - SqlServerPermission AddNTServiceClusSvcPermissions - { - DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' - Ensure = 'Present' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - Principal = 'NT SERVICE\ClusSvc' - Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Create a DatabaseMirroring endpoint - SqlServerEndpoint HADREndpoint - { - EndPointName = 'HADR' - Ensure = 'Present' - Port = 5022 - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - # Create the availability group on the instance tagged as the primary replica - SqlAG AddTestAG - { - Ensure = 'Present' - Name = $Node.AvailabilityGroupName - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - - if ( $Node.Role -eq 'SecondaryReplica' ) - { - # Add the availability group replica to the availability group - SqlAGReplica AddReplica - { - Ensure = 'Present' - Name = $Node.NodeName - AvailabilityGroupName = $Node.AvailabilityGroupName - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PrimaryReplicaServerName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName - PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).InstanceName - } - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - SqlAGDatabase 'TestAGDatabaseMemberships' - { - AvailabilityGroupName = $Node.AvailabilityGroupName - BackupPath = '\\SQL1\AgInitialize' - DatabaseName = 'DB*', 'AdventureWorks' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - Ensure = 'Absent' - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - } -} diff --git a/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 b/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 deleted file mode 100644 index 72d7ae0e7..000000000 --- a/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 +++ /dev/null @@ -1,125 +0,0 @@ -<# -.EXAMPLE - This example shows how to ensure that the databases 'DB*' and 'AdventureWorks' are the only members of the Availability Group 'TestAG'. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - AvailabilityGroupName = 'TestAG' - }, - - @{ - NodeName = 'SQL1' - Role = 'PrimaryReplica' - }, - - @{ - NodeName = 'SQL2' - Role = 'SecondaryReplica' - } - ) -} - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node $AllNodes.NodeName - { - # Adding the required service account to allow the cluster to log into SQL - SqlServerLogin AddNTServiceClusSvc - { - Ensure = 'Present' - Name = 'NT SERVICE\ClusSvc' - LoginType = 'WindowsUser' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Add the required permissions to the cluster service login - SqlServerPermission AddNTServiceClusSvcPermissions - { - DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' - Ensure = 'Present' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - Principal = 'NT SERVICE\ClusSvc' - Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Create a DatabaseMirroring endpoint - SqlServerEndpoint HADREndpoint - { - EndPointName = 'HADR' - Ensure = 'Present' - Port = 5022 - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlAlwaysOnService EnableHADR - { - Ensure = 'Present' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - # Create the availability group on the instance tagged as the primary replica - SqlAG AddTestAG - { - Ensure = 'Present' - Name = $Node.AvailabilityGroupName - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - DependsOn = '[SqlAlwaysOnService]EnableHADR', '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - - if ( $Node.Role -eq 'SecondaryReplica' ) - { - # Add the availability group replica to the availability group - SqlAGReplica AddReplica - { - Ensure = 'Present' - Name = $Node.NodeName - AvailabilityGroupName = $Node.AvailabilityGroupName - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PrimaryReplicaServerName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName - PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).InstanceName - DependsOn = '[SqlAlwaysOnService]EnableHADR' - } - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - SqlAGDatabase 'TestAGDatabaseMemberships' - { - AvailabilityGroupName = $Node.AvailabilityGroupName - BackupPath = '\\SQL1\AgInitialize' - DatabaseName = 'DB*', 'AdventureWorks' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - Ensure = 'Present' - Force = $true - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - } -} diff --git a/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 b/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 deleted file mode 100644 index e2434ca25..000000000 --- a/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 +++ /dev/null @@ -1,117 +0,0 @@ -<# -.EXAMPLE - This example shows how to ensure that the Availability Group Replica 'SQL2' exists in the Availability Group 'TestAG'. - - In the event this is applied to a Failover Cluster Instance (FCI), the - ProcessOnlyOnActiveNode property will tell the Test-TargetResource function - to evaluate if any changes are needed if the node is actively hosting the - SQL Server Instance. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - AvailabilityGroupName = 'TestAG' - ProcessOnlyOnActiveNode = $true - }, - - @{ - NodeName = 'SQL1' - Role = 'PrimaryReplica' - }, - - @{ - NodeName = 'SQL2' - Role = 'SecondaryReplica' - } - ) -} - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node $AllNodes.NodeName - { - # Adding the required service account to allow the cluster to log into SQL - SqlServerLogin AddNTServiceClusSvc - { - Ensure = 'Present' - Name = 'NT SERVICE\ClusSvc' - LoginType = 'WindowsUser' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Add the required permissions to the cluster service login - SqlServerPermission AddNTServiceClusSvcPermissions - { - DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' - Ensure = 'Present' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - Principal = 'NT SERVICE\ClusSvc' - Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Create a DatabaseMirroring endpoint - SqlServerEndpoint HADREndpoint - { - EndPointName = 'HADR' - Ensure = 'Present' - Port = 5022 - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlAlwaysOnService EnableHADR - { - Ensure = 'Present' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - # Create the availability group on the instance tagged as the primary replica - SqlAG AddTestAG - { - Ensure = 'Present' - Name = $Node.AvailabilityGroupName - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - DependsOn = '[SqlAlwaysOnService]EnableHADR', '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - - if ( $Node.Role -eq 'SecondaryReplica' ) - { - # Add the availability group replica to the availability group - SqlAGReplica AddReplica - { - Ensure = 'Present' - Name = $Node.NodeName - AvailabilityGroupName = $Node.AvailabilityGroupName - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PrimaryReplicaServerName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName - PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).InstanceName - DependsOn = '[SqlAlwaysOnService]EnableHADR' - ProcessOnlyOnActiveNode = $Node.ProcessOnlyOnActiveNode - } - } - } -} diff --git a/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 b/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 deleted file mode 100644 index 530de81ae..000000000 --- a/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 +++ /dev/null @@ -1,100 +0,0 @@ -<# -.EXAMPLE - This example shows how to ensure that the Availability Group Replica 'SQL2' does not exist in the Availability Group 'TestAG'. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - AvailabilityGroupName = 'TestAG' - }, - - @{ - NodeName = 'SQL1' - Role = 'PrimaryReplica' - }, - - @{ - NodeName = 'SQL2' - Role = 'SecondaryReplica' - } - ) -} - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node $AllNodes.NodeName { - # Adding the required service account to allow the cluster to log into SQL - SqlServerLogin AddNTServiceClusSvc - { - Ensure = 'Present' - Name = 'NT SERVICE\ClusSvc' - LoginType = 'WindowsUser' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Add the required permissions to the cluster service login - SqlServerPermission AddNTServiceClusSvcPermissions - { - DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' - Ensure = 'Present' - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - Principal = 'NT SERVICE\ClusSvc' - Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' - PsDscRunAsCredential = $SqlAdministratorCredential - } - - # Create a DatabaseMirroring endpoint - SqlServerEndpoint HADREndpoint - { - EndPointName = 'HADR' - Ensure = 'Present' - Port = 5022 - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PsDscRunAsCredential = $SqlAdministratorCredential - } - - if ( $Node.Role -eq 'PrimaryReplica' ) - { - # Create the availability group on the instance tagged as the primary replica - SqlAG AddTestAG - { - Ensure = 'Present' - Name = $Node.AvailabilityGroupName - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - DependsOn = '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' - PsDscRunAsCredential = $SqlAdministratorCredential - } - } - - if ( $Node.Role -eq 'SecondaryReplica' ) - { - # Add the availability group replica to the availability group - SqlAGReplica AddReplica - { - Ensure = 'Absent' - Name = $Node.NodeName - AvailabilityGroupName = $Node.AvailabilityGroupName - ServerName = $Node.NodeName - InstanceName = $Node.InstanceName - PrimaryReplicaServerName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName - PrimaryReplicaInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).InstanceName - } - } - } -} diff --git a/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 b/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 deleted file mode 100644 index 5e4859ecd..000000000 --- a/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# - .EXAMPLE - This example shows how to ensure that the SQL Agent Alert - Sev17 exists with the correct severity level. - - .EXAMPLE - This example shows how to ensure that the SQL Agent Alert - Msg825 exists with the correct message id. -#> - -Configuration Example -{ - - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlAgentAlert Add_Sev17 { - Ensure = 'Present' - Name = 'Sev17' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - Severity = '17' - } - - SqlAgentAlert Add_Msg825 { - Ensure = 'Present' - Name = 'Msg825' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - MessageId = '825' - } - } -} diff --git a/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 b/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 deleted file mode 100644 index 2426862fa..000000000 --- a/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# - .EXAMPLE - This example shows how to ensure that the SQL Agent Alert - Sev17 does not exist. - - .EXAMPLE - This example shows how to ensure that the SQL Agent Alert - Msg825 does not exist. -#> - -Configuration Example -{ - - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlAgentAlert Remove_Sev17 { - Ensure = 'Absent' - Name = 'Sev17' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - } - - SqlAgentAlert Remove_Msg825 { - Ensure = 'Absent' - Name = 'Msg825' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - } - } -} diff --git a/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 b/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 deleted file mode 100644 index a95dcc4e7..000000000 --- a/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -<# - .EXAMPLE - This example shows how to ensure that the SQL Agent - Failsafe Operator 'FailsafeOp' exists with the correct Notification. -#> - -Configuration Example -{ - - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlAgentFailsafe Add_FailsafeOp { - Ensure = 'Present' - Name = 'FailsafeOp' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - NotificationMethod = 'NotifyEmail' - } - } -} diff --git a/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 b/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 deleted file mode 100644 index b9232e2d0..000000000 --- a/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -<# - .EXAMPLE - This example shows how to ensure that the SQL Agent - failsafe operator FailsafeOp does not exist. -#> - -Configuration Example -{ - - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlAgentFailsafe Remove_FailsafeOp { - Ensure = 'Absent' - Name = 'FailsafeOp' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - } - } -} diff --git a/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 b/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 deleted file mode 100644 index c10b38ed2..000000000 --- a/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -<# - .EXAMPLE - This example shows how to ensure that the SQL Agent Operator - DbaTeam exists with the correct email address. -#> - -Configuration Example -{ - - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlAgentOperator Add_DbaTeam { - Ensure = 'Present' - Name = 'DbaTeam' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - EmailAddress = 'dbateam@company.com' - } - } -} diff --git a/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 b/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 deleted file mode 100644 index a4a94d8c8..000000000 --- a/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -<# - .EXAMPLE - This example shows how to ensure that the SQL Agent Operator - DbaTeam does not exist. -#> - -Configuration Example -{ - - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlAgentOperator Remove_DbaTeam { - Ensure = 'Absent' - Name = 'DbaTeam' - ServerName = 'TestServer' - InstanceName = 'MSSQLServer' - } - } -} diff --git a/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 b/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 deleted file mode 100644 index 72fc8a8ce..000000000 --- a/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -<# -.EXAMPLE - This example shows how to create a database with - the database name equal to 'Contoso'. - - The second example shows how to create a database - with a different collation. -#> -Configuration Example -{ - param - ( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - node localhost - { - SqlDatabase Create_Database - { - Ensure = 'Present' - ServerName = 'sqltest.company.local' - InstanceName = 'DSC' - Name = 'Contoso' - - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlDatabase Create_Database_with_different_collation - { - Ensure = 'Present' - ServerName = 'sqltest.company.local' - InstanceName = 'DSC' - Name = 'AdventureWorks' - Collation = 'SQL_Latin1_General_Pref_CP850_CI_AS' - - PsDscRunAsCredential = $SqlAdministratorCredential - } - } -} diff --git a/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 b/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 deleted file mode 100644 index 480a14e40..000000000 --- a/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -<# -.EXAMPLE - This example shows how to remove a database with - the database name equal to 'AdventureWorks'. -#> -Configuration Example -{ - param - ( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - node localhost - { - SqlDatabase Delete_Database - { - Ensure = 'Absent' - ServerName = 'sqltest.company.local' - InstanceName = 'DSC' - Name = 'AdventureWorks' - - PsDscRunAsCredential = $SqlAdministratorCredential - } - } -} diff --git a/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 b/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 deleted file mode 100644 index 8161ca8d7..000000000 --- a/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -<# -.EXAMPLE - This example performs a default SQL Server Reporting Services configuration. - It will initialize SQL Server Reporting Services and register default - Report Server Web Service and Report Manager URLs. - - Report Server Web Service: http://localhost:80/ReportServer - Report Manager: http://localhost:80/Reports -#> -Configuration Example -{ - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlRS DefaultConfiguration - { - InstanceName = 'MSSQLSERVER' - DatabaseServerName = 'localhost' - DatabaseInstanceName = 'MSSQLSERVER' - } - } -} diff --git a/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 b/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 deleted file mode 100644 index af713180d..000000000 --- a/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# -.EXAMPLE - This example performs a custom SQL Server Reporting Services configuration. - It will initialize SQL Server Reporting Services and register the below - custom Report Server Web Service and Report Manager URLs. - - Report Server Web Service: - http://localhost:80/MyReportServer - https://localhost:443/MyReportServer - - Report Manager: - http://localhost:80/MyReports - https://localhost:443/MyReports - - Note: this resource does not currently handle SSL bindings for HTTPS endpoints. -#> -Configuration Example -{ - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlRS DefaultConfiguration - { - InstanceName = 'MSSQLSERVER' - DatabaseServerName = 'localhost' - DatabaseInstanceName = 'MSSQLSERVER' - ReportServerVirtualDirectory = 'MyReportServer' - ReportsVirtualDirectory = 'MyReports' - ReportServerReservedUrl = @('http://+:80', 'https://+:443') - ReportsReservedUrl = @('http://+:80', 'https://+:443') - } - } -} diff --git a/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 b/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 deleted file mode 100644 index 4e2c546e3..000000000 --- a/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -<# -.EXAMPLE - This example performs a custom SQL Server Reporting Services configuration. - It will initialize SQL Server Reporting Services and register the below - custom Report Server Web Service and Report Manager URLs and enable SSL. - - Report Server Web Service: https://localhost:443/MyReportServer () - Report Manager: https://localhost:443/MyReports - - Note: this resource does not currently handle SSL bindings for HTTPS endpoints. -#> -Configuration Example -{ - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlRS DefaultConfiguration - { - InstanceName = 'MSSQLSERVER' - DatabaseServerName = 'localhost' - DatabaseInstanceName = 'MSSQLSERVER' - ReportServerVirtualDirectory = 'MyReportServer' - ReportsVirtualDirectory = 'MyReports' - ReportServerReservedUrl = @('https://+:443') - ReportsReservedUrl = @('https://+:443') - UseSsl = $true - } - } -} diff --git a/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 b/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 deleted file mode 100644 index c439c693e..000000000 --- a/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 +++ /dev/null @@ -1,139 +0,0 @@ -<# -.EXAMPLE - This example installs to instances where the first named instance is used for - the Reporting Services databases, and the second named instance is used for - Reporting Services. After installing the two instances, the configuration - performs a default SQL Server Reporting Services configuration. It will - initialize SQL Server Reporting Services and register the default - Report Server Web Service and Report Manager URLs: - - Report Manager: http://localhost:80/Reports_RS - Report Server Web Service: http://localhost:80/ReportServer_RS -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - - # This is values used for the Reporting Services instance. - InstanceName = 'RS' - Features = 'RS' - - # This is values used for the Database Engine instance. - DatabaseServerName = $env:COMPUTERNAME - DatabaseServerInstanceName = 'RSDB' - DatabaseServerFeatures = 'SQLENGINE' - DatabaseServerCollation = 'Finnish_Swedish_CI_AS' - - # This is values used for both instances. - MediaPath = 'Z:\Sql2016Media' - InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' - InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' - UpdateEnabled = 'False' - BrowserSvcStartupType = 'Automatic' - } - ) -} - -Configuration Example -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.Management.Automation.PSCredential] - $SqlInstallCredential, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.Management.Automation.PSCredential] - $SqlServiceCredential, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.Management.Automation.PSCredential] - $SqlAgentServiceCredential, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.Management.Automation.PSCredential] - $ReportingServicesServiceCredential - ) - - Import-DscResource -ModuleName PSDscResources - Import-DscResource -ModuleName SqlServerDsc - - Node localhost { - WindowsFeature 'NetFramework45' - { - Name = 'NET-Framework-45-Core' - Ensure = 'Present' - } - - SqlSetup 'InstallDatabaseEngine' - { - InstanceName = $Node.DatabaseServerInstanceName - Features = $Node.DatabaseServerFeatures - SourcePath = $Node.MediaPath - BrowserSvcStartupType = $Node.BrowserSvcStartupType - SQLCollation = $Node.DatabaseServerCollation - SQLSvcAccount = $SqlServiceCredential - AgtSvcAccount = $SqlAgentServiceCredential - InstallSharedDir = $Node.InstallSharedDir - InstallSharedWOWDir = $Node.InstallSharedWOWDir - UpdateEnabled = $Node.UpdateEnabled - - SQLSysAdminAccounts = @( - $SqlAdministratorCredential.UserName - ) - - PsDscRunAsCredential = $SqlInstallCredential - - DependsOn = @( - '[WindowsFeature]NetFramework45' - ) - } - - SqlSetup 'InstallReportingServicesInstance' - { - InstanceName = $Node.InstanceName - Features = $Node.Features - SourcePath = $Node.MediaPath - BrowserSvcStartupType = $Node.BrowserSvcStartupType - RSSvcAccount = $ReportingServicesServiceCredential - InstallSharedDir = $Node.InstallSharedDir - InstallSharedWOWDir = $Node.InstallSharedWOWDir - UpdateEnabled = $Node.UpdateEnabled - - PsDscRunAsCredential = $SqlInstallCredential - - DependsOn = @( - '[WindowsFeature]NetFramework45' - '[SqlSetup]InstallDatabaseEngine' - ) - } - - SqlRS 'ConfigureReportingServiceInstance' - { - # Instance name for the Reporting Services. - InstanceName = $Node.InstanceName - - # Instance for Reporting Services databases. - DatabaseServerName = $Node.DatabaseServerName - DatabaseInstanceName = $Node.DatabaseServerInstanceName - - PsDscRunAsCredential = $SqlInstallCredential - - DependsOn = @( - '[SqlSetup]InstallReportingServicesInstance' - ) - } - } -} diff --git a/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 b/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 deleted file mode 100644 index b1f0a9eaf..000000000 --- a/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 +++ /dev/null @@ -1,66 +0,0 @@ -<# -.EXAMPLE - This example uses the Configuration Data to pass the Query Strings fo SqlScriptQuery Resource. -#> - -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - ServerName = $env:COMPUTERNAME - InstanceName = 'DSCTEST' - DatabaseName = 'ScriptDatabase1' - - GetSqlQuery = @' -SELECT Name FROM sys.databases WHERE Name = '$(DatabaseName)' FOR JSON AUTO -'@ - - TestSqlQuery = @' -if (select count(name) from sys.databases where name = '$(DatabaseName)') = 0 -BEGIN - RAISERROR ('Did not find database [$(DatabaseName)]', 16, 1) -END -ELSE -BEGIN - PRINT 'Found database [$(DatabaseName)]' -END -'@ - - SetSqlQuery = @' -CREATE DATABASE [$(DatabaseName)] -'@ - } - ) -} - -Configuration Example -{ - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName 'PSDscResources' - Import-DscResource -ModuleName 'SqlServerDsc' - - node localhost { - - SqlScriptQuery 'Integration_Test' - { - ServerInstance = Join-Path -Path $Node.ServerName -ChildPath $Node.InstanceName - - GetQuery = $Node.GetSqlQuery - TestQuery = $Node.TestSqlQuery - SetQuery = $Node.SetSqlQuery - Variable = @( - ('DatabaseName={0}' -f $Node.DatabaseName) - ) - QueryTimeout = 30 - - PsDscRunAsCredential = $SqlAdministratorCredential - } - } -} diff --git a/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 b/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 deleted file mode 100644 index c6bd8677b..000000000 --- a/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.EXAMPLE - This example shows how to configure two SQL Server instances on the same server to have CLR enabled. -.NOTES - To get all available options run sp_configure on the SQL Server instance, or refer to https://msdn.microsoft.com/en-us/library/ms189631.aspx -#> - -$configurationData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - SQLInstances = @('CONTENT', 'DIST') - OptionName = 'clr enabled' - } - ) -} - -Configuration Example -{ - Import-DscResource -ModuleName SqlServerDsc - - node localhost - { - foreach ($SQLInstance in $node.SQLInstances) - { - SqlServerConfiguration ('SQLConfigCLR_{0}' -f $SQLInstance) - { - Servername = $node.NodeName - InstanceName = $SQLInstance - OptionName = $node.OptionName - OptionValue = 1 - } - } - } -} diff --git a/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 b/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 deleted file mode 100644 index d3adc05f3..000000000 --- a/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# -.EXAMPLE - This example shows how to configure two SQL Server instances on the same server to have the setting 'priority boost' enabled. -.NOTES - To get all available options run sp_configure on the SQL Server instance, or refer to https://msdn.microsoft.com/en-us/library/ms189631.aspx -#> - -Configuration Example -{ - Import-DscResource -ModuleName SqlServerDsc - - node localhost - { - SqlServerConfiguration 'SQLConfigPriorityBoost' - { - - ServerName = 'localhost' - InstanceName = 'MSSQLSERVER' - OptionName = 'priority boost' - OptionValue = 1 - RestartService = $false - } - } -} diff --git a/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 b/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 deleted file mode 100644 index d5fa462d4..000000000 --- a/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 +++ /dev/null @@ -1,67 +0,0 @@ -<# - .EXAMPLE - This example will enable Database Mail on a SQL Server instance and - create a mail account with a default public profile. - -#> -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - ServerName = $env:COMPUTERNAME - InstanceName = 'DSCSQLTEST' - - MailServerName = 'mail.company.local' - AccountName = 'MyMail' - ProfileName = 'MyMailProfile' - EmailAddress = 'NoReply@company.local' - Description = 'Default mail account and profile.' - LoggingLevel = 'Normal' - TcpPort = 25 - } - ) -} - -Configuration Example -{ - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.Management.Automation.PSCredential] - $SqlInstallCredential - ) - - Import-DscResource -ModuleName 'SqlServerDsc' - - node localhost { - SqlServerConfiguration 'EnableDatabaseMailXPs' - { - - ServerName = $Node.ServerName - InstanceName = $Node.InstanceName - OptionName = 'Database Mail XPs' - OptionValue = 1 - RestartService = $false - } - - SqlServerDatabaseMail 'EnableDatabaseMail' - { - Ensure = 'Present' - ServerName = $Node.ServerName - InstanceName = $Node.InstanceName - AccountName = $Node.AccountName - ProfileName = $Node.ProfileName - EmailAddress = $Node.EmailAddress - ReplyToAddress = $Node.EmailAddress - DisplayName = $Node.MailServerName - MailServerName = $Node.MailServerName - Description = $Node.Description - LoggingLevel = $Node.LoggingLevel - TcpPort = $Node.TcpPort - - PsDscRunAsCredential = $SqlInstallCredential - } - } -} - diff --git a/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 b/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 deleted file mode 100644 index acf810862..000000000 --- a/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -<# -.EXAMPLE - This example performs a standard Sql encryption setup. Forcing all connections to be encrypted. -#> -Configuration Example -{ - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlServerSecureConnection SecureConnectionAbsent - { - InstanceName = 'MSSQLSERVER' - Thumbprint = '' - Ensure = 'Absent' - ServiceAccount = 'SqlSvc' - } - } -} diff --git a/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 b/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 deleted file mode 100644 index ab4f2c70f..000000000 --- a/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -<# -.EXAMPLE - This example performs a standard Sql encryption setup using the "SYSTEM" account. - Note that the "LocalSystem" account should not be used because it returns a connection error, - even though it inherits the "SYSTEM" account's privileges. -#> -Configuration Example -{ - Import-DscResource -ModuleName SqlServerDsc - - node localhost { - SqlServerSecureConnection SecureConnectionUsingSYSTEMAccount - { - InstanceName = 'MSSQLSERVER' - Thumbprint = 'fb0b82c94b80da26cf0b86f10ec0c50ae7864a2c' - ForceEncryption = $false - Ensure = 'Present' - ServiceAccount = 'SYSTEM' - } - } -} diff --git a/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 b/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 deleted file mode 100644 index 60257b6ee..000000000 --- a/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# -.EXAMPLE - This example shows how to ensure the SQL Server service - on TestServer\DSC is running under a virtual account. - Force will cause this account to be set every time the - configuration is evaluated. Specifying RestartService will - cause the service to be restarted. -#> - -Configuration Example -{ - param( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $ServiceAccountCredential - ) - - Import-DscResource -ModuleName SqlServerDsc - - Node localhost { - SqlServiceAccount SetServiceAccount_User - { - ServerName = 'TestServer' - InstanceName = 'DSC' - ServiceType = 'DatabaseEngine' - ServiceAccount = $ServiceAccountCredential - RestartService = $true - Force = $true - } - } -} diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 000000000..e0559776f --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,26 @@ +mode: ContinuousDelivery +next-version: 13.3.0 +major-version-bump-message: '\s?(breaking|major|breaking\schange)' +minor-version-bump-message: '\s?(add|feature|minor)' +patch-version-bump-message: '\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}' +branches: + master: + tag: preview + pull-request: + tag: PR + feature: + tag: useBranchName + increment: Minor + regex: f(eature(s)?)?[/-] + source-branches: ['master'] + hotfix: + tag: fix + increment: Patch + regex: (hot)?fix(es)?[/-] + source-branches: ['master'] + +ignore: + sha: [] +merge-message-formats: {} diff --git a/HISTORIC_CHANGELOG.md b/HISTORIC_CHANGELOG.md new file mode 100644 index 000000000..c9e24b888 --- /dev/null +++ b/HISTORIC_CHANGELOG.md @@ -0,0 +1,2022 @@ +# Historic change log for SqlServerDsc + +The release notes in the PowerShell Module manifest cannot exceed 10000 +characters. Due to a bug in the CI deploy pipeline this is not handled. +This file is to temporary move the older change log history to keep the +change log short. + +## [13.2.0.0] - 2019-09-18 + +### Changed + +- Changes to SqlServerDsc + - Fix keywords to lower-case to align with guideline. + - Fix keywords to have space before a parenthesis to align with guideline. + - Fix typo in SqlSetup strings ([issue #1419](https://github.com/PowerShell/SqlServerDsc/issues/1419)). + +## [13.1.0.0] - 2019-08-07 + +### Changed + +- Changes to SqlServerDsc + - New DSC resource SqlAgentFailsafe + - New DSC resource SqlDatabaseUser ([issue #846](https://github.com/PowerShell/SqlServerDsc/issues/846)). + - Adds ability to create database users with more fine-grained control, + e.g. re-mapping of orphaned logins or a different login. Supports + creating a user with or without login name, and database users mapped + to a certificate or asymmetric key. + - Changes to helper function Invoke-Query + - Fixes issues in [issue #1355](https://github.com/PowerShell/SqlServerDsc/issues/1355). + - Works together with Connect-SQL now. + - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). + - Can now pass in credentials. + - Can now pass in 'Microsoft.SqlServer.Management.Smo.Server' object. + - Can also pipe in 'Microsoft.SqlServer.Management.Smo.Server' object. + - Can pipe Connect-SQL | Invoke-Query. + - Added default values to Invoke-Query. + - Now it will output verbose messages of the query that is run, so it + not as quiet of what it is doing when a user asks for verbose output + ([issue #1404](https://github.com/PowerShell/SqlServerDsc/issues/1404)). + - It is possible to redact text in the verbose output by providing + strings in the new parameter `RedactText`. + - Minor style fixes in unit tests. + - Changes to helper function Connect-SQL + - When impersonating WindowsUser credential use the NetworkCredential UserName. + - Added additional verbose logging. + - Connect-SQL now uses parameter sets to more intuitive evaluate that + the correct parameters are used in different scenarios + ([issue #1403](https://github.com/PowerShell/SqlServerDsc/issues/1403)). + - Changes to helper function Connect-SQLAnalysis + - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). + - Changes to helper function Restart-SqlService + - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). + - Changes to helper function Restart-ReportingServicesService + - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). + - Changes to helper function Split-FullSqlInstanceName + - Parameters and function name changed to use correct casing. + - Changes to helper function Get-SqlInstanceMajorVersion + - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). + - Changes to helper function Test-LoginEffectivePermissions + - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). + - Changes to helper function Test-AvailabilityReplicaSeedingModeAutomatic + - Parameters now match that of Connect-SQL ([issue #1392](https://github.com/PowerShell/SqlServerDsc/issues/1392)). +- Changes to SqlServerSecureConnection + - Forced $Thumbprint to lowercase to fix [issue #1350](https://github.com/PowerShell/SqlServerDsc/issues/1350). + - Add parameter SuppressRestart with default value false. + This allows users to suppress restarts after changes have been made. + Changes will not take effect until the service has been restarted. +- Changes to SqlSetup + - Correct minor style violation [issue #1387](https://github.com/PowerShell/SqlServerDsc/issues/1387). +- Changes to SqlDatabase + - Get-TargetResource now correctly return `$null` for the collation property + when the database does not exist ([issue #1395](https://github.com/PowerShell/SqlServerDsc/issues/1395)). + - No longer enforces the collation property if the Collation parameter + is not part of the configuration ([issue #1396](https://github.com/PowerShell/SqlServerDsc/issues/1396)). + - Updated resource description in README.md + - Fix examples to use `PsDscRunAsCredential` ([issue #760](https://github.com/PowerShell/SqlServerDsc/issues/760)). + - Added integration tests ([issue #739](https://github.com/PowerShell/SqlServerDsc/issues/739)). + - Updated unit tests to the latest template ([issue #1068](https://github.com/PowerShell/SqlServerDsc/issues/1068)). + +## [13.0.0.0] - 2019-06-26 + +### Changed + +- Changes to SqlServerDsc + - Added SqlAgentAlert resource. + - Opt-in to the common test 'Common Test - Validation Localization'. + - Opt-in to the common test 'Common Test - Flagged Script Analyzer Rules' + ([issue #1101](https://github.com/PowerShell/SqlServerDsc/issues/1101)). + - Removed the helper function `New-TerminatingError`, `New-WarningMessage` + and `New-VerboseMessage` in favor of the the new + [localization helper functions](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#localization). + - Combine DscResource.LocalizationHelper and DscResource.Common into + SqlServerDsc.Common ([issue #1357](https://github.com/PowerShell/SqlServerDsc/issues/1357)). + - Update Assert-TestEnvironment.ps1 to not error if strict mode is enabled + and there are no missing dependencies ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). +- Changes to SqlServerDsc.Common + - Added StatementTimeout to function 'Connect-SQL' with default 600 seconds (10mins). + - Added StatementTimeout to function 'Invoke-Query' with default 600 seconds (10mins) + ([issue #1358](https://github.com/PowerShell/SqlServerDsc/issues/1358)). + - Changes to helper function Connect-SQL + - The function now make it more clear that when using the parameter + `SetupCredential` is impersonates that user, and by default it does + not impersonates a user but uses the credential that the resource + is run as (for example the built-in credential parameter + `PsDscRunAsCredential`). [@kungfu71186](https://github.com/kungfu71186) + - Added parameter alias `-DatabaseCredential` for the parameter + `-SetupCredential`. [@kungfu71186](https://github.com/kungfu71186) +- Changes to SqlAG + - Added en-US localization. +- Changes to SqlAGReplica + - Added en-US localization. + - Improved verbose message output when creating availability group replica, + removing a availability group replica, and joining the availability + group replica to the availability group. +- Changes to SqlAlwaysOnService + - Now outputs the correct verbose message when restarting the service. +- Changes to SqlServerMemory + - Now outputs the correct verbose messages when calculating the dynamic + memory, and when limiting maximum memory. +- Changes to SqlServerRole + - Now outputs the correct verbose message when the members of a role is + not in desired state. +- Changes to SqlAgentOperator + - Fix minor issue that when unable to connect to an instance. Instead + of showing a message saying that connect failed another unrelated + error message could have been shown, because of an error in the code. + - Fix typo in test it block. +- Changes to SqlDatabaseRole + - BREAKING CHANGE: Refactored to enable creation/deletion of the database role + itself as well as management of the role members. *Note that the resource no + longer adds database users.* ([issue #845](https://github.com/PowerShell/SqlServerDsc/issues/845), + [issue #847](https://github.com/PowerShell/SqlServerDsc/issues/847), + [issue #1252](https://github.com/PowerShell/SqlServerDsc/issues/1252), + [issue #1339](https://github.com/PowerShell/SqlServerDsc/issues/1339)). + [Paul Shamus @pshamus](https://github.com/pshamus) +- Changes to SqlSetup + - Add an Action type of 'Upgrade'. This will ask setup to do a version + upgrade where possible ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). + - Fix an error when testing for DQS installation ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). + - Changed the logic of how default value of FailoverClusterGroupName is + set since that was preventing the resource to be able to be debugged + ([issue #448](https://github.com/PowerShell/SqlServerDsc/issues/448)). + - Added RSInstallMode parameter ([issue #1163](https://github.com/PowerShell/SqlServerDsc/issues/1163)). +- Changes to SqlWindowsFirewall + - Where a version upgrade has changed paths for a database engine, the + existing firewall rule for that instance will be updated rather than + another one created ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). + Other firewall rules can be fixed to work in the same way later. +- Changes to SqlAGDatabase + - Added new parameter 'ReplaceExisting' with default false. + This allows forced restores when a database already exists on secondary. + - Added StatementTimeout to Invoke-Query to fix Issue#1358 + - Fix issue where calling Get would return an error because the database + name list may have been returned as a string instead of as a string array + ([issue #1368](https://github.com/PowerShell/SqlServerDsc/issues/1368)). + +## [12.5.0.0] - 2019-05-15 + +### Changed + +- Changes to SqlServerSecureConnection + - Updated README and added example for SqlServerSecureConnection, + instructing users to use the 'SYSTEM' service account instead of + 'LocalSystem'. +- Changes to SqlScript + - Correctly passes the `$VerbosePreference` to the helper function + `Invoke-SqlScript` so that `PRINT` statements is outputted correctly + when verbose output is requested, e.g + `Start-DscConfiguration -Verbose`. + - Added en-US localization ([issue #624](https://github.com/PowerShell/SqlServerDsc/issues/624)). + - Added additional unit tests for code coverage. +- Changes to SqlScriptQuery + - Correctly passes the `$VerbosePreference` to the helper function + `Invoke-SqlScript` so that `PRINT` statements is outputted correctly + when verbose output is requested, e.g + `Start-DscConfiguration -Verbose`. + - Added en-US localization. + - Added additional unit tests for code coverage. +- Changes to SqlSetup + - Concatenated Robocopy localization strings ([issue #694](https://github.com/PowerShell/SqlServerDsc/issues/694)). + - Made the error message more descriptive when the Set-TargetResource + function calls the Test-TargetResource function to verify the desired + state. +- Changes to SqlWaitForAG + - Added en-US localization ([issue #625](https://github.com/PowerShell/SqlServerDsc/issues/625)). +- Changes to SqlServerPermission + - Added en-US localization ([issue #619](https://github.com/PowerShell/SqlServerDsc/issues/619)). +- Changes to SqlServerMemory + - Added en-US localization ([issue #617](https://github.com/PowerShell/SqlServerDsc/issues/617)). + - No longer will the resource set the MinMemory value if it was provided + in a configuration that also set the `Ensure` parameter to 'Absent' + ([issue #1329](https://github.com/PowerShell/SqlServerDsc/issues/1329)). + - Refactored unit tests to simplify them add add slightly more code + coverage. +- Changes to SqlServerMaxDop + - Added en-US localization ([issue #616](https://github.com/PowerShell/SqlServerDsc/issues/616)). +- Changes to SqlRS + - Reporting Services are restarted after changing settings, unless + `$SuppressRestart` parameter is set ([issue #1331](https://github.com/PowerShell/SqlServerDsc/issues/1331)). + `$SuppressRestart` will also prevent Reporting Services restart after initialization. + - Fixed one of the error handling to use localization, and made the + error message more descriptive when the Set-TargetResource function + calls the Test-TargetResource function to verify the desired + state. *This was done prior to adding full en-US localization.* + - Fixed ([issue #1258](https://github.com/PowerShell/SqlServerDsc/issues/1258)). + When initializing Reporting Services, there is no need to execute `InitializeReportServer` + CIM method, since executing `SetDatabaseConnection` CIM method initializes + Reporting Services. + - [issue #864](https://github.com/PowerShell/SqlServerDsc/issues/864) SqlRs + can now initialise SSRS 2017 instances +- Changes to SqlServerLogin + - Added en-US localization ([issue #615](https://github.com/PowerShell/SqlServerDsc/issues/615)). + - Added unit tests to improved code coverage. +- Changes to SqlWindowsFirewall + - Added en-US localization ([issue #614](https://github.com/PowerShell/SqlServerDsc/issues/614)). +- Changes to SqlServerEndpoint + - Added en-US localization ([issue #611](https://github.com/PowerShell/SqlServerDsc/issues/611)). +- Changes to SqlServerEndpointPermission + - Added en-US localization ([issue #612](https://github.com/PowerShell/SqlServerDsc/issues/612)). +- Changes to SqlServerEndpointState + - Added en-US localization ([issue #613](https://github.com/PowerShell/SqlServerDsc/issues/613)). +- Changes to SqlDatabaseRole + - Added en-US localization ([issue #610](https://github.com/PowerShell/SqlServerDsc/issues/610)). +- Changes to SqlDatabaseRecoveryModel + - Added en-US localization ([issue #609](https://github.com/PowerShell/SqlServerDsc/issues/609)). +- Changes to SqlDatabasePermission + - Added en-US localization ([issue #608](https://github.com/PowerShell/SqlServerDsc/issues/608)). +- Changes to SqlDatabaseOwner + - Added en-US localization ([issue #607](https://github.com/PowerShell/SqlServerDsc/issues/607)). +- Changes to SqlDatabase + - Added en-US localization ([issue #606](https://github.com/PowerShell/SqlServerDsc/issues/606)). +- Changes to SqlAGListener + - Added en-US localization ([issue #604](https://github.com/PowerShell/SqlServerDsc/issues/604)). +- Changes to SqlAlwaysOnService + - Added en-US localization ([issue #603](https://github.com/PowerShell/SqlServerDsc/issues/608)). +- Changes to SqlAlias + - Added en-US localization ([issue #602](https://github.com/PowerShell/SqlServerDsc/issues/602)). + - Removed ShouldProcess for the code, since it has no purpose in a DSC + resource ([issue #242](https://github.com/PowerShell/SqlServerDsc/issues/242)). +- Changes to SqlServerReplication + - Added en-US localization ([issue #620](https://github.com/PowerShell/SqlServerDsc/issues/620)). + - Refactored Get-TargetResource slightly so it provide better verbose + messages. + +## [12.4.0.0] - 2019-04-03 + +### Changed + +- Changes to SqlServerDsc + - Added new resources. + - SqlRSSetup + - Added helper module DscResource.Common from the repository + DscResource.Template. + - Moved all helper functions from SqlServerDscHelper.psm1 to DscResource.Common. + - Renamed Test-SqlDscParameterState to Test-DscParameterState. + - New-TerminatingError error text for a missing localized message now matches + the output even if the "missing localized message" localized message is + also missing. + - Added helper module DscResource.LocalizationHelper from the repository + DscResource.Template, this replaces the helper module CommonResourceHelper.psm1. + - Cleaned up unit tests, mostly around loading cmdlet stubs and loading + classes stubs, but also some tests that were using some odd variants. + - Fix all integration tests according to issue [PowerShell/DscResource.Template#14](https://github.com/PowerShell/DscResource.Template/issues/14). +- Changes to SqlServerMemory + - Updated Cim Class to Win32_ComputerSystem (instead of Win32_PhysicalMemory) + because the correct memory size was not being detected correctly on Azure VMs + ([issue #914](https://github.com/PowerShell/SqlServerDsc/issues/914)). +- Changes to SqlSetup + - Split integration tests into two jobs, one for running integration tests + for SQL Server 2016 and another for running integration test for + SQL Server 2017 ([issue #858](https://github.com/PowerShell/SqlServerDsc/issues/858)). + - Localized messages for Master Data Services no longer start and end with + single quote. + - When installing features a verbose message is written if a feature is found + to already be installed. It no longer quietly removes the feature from the + `/FEATURES` argument. + - Cleaned up a bit in the tests, removed excessive piping. + - Fixed minor typo in examples. + - A new optional parameter `FeatureFlag` parameter was added to control + breaking changes. Functionality added under a feature flag can be + toggled on or off, and could be changed later to be the default. + This way we can also make more of the new functionalities the default + in the same breaking change release ([issue #1105](https://github.com/PowerShell/SqlServerDsc/issues/1105)). + - Added a new way of detecting if the shared feature CONN (Client Tools + Connectivity, and SQL Client Connectivity SDK), BC (Client Tools + Backwards Compatibility), and SDK (Client Tools SDK) is installed or + not. The new functionality is used when the parameter `FeatureFlag` + is set to `'DetectionSharedFeatures'` ([issue #1105](https://github.com/PowerShell/SqlServerDsc/issues/1105)). + - Added a new helper function `Get-InstalledSharedFeatures` to move out + some of the code from the `Get-TargetResource` to make unit testing + easier and faster. + - Changed the logic of 'Build the argument string to be passed to setup' to + not quote the value if root directory is specified + ([issue #1254](https://github.com/PowerShell/SqlServerDsc/issues/1254)). + - Moved some resource specific helper functions to the new helper module + DscResource.Common so they can be shared with the new resource SqlRSSetup. + - Improved verbose messages in Test-TargetResource function to more + clearly tell if features are already installed or not. + - Refactored unit tests for the functions Test-TargetResource and + Set-TargetResource to improve testing speed. + - Modified the Test-TargetResource and Set-TargetResource to not be + case-sensitive when comparing feature names. *This was handled + correctly in real-world scenarios, but failed when running the unit + tests (and testing casing).* +- Changes to SqlAGDatabase + - Fix MatchDatabaseOwner to check for CONTROL SERVER, IMPERSONATE LOGIN, or + CONTROL LOGIN permission in addition to IMPERSONATE ANY LOGIN. + - Update and fix MatchDatabaseOwner help text. +- Changes to SqlAG + - Updated documentation on the behaviour of defaults as they only apply when + creating a group. +- Changes to SqlAGReplica + - AvailabilityMode, BackupPriority, and FailoverMode defaults only apply when + creating a replica not when making changes to an existing replica. Explicit + parameters will still change existing replicas ([issue #1244](https://github.com/PowerShell/SqlServerDsc/issues/1244)). + - ReadOnlyRoutingList now gets updated without throwing an error on the first + run ([issue #518](https://github.com/PowerShell/SqlServerDsc/issues/518)). + - Test-Resource fixed to report whether ReadOnlyRoutingList desired state + has been reached correctly ([issue #1305](https://github.com/PowerShell/SqlServerDsc/issues/1305)). +- Changes to SqlDatabaseDefaultLocation + - No longer does the Test-TargetResource fail on the second test run + when the backup file path was changed, and the path was ending with + a backslash ([issue #1307](https://github.com/PowerShell/SqlServerDsc/issues/1307)). + +## [12.3.0.0] - 2019-02-20 + +### Changed + +- Changes to SqlServerDsc + - Reverting the change that was made as part of the + [issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260) + in the previous release, as it only mitigated the issue, it did not + solve the issue. + - Removed the container testing since that broke the integration tests, + possible due to using excessive amount of memory on the AppVeyor build + worker. This will make the unit tests to take a bit longer to run + ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). + - The unit tests and the integration tests are now run in two separate + build workers in AppVeyor. One build worker runs the integration tests, + while a second build worker runs the unit tests. The build workers runs + in parallel on paid accounts, but sequentially on free accounts + ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). + - Clean up error handling in some of the integration tests that was + part of a workaround for a bug in Pester. The bug is resolved, and + the error handling is not again built into Pester. + - Speeding up the AppVeyor tests by splitting the common tests in a + separate build job. + - Updated the appveyor.yml to have the correct build step, and also + correct run the build step only in one of the jobs. + - Update integration tests to use the new integration test template. + - Added SqlAgentOperator resource. +- Changes to SqlServiceAccount + - Fixed Get-ServiceObject when searching for Integration Services service. + Unlike the rest of SQL Server services, the Integration Services service + cannot be instanced, however you can have multiple versions installed. + Get-Service object would return the correct service name that you + are looking for, but it appends the version number at the end. Added + parameter VersionNumber so the search would return the correct + service name. + - Added code to allow for using Managed Service Accounts. + - Now the correct service type string value is returned by the function + `Get-TargetResource`. Previously one value was passed in as a parameter + (e.g. `DatabaseEngine`), but a different string value as returned + (e.g. `SqlServer`). Now `Get-TargetResource` return the same values + that can be passed as values in the parameter `ServiceType` + ([issue #981](https://github.com/PowerShell/SqlServerDsc/issues/981)). +- Changes to SqlServerLogin + - Fixed issue in Test-TargetResource to valid password on disabled accounts + ([issue #915](https://github.com/PowerShell/SqlServerDsc/issues/915)). + - Now when adding a login of type SqlLogin, and the SQL Server login mode + is set to `'Integrated'`, an error is correctly thrown + ([issue #1179](https://github.com/PowerShell/SqlServerDsc/issues/1179)). +- Changes to SqlSetup + - Updated the integration test to stop the named instance while installing + the other instances to mitigate + [issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260). + - Add parameters to configure the Tempdb files during the installation of + the instance. The new parameters are SqlTempdbFileCount, SqlTempdbFileSize, + SqlTempdbFileGrowth, SqlTempdbLogFileSize and SqlTempdbLogFileGrowth + ([issue #1167](https://github.com/PowerShell/SqlServerDsc/issues/1167)). +- Changes to SqlServerEndpoint + - Add the optional parameter Owner. The default owner remains the login used + for the creation of the endpoint + ([issue #1251](https://github.com/PowerShell/SqlServerDsc/issues/1251)). + [Maxime Daniou (@mdaniou)](https://github.com/mdaniou) + - Add integration tests + ([issue #744](https://github.com/PowerShell/SqlServerDsc/issues/744)). + [Maxime Daniou (@mdaniou)](https://github.com/mdaniou) + +## [12.2.0.0] - 2019-01-09 + +### Changed + +- Changes to SqlServerDsc + - During testing in AppVeyor the Build Worker is restarted in the install + step to make sure the are no residual changes left from a previous SQL + Server install on the Build Worker done by the AppVeyor Team + ([issue #1260](https://github.com/PowerShell/SqlServerDsc/issues/1260)). + - Code cleanup: Change parameter names of Connect-SQL to align with resources. + - Updated README.md in the Examples folder. + - Added a link to the new xADObjectPermissionEntry examples in + ActiveDirectory, fixed a broken link and a typo. + [Adam Rush (@adamrushuk)](https://github.com/adamrushuk) +- Change to SqlServerLogin so it doesn't check properties for absent logins. + - Fix for ([issue #1096](https://github.com/PowerShell/SqlServerDsc/issues/1096)) + +## [12.1.0.0] - 2018-10-24 + +### Changed + +- Changes to SqlServerDsc + - Add support for validating the code with the DSC ResourceKit + Script Analyzer rules, both in Visual Studio Code and directly using + `Invoke-ScriptAnalyzer`. + - Opt-in for common test "Common Tests - Validate Markdown Links". + - Updated broken links in `\README.md` and in `\Examples\README.md` + - Opt-in for common test 'Common Tests - Relative Path Length'. + - Updated the Installation section in the README.md. + - Updated the Contributing section in the README.md after + [Style Guideline and Best Practices guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) + has merged into one document. + - To speed up testing in AppVeyor, unit tests are now run in two containers. + - Adding the PowerShell script `Assert-TestEnvironment.ps1` which + must be run prior to running any unit tests locally with + `Invoke-Pester`. + Read more in the specific contributing guidelines, under the section + [Unit Tests](https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md#unit-tests). +- Changes to SqlServerDscHelper + - Fix style guideline lint errors. + - Changes to Connect-SQL + - Adding verbose message in Connect-SQL so it + now shows the username that is connecting. + - Changes to Import-SQLPS + - Fixed so that when importing SQLPS it imports + using the path (and not the .psd1 file). + - Fixed so that the verbose message correctly + shows the name, version and path when importing + the module SQLPS (it did show correctly for the + SqlServer module). +- Changes to SqlAg, SqlAGDatabase, and SqlAGReplica examples + - Included configuration for SqlAlwaysOnService to enable + HADR on each node to avoid confusion + ([issue #1182](https://github.com/PowerShell/SqlServerDsc/issues/1182)). +- Changes to SqlServerDatabaseMail + - Minor update to Ensure parameter description in the README.md. +- Changes to Write-ModuleStubFile.ps1 + - Create aliases for cmdlets in the stubbed module which have aliases + ([issue #1224](https://github.com/PowerShell/SqlServerDsc/issues/1224)). + [Dan Reist (@randomnote1)](https://github.com/randomnote1) + - Use a string builder to build the function stubs. + - Fixed formatting issues for the function to work with modules other + than SqlServer. +- New DSC resource SqlServerSecureConnection + - New resource to configure a SQL Server instance for encrypted SQL + connections. +- Changes to SqlAlwaysOnService + - Updated integration tests to use NetworkingDsc + ([issue #1129](https://github.com/PowerShell/SqlServerDsc/issues/1129)). +- Changes to SqlServiceAccount + - Fix unit tests that didn't mock some of the calls. It no longer fail + when a SQL Server installation is not present on the node running the + unit test ([issue #983](https://github.com/PowerShell/SqlServerDsc/issues/983)). + +## [12.0.0.0] - 2018-09-05 + +### Changed + +- Changes to SqlServerDatabaseMail + - DisplayName is now properly treated as display name + for the originating email address ([issue #1200](https://github.com/PowerShell/SqlServerDsc/issue/1200)). + [Nick Reilingh (@NReilingh)](https://github.com/NReilingh) + - DisplayName property now defaults to email address instead of server name. + - Minor improvements to documentation. +- Changes to SqlAGDatabase + - Corrected reference to "PsDscRunAsAccount" in documentation + ([issue #1199](https://github.com/PowerShell/SqlServerDsc/issues/1199)). + [Nick Reilingh (@NReilingh)](https://github.com/NReilingh) +- Changes to SqlDatabaseOwner + - BREAKING CHANGE: Support multiple instances on the same node. + The parameter InstanceName is now Key and cannot be omitted + ([issue #1197](https://github.com/PowerShell/SqlServerDsc/issues/1197)). +- Changes to SqlSetup + - Added new parameters to allow to define the startup types for the Sql Engine + service, the Agent service, the Analysis service and the Integration Service. + The new optional parameters are respectively SqlSvcStartupType, AgtSvcStartupType, + AsSvcStartupType, IsSvcStartupType and RsSvcStartupType ([issue #1165](https://github.com/PowerShell/SqlServerDsc/issues/1165). + [Maxime Daniou (@mdaniou)](https://github.com/mdaniou) + +## [11.4.0.0] - 2018-07-25 + +### Changed + +- Changes to SqlServerDsc + - Updated helper function Restart-SqlService to have to new optional parameters + `SkipClusterCheck` and `SkipWaitForOnline`. This was to support more aspects + of the resource SqlServerNetwork. + - Updated helper function `Import-SQLPSModule` + - To only import module if the + module does not exist in the session. + - To always import the latest version of 'SqlServer' or 'SQLPS' module, if + more than one version exist on the target node. It will still prefer to + use 'SqlServer' module. + - Updated all the examples and integration tests to not use + `PSDscAllowPlainTextPassword`, so examples using credentials or + passwords by default are secure. +- Changes to SqlAlwaysOnService + - Integration tests was updated to handle new IPv6 addresses on the AppVeyor + build worker ([issue #1155](https://github.com/PowerShell/SqlServerDsc/issues/1155)). +- Changes to SqlServerNetwork + - Refactor SqlServerNetwork to not load assembly from GAC ([issue #1151](https://github.com/PowerShell/SqlServerDsc/issues/1151)). + - The resource now supports restarting the SQL Server service when both + enabling and disabling the protocol. + - Added integration tests for this resource + ([issue #751](https://github.com/PowerShell/SqlServerDsc/issues/751)). +- Changes to SqlAG + - Removed excess `Import-SQLPSModule` call. +- Changes to SqlSetup + - Now after a successful install the "SQL PowerShell module" is reevaluated and + forced to be reimported into the session. This is to support that a never + version of SQL Server was installed side-by-side so that SQLPS module should + be used instead. + +## [11.3.0.0] - 2018-06-13 + +### Changed + +- Changes to SqlServerDsc + - Moved decoration for integration test to resolve a breaking change in + DscResource.Tests. + - Activated the GitHub App Stale on the GitHub repository. + - Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md + [issue #939](https://github.com/PowerShell/SqlServerDsc/issues/939). + - New resources: + - Added SqlScriptQueryResource. [Chase Wilson (@chasewilson)](https://github.com/chasewilson) + - Fix for issue #779 [Paul Kelly (@prkelly)](https://github.com/prkelly) + +## [11.2.0.0] - 2018-05-02 + +- Changes to SqlServerDsc + - Added new test helper functions in the CommonTestHelpers module. These are used + by the integration tests. + - **New-IntegrationLoopbackAdapter:** Installs the PowerShell module + 'LoopbackAdapter' from PowerShell Gallery and creates a new network + loopback adapter. + - **Remove-IntegrationLoopbackAdapter:** Removes a new network loopback adapter. + - **Get-NetIPAddressNetwork:** Returns the IP network address from an IPv4 address + and prefix length. + - Enabled PSSA rule violations to fail build in the CI environment. + - Renamed SqlServerDsc.psd1 to be consistent + ([issue #1116](https://github.com/PowerShell/SqlServerDsc/issues/1116)). + [Glenn Sarti (@glennsarti)](https://github.com/glennsarti) +- Changes to Unit Tests + - Updated + the following resources unit test template to version 1.2.1 + - SqlWaitForAG ([issue #1088](https://github.com/PowerShell/SqlServerDsc/issues/1088)). + [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode) +- Changes to SqlAlwaysOnService + - Updated the integration tests to use a loopback adapter to be less intrusive + in the build worker environment. + - Minor code cleanup in integration test, fixed the scope on variable. +- Changes to SqlSetup + - Updated the integration tests to stop some services after each integration test. + This is to save memory on the AppVeyor build worker. + - Updated the integration tests to use a SQL Server 2016 Service Pack 1. + - Fixed Script Analyzer rule error. +- Changes to SqlRS + - Updated the integration tests to stop the Reporting Services service after + the integration test. This is to save memory on the AppVeyor build worker. + - The helper function `Restart-ReportingServicesService` should no longer timeout + when restarting the service ([issue #1114](https://github.com/PowerShell/SqlServerDsc/issues/1114)). +- Changes to SqlServiceAccount + - Updated the integration tests to stop some services after each integration test. + This is to save memory on the AppVeyor build worker. +- Changes to SqlServerDatabaseMail + - Fixed Script Analyzer rule error. + +## [11.1.0.0] - 2018-03-21 + +### Changed + +- Changes to SqlServerDsc + - Updated the PULL\_REQUEST\_TEMPLATE with an improved task list and modified + some text to be clearer ([issue #973](https://github.com/PowerShell/SqlServerDsc/issues/973)). + - Updated the ISSUE_TEMPLATE to hopefully be more intuitive and easier to use. + - Added information to ISSUE_TEMPLATE that issues must be reproducible in + SqlServerDsc resource module (if running the older xSQLServer resource module) + ([issue #1036](https://github.com/PowerShell/SqlServerDsc/issues/1036)). + - Updated ISSUE_TEMPLATE.md with a note about sensitive information ([issue #1092](https://github.com/PowerShell/SqlServerDsc/issues/1092)). +- Changes to SqlServerLogin + - [Claudio Spizzi (@claudiospizzi)](https://github.com/claudiospizzi): Fix password + test fails for nativ sql users ([issue #1048](https://github.com/PowerShell/SqlServerDsc/issues/1048)). +- Changes to SqlSetup + - [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode): Clarify usage + of 'SecurityMode' along with adding parameter validations for the only 2 + supported values ([issue #1010](https://github.com/PowerShell/SqlServerDsc/issues/1010)). + - Now accounts containing '$' will be able to be used for installing + SQL Server. Although, if the account ends with '$' it is considered a + Managed Service Account ([issue #1055](https://github.com/PowerShell/SqlServerDsc/issues/1055)). +- Changes to Integration Tests + - [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode): Replace xStorage + dsc resource module with StorageDsc ([issue #1038](https://github.com/PowerShell/SqlServerDsc/issues/1038)). +- Changes to Unit Tests + - [Michael Fyffe (@TraGicCode)](https://github.com/TraGicCode): Updated + the following resources unit test template to version 1.2.1 + - SqlAlias ([issue #999](https://github.com/PowerShell/SqlServerDsc/issues/999)). + - SqlWindowsFirewall ([issue #1089](https://github.com/PowerShell/SqlServerDsc/issues/1089)). + +## [11.0.0.0] - 2018-02-07 + +### Changed + +- Changes to SqlServerDsc + - BREAKING CHANGE: Resource SqlRSSecureConnectionLevel was remove + ([issue #990](https://github.com/PowerShell/SqlServerDsc/issues/990)). + The parameter that was set using that resource has been merged into resource + SqlRS as the parameter UseSsl. The UseSsl parameter is of type boolean. This + change was made because from SQL Server 2008 R2 this value is made an on/off + switch. Read more in the article [ConfigurationSetting Method - SetSecureConnectionLevel](https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/configurationsetting-method-setsecureconnectionlevel). + - Updated so that named parameters are used for New-Object cmdlet. This was + done to follow the style guideline. + - Updated manifest and license to reflect the new year + ([issue #965](https://github.com/PowerShell/SqlServerDsc/issues/965)). + - Added a README.md under Tests\Integration to help contributors to write + integration tests. + - Added 'Integration tests' section in the CONTRIBUTING.md. + - The complete examples were removed. They were no longer accurate and some + referenced resources that no longer exist. Accurate examples can be found + in each specific resource example folder. Examples for installing Failover Cluster + can be found in the resource examples folders in the xFailOverCluster + resource module ([issue #462](https://github.com/PowerShell/SqlServerDsc/issues/462)). + - A README.md was created under the Examples folder to be used as reference how + to install certain scenarios ([issue #462](https://github.com/PowerShell/SqlServerDsc/issues/462)). + - Removed the local specific common test for compiling examples in this repository + and instead opted-in for the common test in the 'DscResource.Tests' repository + ([issue #669](https://github.com/PowerShell/SqlServerDsc/issues/669)). + - Added new resource SqlServerDatabaseMail for configuring SQL Server + Database Mail ([issue #155](https://github.com/PowerShell/SqlServerDsc/issues/155)). + - Updated the helper function Test-SQLDscParameterState to handle the + data type UInt16. + - Fixed typo in SqlServerDscCommon.Tests. + - Updated README.md with known issue section for each resource. + - Resources that did not have a description in the README.md now has one. + - Resources that missed links to the examples in the README.md now has those + links. + - Style changes in all examples, removing type [System.Management.Automation.Credential()] + from credential parameters ([issue #1003](https://github.com/PowerShell/SqlServerDsc/issues/1003)), + and renamed the credential parameter so it is not using abbreviation. + - Updated the security token for AppVeyor status badge in README.md. When we + renamed the repository the security token was changed + ([issue #1012](https://github.com/PowerShell/SqlServerDsc/issues/1012)). + - Now the helper function Restart-SqlService, after restarting the SQL Server + service, does not return until it can connect to the SQL Server instance, and + the instance returns status 'Online' ([issue #1008](https://github.com/PowerShell/SqlServerDsc/issues/1008)). + If it fails to connect within the timeout period (defaults to 120 seconds) it + throws an error. + - Fixed typo in comment-base help for helper function Test-AvailabilityReplicaSeedingModeAutomatic. + - Style cleanup in helper functions and tests. +- Changes to SqlAG + - Fixed typos in tests. + - Style cleanup in code and tests. +- Changes to SqlAGDatabase + - Style cleanup in code and tests. +- Changes to SqlAGListener + - Fixed typo in comment-based help. + - Style cleanup in code and tests. +- Changes to SqlAGReplica + - Minor code style cleanup. Removed unused variable and instead piped the cmdlet + Join-SqlAvailabilityGroup to Out-Null. + - Fixed minor typos in comment-based help. + - Fixed minor typos in comment. + - Style cleanup in code and tests. + - Updated description for parameter Name in README.md and in comment-based help + ([issue #1034](https://github.com/PowerShell/SqlServerDsc/issues/1034)). +- Changes to SqlAlias + - Fixed issue where exception was thrown if reg keys did not exist + ([issue #949](https://github.com/PowerShell/SqlServerDsc/issues/949)). + - Style cleanup in tests. +- Changes to SqlAlwaysOnService + - Refactor integration tests slightly to improve run time performance + ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). + - Style cleanup in code and tests. +- Changes to SqlDatabase + - Fix minor Script Analyzer warning. +- Changes to SqlDatabaseDefaultLocation + - Refactor integration tests slightly to improve run time performance + ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). + - Minor style cleanup of code in tests. +- Changes to SqlDatabaseRole + - Style cleanup in tests. +- Changes to SqlRS + - Replaced Get-WmiObject with Get-CimInstance to fix Script Analyzer warnings + ([issue #264](https://github.com/PowerShell/SqlServerDsc/issues/264)). + - Refactored the resource to use Invoke-CimMethod. + - Added parameter UseSsl which when set to $true forces connections to the + Reporting Services to use SSL when connecting ([issue #990](https://github.com/PowerShell/SqlServerDsc/issues/990)). + - Added complete example for SqlRS (based on the integration tests) + ([issue #634](https://github.com/PowerShell/SqlServerDsc/issues/634)). + - Refactor integration tests slightly to improve run time performance + ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). + - Style cleanup in code and tests. +- Changes to SqlScript + - Style cleanup in tests. + - Updated examples. + - Added integration tests. + - Fixed minor typos in comment-based help. + - Added new example based on integration test. +- Changes to SqlServerConfiguration + - Fixed minor typos in comment-based help. + - Now the verbose message say what option is changing and to what value + ([issue #1014](https://github.com/PowerShell/SqlServerDsc/issues/1014)). + - Changed the RestartTimeout parameter from type SInt32 to type UInt32. + - Added localization ([issue #605](https://github.com/PowerShell/SqlServerDsc/issues/605)). + - Style cleanup in code and tests. +- Changes to SqlServerEndpoint + - Updated README.md with links to the examples + ([issue #504](https://github.com/PowerShell/SqlServerDsc/issues/504)). + - Style cleanup in tests. +- Changes to SqlServerLogin + - Added integration tests ([issue #748](https://github.com/PowerShell/SqlServerDsc/issues/748)). + - Minor code style cleanup. + - Removed unused variable and instead piped the helper function Connect-SQL to + Out-Null. + - Style cleanup in tests. +- Changes to SqlServerMaxDop + - Minor style changes in the helper function Get-SqlDscDynamicMaxDop. +- Changes to SqlServerMemory + - Style cleanup in code and tests. +- Changes to SqlServerPermission + - Fixed minor typos in comment-based help. + - Style cleanup in code. +- Changes to SqlServerReplication + - Fixed minor typos in verbose messages. + - Style cleanup in tests. +- Changes to SqlServerNetwork + - Added sysadmin account parameter usage to the examples. +- Changes to SqlServerReplication + - Fix Script Analyzer warning ([issue #263](https://github.com/PowerShell/SqlServerDsc/issues/263)). +- Changes to SqlServerRole + - Added localization ([issue #621](https://github.com/PowerShell/SqlServerDsc/issues/621)). + - Added integration tests ([issue #756](https://github.com/PowerShell/SqlServerDsc/issues/756)). + - Updated example to add two server roles in the same configuration. + - Style cleanup in tests. +- Changes to SqlServiceAccount + - Default services are now properly detected + ([issue #930](https://github.com/PowerShell/SqlServerDsc/issues/930)). + - Made the description of parameter RestartService more descriptive + ([issue #960](https://github.com/PowerShell/SqlServerDsc/issues/960)). + - Added a read-only parameter ServiceAccountName so that the service account + name is correctly returned as a string ([issue #982](https://github.com/PowerShell/SqlServerDsc/issues/982)). + - Added integration tests ([issue #980](https://github.com/PowerShell/SqlServerDsc/issues/980)). + - The timing issue that the resource returned before SQL Server service was + actually restarted has been solved by a change in the helper function + Restart-SqlService ([issue #1008](https://github.com/PowerShell/SqlServerDsc/issues/1008)). + Now Restart-SqlService waits for the instance to return status 'Online' or + throws an error saying it failed to connect within the timeout period. + - Style cleanup in code and tests. +- Changes to SqlSetup + - Added parameter `ASServerMode` to support installing Analysis Services in + Multidimensional mode, Tabular mode and PowerPivot mode + ([issue #388](https://github.com/PowerShell/SqlServerDsc/issues/388)). + - Added integration tests for testing Analysis Services Multidimensional mode + and Tabular mode. + - Cleaned up integration tests. + - Added integration tests for installing a default instance of Database Engine. + - Refactor integration tests slightly to improve run time performance + ([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)). + - Added PSSA rule 'PSUseDeclaredVarsMoreThanAssignments' override in the + function Set-TargetResource for the variable $global:DSCMachineStatus. + - Style cleanup in code and tests. +- Changes to SqlWaitForAG + - Style cleanup in code. +- Changes to SqlWindowsFirewall + - Fixed minor typos in comment-based help. + - Style cleanup in code. + +## [10.0.0.0] - 2017-12-14 + +### Changed + +- BREAKING CHANGE: Resource module has been renamed to SqlServerDsc + ([issue #916](https://github.com/PowerShell/SqlServerDsc/issues/916)). +- BREAKING CHANGE: Significant rename to reduce length of resource names + - See [issue #851](https://github.com/PowerShell/SqlServerDsc/issues/851) for a + complete table mapping rename changes. + - Impact to all resources. +- Changes to CONTRIBUTING.md + - Added details to the naming convention used in SqlServerDsc. +- Changes to SqlServerDsc + - The examples in the root of the Examples folder are obsolete. A note was + added to the comment-based help in each example stating it is obsolete. + This is a temporary measure until they are replaced + ([issue #904](https://github.com/PowerShell/SqlServerDsc/issues/904)). + - Added new common test (regression test) for validating the long path + issue for compiling resources in Azure Automation. + - Fix resources in alphabetical order in README.md ([issue #908](https://github.com/PowerShell/SqlServerDsc/issues/908)). +- Changes to SqlAG + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). + - BREAKING CHANGE: The read-only property SQLServerNetName was removed in favor + of EndpointHostName ([issue #924](https://github.com/PowerShell/SqlServerDsc/issues/924)). + Get-TargetResource will now return the value of property [NetName](https://technet.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.server.netname(v=sql.105).aspx) + for the property EndpointHostName. +- Changes to SqlAGDatabase + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). + - Changed the Get-MatchingDatabaseNames function to be case insensitive when + matching database names ([issue #912](https://github.com/PowerShell/SqlServerDsc/issues/912)). +- Changes to SqlAGListener + - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlAGReplica + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). + - BREAKING CHANGE: Parameters PrimaryReplicaSQLServer and PrimaryReplicaSQLInstanceName + has been renamed to PrimaryReplicaServerName and PrimaryReplicaInstanceName + respectively ([issue #922](https://github.com/PowerShell/SqlServerDsc/issues/922)). + - BREAKING CHANGE: The read-only property SQLServerNetName was removed in favor + of EndpointHostName ([issue #924](https://github.com/PowerShell/SqlServerDsc/issues/924)). + Get-TargetResource will now return the value of property [NetName](https://technet.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.server.netname(v=sql.105).aspx) + for the property EndpointHostName. +- Changes to SqlAlwaysOnService + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlDatabase + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes SqlDatabaseDefaultLocation + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlDatabaseOwner + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlDatabasePermission + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlDatabaseRecoveryModel + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlDatabaseRole + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlRS + - BREAKING CHANGE: Parameters RSSQLServer and RSSQLInstanceName has been renamed + to DatabaseServerName and DatabaseInstanceName respectively + ([issue #923](https://github.com/PowerShell/SqlServerDsc/issues/923)). +- Changes to SqlServerConfiguration + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerEndpoint + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerEndpointPermission + - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). + - Now the examples files have a shorter name so that resources will not fail + to compile in Azure Automation ([issue #934](https://github.com/PowerShell/SqlServerDsc/issues/934)). +- Changes to SqlServerEndpointState + - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerLogin + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerMaxDop + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerMemory + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerNetwork + - BREAKING CHANGE: Parameters SQLServer has been renamed to ServerName + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerPermission + - BREAKING CHANGE: Parameter NodeName has been renamed to ServerName + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerRole + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). +- Changes to SqlServerServiceAccount + - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed + to ServerName and InstanceName respectively + ([issue #308](https://github.com/PowerShell/SqlServerDsc/issues/308)). + +## [9.0.0.0] - 2017-11-15 + +### Changed + +- 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)). + +## [8.2.0.0] - 2017-10-05 + +### Changed + +- Changes to xSQLServer + - Updated appveyor.yml so that integration tests run in order and so that + the SQLPS module folders are renamed to not disturb the units test, but + can be renamed back by the integration tests xSQLServerSetup so that the + integration tests can run successfully + ([issue #774](https://github.com/PowerShell/xSQLServer/issues/774)). + - Changed so the maximum version to be installed is 4.0.6.0, when running unit + tests in AppVeyor. Quick fix until we can resolve the unit tests (see + [issue #807](https://github.com/PowerShell/xSQLServer/issues/807)). + - Moved the code block, that contains workarounds in appveyor.yml, so it is run + during the install phase instead of the test phase. + - Fix problem with tests breaking with Pester 4.0.7 ([issue #807](https://github.com/PowerShell/xSQLServer/issues/807)). +- Changes to xSQLServerHelper + - Changes to Connect-SQL and Import-SQLPSModule + - Now it correctly loads the correct assemblies when SqlServer module is + present ([issue #649](https://github.com/PowerShell/xSQLServer/issues/649)). + - Now SQLPS module will be correctly loaded (discovered) after installation + of SQL Server. Previously resources depending on SQLPS module could fail + because SQLPS was not found after installation because the PSModulePath + environment variable in the (LCM) PowerShell session did not contain the new + module path. + - Added new helper function "Test-ClusterPermissions" ([issue #446](https://github.com/PowerShell/xSQLServer/issues/446)). +- Changes to xSQLServerSetup + - Fixed an issue with trailing slashes in the 'UpdateSource' property + ([issue #720](https://github.com/PowerShell/xSQLServer/issues/720)). + - Fixed so that the integration test renames back the SQLPS module folders if + they was renamed by AppVeyor (in the appveyor.yml file) + ([issue #774](https://github.com/PowerShell/xSQLServer/issues/774)). + - Fixed so integration test does not write warnings when SQLPS module is loaded + ([issue #798](https://github.com/PowerShell/xSQLServer/issues/798)). + - Changes to integration tests. + - Moved the configuration block from the MSFT\_xSQLServerSetup.Integration.Tests.ps1 + to the MSFT\_xSQLServerSetup.config.ps1 to align with the other integration + test. And also get most of the configuration in one place. + - Changed the tests so that the local SqlInstall account is added as a member + of the local administrators group. + - Changed the tests so that the local SqlInstall account is added as a member + of the system administrators in SQL Server (Database Engine) - needed for the + xSQLServerAlwaysOnService integration tests. + - Changed so that only one of the Modules-folder for the SQLPS PowerShell module + for SQL Server 2016 is renamed back so it can be used with the integration + tests. There was an issue when more than one SQLPS module was present (see + more information in [issue #806](https://github.com/PowerShell/xSQLServer/issues/806)). + - Fixed wrong variable name for SQL service credential. It was using the + integration test variable name instead of the parameter name. + - Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration + ([issue #824](https://github.com/PowerShell/xSQLServer/issues/824)). +- Changes to xSQLServerAlwaysOnAvailabilityGroup + - Change the check of the values entered as parameter for + BasicAvailabilityGroup. It is a boolean, hence it was not possible to + disable the feature. + - Add possibility to enable/disable the feature DatabaseHealthTrigger + (SQL Server 2016 or later only). + - Add possibility to enable the feature DtcSupportEnabled (SQL Server 2016 or + later only). The feature currently can't be altered once the Availability + Group is created. + - Use the new helper function "Test-ClusterPermissions". + - Refactored the unit tests to allow them to be more user friendly. + - Added the following read-only properties to the schema ([issue #476](https://github.com/PowerShell/xSQLServer/issues/476)) + - EndpointPort + - EndpointURL + - SQLServerNetName + - Version + - Use the Get-PrimaryReplicaServerObject helper function. +- Changes to xSQLServerAlwaysOnAvailabilityGroupReplica + - Fixed the formatting for the AvailabilityGroupNotFound error. + - Added the following read-only properties to the schema ([issue #477](https://github.com/PowerShell/xSQLServer/issues/477)) + - EndpointPort + - EndpointURL + - Use the new helper function "Test-ClusterPermissions". + - Use the Get-PrimaryReplicaServerObject helper function +- Changes to xSQLServerHelper + - Fixed Connect-SQL by ensuring the Status property returns 'Online' prior to + returning the SQL Server object ([issue #333](https://github.com/PowerShell/xSQLServer/issues/333)). +- Changes to xSQLServerRole + - Running Get-DscConfiguration no longer throws an error saying property + Members is not an array ([issue #790](https://github.com/PowerShell/xSQLServer/issues/790)). +- Changes to xSQLServerMaxDop + - Fixed error where Measure-Object cmdlet would fail claiming it could not + find the specified property ([issue #801](https://github.com/PowerShell/xSQLServer/issues/801)) +- Changes to xSQLServerAlwaysOnService + - Added integration test ([issue #736](https://github.com/PowerShell/xSQLServer/issues/736)). + - Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration + ([issue #824](https://github.com/PowerShell/xSQLServer/issues/824)). +- Changes to SMO.cs + - Added default properties to the Server class + - AvailabilityGroups + - Databases + - EndpointCollection + - Added a new overload to the Login class + - Added default properties to the AvailabilityReplicas class + - AvailabilityDatabases + - AvailabilityReplicas +- Added new resource xSQLServerAccount ([issue #706](https://github.com/PowerShell/xSQLServer/issues/706)) + - Added localization support for all strings + - Added examples for usage +- Changes to xSQLServerRSConfig + - No longer returns a null value from Test-TargetResource when Reporting + Services has not been initialized ([issue #822](https://github.com/PowerShell/xSQLServer/issues/822)). + - Fixed so that when two Reporting Services are installed for the same major + version the resource does not throw an error ([issue #819](https://github.com/PowerShell/xSQLServer/issues/819)). + - Now the resource will restart the Reporting Services service after + initializing ([issue #592](https://github.com/PowerShell/xSQLServer/issues/592)). + This will enable the Reports site to work. + - Added integration test ([issue #753](https://github.com/PowerShell/xSQLServer/issues/753)). + - Added support for configuring URL reservations and virtual directory names + ([issue #570](https://github.com/PowerShell/xSQLServer/issues/570)) +- Added resource + - xSQLServerDatabaseDefaultLocation + ([issue #656](https://github.com/PowerShell/xSQLServer/issues/656)) + +## [8.1.0.0] - 2017-08-23 + +### Changed + +- Changes to xSQLServer + - Added back .markdownlint.json so that lint rule MD013 is enforced. + - Change the module to use the image 'Visual Studio 2017' as the build worker + image for AppVeyor (issue #685). + - Minor style change in CommonResourceHelper. Added missing [Parameter()] on + three parameters. + - Minor style changes to the unit tests for CommonResourceHelper. + - Changes to xSQLServerHelper + - Added Swedish localization ([issue #695](https://github.com/PowerShell/xSQLServer/issues/695)). + - Opt-in for module files common tests ([issue #702](https://github.com/PowerShell/xSQLServer/issues/702)). + - Removed Byte Order Mark (BOM) from the files; CommonResourceHelper.psm1, + MSFT\_xSQLServerAvailabilityGroupListener.psm1, MSFT\_xSQLServerConfiguration.psm1, + MSFT\_xSQLServerEndpointPermission.psm1, MSFT\_xSQLServerEndpointState.psm1, + MSFT\_xSQLServerNetwork.psm1, MSFT\_xSQLServerPermission.psm1, + MSFT\_xSQLServerReplication.psm1, MSFT\_xSQLServerScript.psm1, + SQLPSStub.psm1, SQLServerStub.psm1. + - Opt-in for script files common tests ([issue #707](https://github.com/PowerShell/xSQLServer/issues/707)). + - Removed Byte Order Mark (BOM) from the files; DSCClusterSqlBuild.ps1, + DSCFCISqlBuild.ps1, DSCSqlBuild.ps1, DSCSQLBuildEncrypted.ps1, + SQLPush_SingleServer.ps1, 1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1, + 2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, + 3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1, + 4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, + 5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1, + 6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1, + 2-ConfigureInstanceToEnablePriorityBoost.ps1, 1-CreateEndpointWithDefaultValues.ps1, + 2-CreateEndpointWithSpecificPortAndIPAddress.ps1, 3-RemoveEndpoint.ps1, + 1-AddConnectPermission.ps1, 2-RemoveConnectPermission.ps1, + 3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, + 4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, + 1-MakeSureEndpointIsStarted.ps1, 2-MakeSureEndpointIsStopped.ps1, + 1-EnableTcpIpWithStaticPort.ps1, 2-EnableTcpIpWithDynamicPort.ps1, + 1-AddServerPermissionForLogin.ps1, 2-RemoveServerPermissionForLogin.ps1, + 1-ConfigureInstanceAsDistributor.ps1, 2-ConfigureInstanceAsPublisher.ps1, + 1-WaitForASingleClusterGroup.ps1, 2-WaitForMultipleClusterGroups.ps1. + - Updated year to 2017 in license file ([issue #711](https://github.com/PowerShell/xSQLServer/issues/711)). + - Code style clean-up throughout the module to align against the Style Guideline. + - Fixed typos and the use of wrong parameters in unit tests which was found + after release of new version of Pester ([issue #773](https://github.com/PowerShell/xSQLServer/issues/773)). +- Changes to xSQLServerAlwaysOnService + - Added resource description in README.md. + - Updated parameters descriptions in comment-based help, schema.mof and README.md. + - Changed the datatype of the parameter to UInt32 so the same datatype is used + in both the Get-/Test-/Set-TargetResource functions as in the schema.mof + (issue #688). + - Added read-only property IsHadrEnabled to schema.mof and the README.md + (issue #687). + - Minor cleanup of code. + - Added examples (issue #633) + - 1-EnableAlwaysOn.ps1 + - 2-DisableAlwaysOn.ps1 + - Fixed PS Script Analyzer errors ([issue #724](https://github.com/PowerShell/xSQLServer/issues/724)) + - Casting the result of the property IsHadrEnabled to [System.Boolean] so that + $null is never returned, which resulted in an exception ([issue #763](https://github.com/PowerShell/xSQLServer/issues/763)). +- Changes to xSQLServerDatabasePermission + - Fixed PS Script Analyzer errors ([issue #725](https://github.com/PowerShell/xSQLServer/issues/725)) +- Changes to xSQLServerScript + - Fixed PS Script Analyzer errors ([issue #728](https://github.com/PowerShell/xSQLServer/issues/728)) +- Changes to xSQLServerSetup + - Added Swedish localization ([issue #695](https://github.com/PowerShell/xSQLServer/issues/695)). + - Now Get-TargetResource correctly returns an array for property ASSysAdminAccounts, + and no longer throws an error when there is just one Analysis Services + administrator (issue #691). + - Added a simple integration test ([issue #709](https://github.com/PowerShell/xSQLServer/issues/709)). + - Fixed PS Script Analyzer errors ([issue #729](https://github.com/PowerShell/xSQLServer/issues/729)) + +## [8.0.0.0] - 2017-07-12 + +### Changed + +- BREAKING CHANGE: The module now requires WMF 5. + - This is required for class-based resources +- Added new resource + - xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership + - Added localization support for all strings. + - Refactored as a MOF based resource due to challenges with Pester and testing + in Powershell 5. +- Changes to xSQLServer + - BREAKING CHANGE: xSQLServer does no longer try to support WMF 4.0 (PowerShell + 4.0) (issue #574). Minimum supported version of WMF is now 5.0 (PowerShell 5.0). + - BREAKING CHANGE: Removed deprecated resource xSQLAOGroupJoin (issue #457). + - BREAKING CHANGE: Removed deprecated resource xSQLAOGroupEnsure (issue #456). + - BREAKING CHANGE: Removed deprecated resource xSQLServerFailoverClusterSetup + (issue #336). + - Updated PULL\_REQUEST\_TEMPLATE adding comment block around text. Also + rearranged and updated texts (issue #572). + - Added common helper functions for HQRM localization, and added tests for the + helper functions. + - Get-LocalizedData + - New-InvalidResultException + - New-ObjectNotFoundException + - New-InvalidOperationException + - New-InvalidArgumentException + - Updated CONTRIBUTING.md describing the new localization helper functions. + - Fixed typos in xSQLServer.strings.psd1 + - Fixed CodeCov badge links in README.md so that they point to the correct branch. + - Added VS Code workspace settings file with formatting settings matching the + Style Guideline (issue #645). That will make it possible inside VS Code to press + SHIFT+ALT+F, or press F1 and choose 'Format document' in the list. The + PowerShell code will then be formatted according to the Style Guideline + (although maybe not complete, but would help a long way). + - Removed powershell.codeFormatting.alignPropertyValuePairs setting since + it does not align with the style guideline. + - Added powershell.codeFormatting.preset with a value of 'Custom' so that + workspace formatting settings are honored (issue #665). + - Fixed lint error MD013 and MD036 in README.md. + - Updated .markdownlint.json to enable rule MD013 and MD036 to enforce those + lint markdown rules in the common tests. + - Fixed lint error MD013 in CHANGELOG.md. + - Fixed lint error MD013 in CONTRIBUTING.md. + - Added code block around types in README.md. + - Updated copyright information in xSQLServer.psd1. + - Opt-in for markdown common tests (issue #668). + - The old markdown tests has been removed. +- Changes to xSQLServerHelper + - Removed helper function Grant-ServerPerms because the deprecated resource that + was using it was removed. + - Removed helper function Grant-CNOPerms because the deprecated resource that + was using it was removed. + - Removed helper function New-ListenerADObject because the deprecated resource + that was using it was removed. + - Added tests for those helper functions that did not have tests. + - Test-SQLDscParameterState helper function can now correctly pass a CimInstance + as DesiredValue. + - Test-SQLDscParameterState helper function will now output a warning message + if the value type of a desired value is not supported. + - Added localization to helper functions (issue #641). + - Resolved the issue when using Write-Verbose in helper functions discussed + in #641 where Write-Verbose wouldn't write out verbose messages unless using + parameter Verbose. + - Moved localization strings from xSQLServer.strings.psd1 to + xSQLServerHelper.strings.psd1. +- Changes to xSQLServerSetup + - BREAKING CHANGE: Replaced StartWin32Process helper function with the cmdlet + Start-Process (issue #41, #93 and #126). + - BREAKING CHANGE: The parameter SetupCredential has been removed since it is + no longer needed. This is because the resource now support the built-in + PsDscRunAsCredential. + - BREAKING CHANGE: Now the resource supports using built-in PsDscRunAsCredential. + If PsDscRunAsCredential is set, that username will be used as the first system + administrator. + - BREAKING CHANGE: If the parameter PsDscRunAsCredential are not assigned any + credentials then the resource will start the setup process as the SYSTEM account. + When installing as the SYSTEM account, then parameter SQLSysAdminAccounts and + ASSysAdminAccounts must be specified when installing feature Database Engine + and Analysis Services respectively. + - When setup exits with the exit code 3010 a warning message is written to console + telling that setup finished successfully, but a reboot is required (partly fixes + issue #565). + - When setup exits with an exit code other than 0 or 3010 a warning message is + written to console telling that setup finished with an error (partly fixes + issue #580). + - Added a new parameter SetupProcessTimeout which defaults to 7200 seconds (2 + hours). If the setup process has not finished before the timeout value in + SetupProcessTimeout an error will be thrown (issue #566). + - Updated all examples to match the removal of SetupCredential. + - Updated (removed) severe known issues in README.md for resource xSQLServerSetup. + - Now all major version uses the same identifier to evaluate InstallSharedDir + and InstallSharedWOWDir (issue #420). + - Now setup arguments that contain no value will be ignored, for example when + InstallSharedDir and + InstallSharedWOWDir path is already present on the target node, because of a + previous installation (issue #639). + - Updated Get-TargetResource to correctly detect BOL, Conn, BC and other tools + when they are installed without SQLENGINE (issue #591). + - Now it can detect Documentation Components correctly after the change in + issue #591 (issue #628) + - Fixed bug that prevented Get-DscConfiguration from running without error. The + return hash table fails if the $clusteredSqlIpAddress variable is not used. + The schema expects a string array but it is initialized as just a null string, + causing it to fail on Get-DscConfiguration (issue #393). + - Added localization support for all strings. + - Added a test to test some error handling for cluster installations. + - Added support for MDS feature install (issue #486) + - Fixed localization support for MDS feature (issue #671). +- Changes to xSQLServerRSConfig + - BREAKING CHANGE: Removed `$SQLAdminCredential` parameter. Use common parameter + `PsDscRunAsCredential` (WMF 5.0+) to run the resource under different credentials. + `PsDscRunAsCredential` Windows account must be a sysadmin on SQL Server (issue + #568). + - In addition, the resource no longer uses `Invoke-Command` cmdlet that was used + to impersonate the Windows user specified by `$SQLAdminCredential`. The call + also needed CredSSP authentication to be enabled and configured on the target + node, which complicated deployments in non-domain scenarios. Using + `PsDscRunAsCredential` solves this problems for us. + - Fixed virtual directory creation for SQL Server 2016 (issue #569). + - Added unit tests (issue #295). +- Changes to xSQLServerDatabase + - Changed the readme, SQLInstance should have been SQLInstanceName. +- Changes to xSQLServerScript + - Fixed bug with schema and variable mismatch for the Credential/Username parameter + in the return statement (issue #661). + - Optional QueryTimeout parameter to specify sql script query execution timeout. + Fixes issue #597 +- Changes to xSQLServerAlwaysOnService + - Fixed typos in localization strings and in tests. +- Changes to xSQLServerAlwaysOnAvailabilityGroup + - Now it utilize the value of 'FailoverMode' to set the 'FailoverMode' property + of the Availability Group instead of wrongly using the 'AvailabilityMode' + property of the Availability Group. + +## [7.1.0.0] - 2017-05-31 + +### Changed + +- Changes to xSQLServerMemory + - Changed the way SQLServer parameter is passed from Test-TargetResource to + Get-TargetResource so that the default value isn't lost (issue #576). + - Added condition to unit tests for when no SQLServer parameter is set. +- Changes to xSQLServerMaxDop + - Changed the way SQLServer parameter is passed from Test-TargetResource to + Get-TargetResource so that the default value isn't lost (issue #576). + - Added condition to unit tests for when no SQLServer parameter is set. +- Changes to xWaitForAvailabilityGroup + - Updated README.md with a description for the resources and revised the parameter + descriptions. + - The default value for RetryIntervalSec is now 20 seconds and the default value + for RetryCount is now 30 times (issue #505). + - Cleaned up code and fixed PSSA rules warnings (issue #268). + - Added unit tests (issue #297). + - Added descriptive text to README.md that the account that runs the resource + must have permission to run the cmdlet Get-ClusterGroup (issue #307). + - Added read-only parameter GroupExist which will return $true if the cluster + role/group exist, otherwise it returns $false (issue #510). + - Added examples. +- Changes to xSQLServerPermission + - Cleaned up code, removed SupportsShouldProcess and fixed PSSA rules warnings + (issue #241 and issue #262). + - It is now possible to add permissions to two or more logins on the same instance + (issue #526). + - The parameter NodeName is no longer mandatory and has now the default value + of $env:COMPUTERNAME. + - The parameter Ensure now has a default value of 'Present'. + - Updated README.md with a description for the resources and revised the parameter + descriptions. + - Removed dependency of SQLPS provider (issue #482). + - Added ConnectSql permission. Now that permission can also be granted or revoked. + - Updated note in resource description to also mention ConnectSql permission. +- Changes to xSQLServerHelper module + - Removed helper function Get-SQLPSInstance and Get-SQLPSInstanceName because + there is no resource using it any longer. + - Added four new helper functions. + - Register-SqlSmo, Register-SqlWmiManagement and Unregister-SqlAssemblies to + handle the creation on the application domain and loading and unloading of + the SMO and SqlWmiManagement assemblies. + - Get-SqlInstanceMajorVersion to get the major SQL version for a specific instance. + - Fixed typos in comment-based help +- Changes to xSQLServer + - Fixed typos in markdown files; CHANGELOG, CONTRIBUTING, README and ISSUE_TEMPLATE. + - Fixed typos in schema.mof files (and README.md). + - Updated some parameter description in schema.mof files on those that was found + was not equal to README.md. +- Changes to xSQLServerAlwaysOnService + - Get-TargetResource should no longer fail silently with error 'Index operation + failed; the array index evaluated to null.' (issue #519). Now if the + Server.IsHadrEnabled property return neither $true or $false the + Get-TargetResource function will throw an error. +- Changes to xSQLServerSetUp + - Updated xSQLServerSetup Module Get-Resource method to fix (issue #516 and #490). + - Added change to detect DQ, DQC, BOL, SDK features. Now the function + Test-TargetResource returns true after calling set for DQ, DQC, BOL, SDK + features (issue #516 and #490). +- Changes to xSQLServerAlwaysOnAvailabilityGroup + - Updated to return the exception raised when an error is thrown. +- Changes to xSQLServerAlwaysOnAvailabilityGroupReplica + - Updated to return the exception raised when an error is thrown. + - Updated parameter description for parameter Name, so that it says it must be + in the format SQLServer\InstanceName for named instance (issue #548). +- Changes to xSQLServerLogin + - Added an optional boolean parameter Disabled. It can be used to enable/disable + existing logins or create disabled logins (new logins are created as enabled + by default). +- Changes to xSQLServerDatabaseRole + - Updated variable passed to Microsoft.SqlServer.Management.Smo.User constructor + to fix issue #530 +- Changes to xSQLServerNetwork + - Added optional parameter SQLServer with default value of $env:COMPUTERNAME + (issue #528). + - Added optional parameter RestartTimeout with default value of 120 seconds. + - Now the resource supports restarting a sql server in a cluster (issue #527 + and issue #455). + - Now the resource allows to set the parameter TcpDynamicPorts to a blank value + (partly fixes issue #534). Setting a blank value for parameter TcpDynamicPorts + together with a value for parameter TcpPort means that static port will be used. + - Now the resource will not call Alter() in the Set-TargetResource when there + is no change necessary (issue #537). + - Updated example 1-EnableTcpIpOnCustomStaticPort. + - Added unit tests (issue #294). + - Refactored some of the code, cleaned up the rest and fixed PSSA rules warnings + (issue #261). + - If parameter TcpDynamicPort is set to '0' at the same time as TcpPort is set + the resource will now throw an error (issue #535). + - Added examples (issue #536). + - When TcpDynamicPorts is set to '0' the Test-TargetResource function will no + longer fail each time (issue #564). +- Changes to xSQLServerRSConfig + - Replaced sqlcmd.exe usages with Invoke-Sqlcmd calls (issue #567). +- Changes to xSQLServerDatabasePermission + - Fixed code style, updated README.md and removed *-SqlDatabasePermission functions + from xSQLServerHelper.psm1. + - Added the option 'GrantWithGrant' with gives the user grant rights, together + with the ability to grant others the same right. + - Now the resource can revoke permission correctly (issue #454). When revoking + 'GrantWithGrant', both the grantee and all the other users the grantee has + granted the same permission to, will also get their permission revoked. + - Updated tests to cover Revoke(). +- Changes to xSQLServerHelper + - The missing helper function ('Test-SPDSCObjectHasProperty'), that was referenced + in the helper function Test-SQLDscParameterState, is now incorporated into + Test-SQLDscParameterState (issue #589). + +## [7.0.0.0] - 2017-04-19 + +### Changed + +- Examples + - xSQLServerDatabaseRole + - 1-AddDatabaseRole.ps1 + - 2-RemoveDatabaseRole.ps1 + - xSQLServerRole + - 3-AddMembersToServerRole.ps1 + - 4-MembersToIncludeInServerRole.ps1 + - 5-MembersToExcludeInServerRole.ps1 + - xSQLServerSetup + - 1-InstallDefaultInstanceSingleServer.ps1 + - 2-InstallNamedInstanceSingleServer.ps1 + - 3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 + - 4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 + - 5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 + - xSQLServerReplication + - 1-ConfigureInstanceAsDistributor.ps1 + - 2-ConfigureInstanceAsPublisher.ps1 + - xSQLServerNetwork + - 1-EnableTcpIpOnCustomStaticPort.ps1 + - xSQLServerAvailabilityGroupListener + - 1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 + - 2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 + - 3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 + - 4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 + - 5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 + - 6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 + - xSQLServerEndpointPermission + - 1-AddConnectPermission.ps1 + - 2-RemoveConnectPermission.ps1 + - 3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 + - 4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 + - xSQLServerPermission + - 1-AddServerPermissionForLogin.ps1 + - 2-RemoveServerPermissionForLogin.ps1 + - xSQLServerEndpointState + - 1-MakeSureEndpointIsStarted.ps1 + - 2-MakeSureEndpointIsStopped.ps1 + - xSQLServerConfiguration + - 1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 + - 2-ConfigureInstanceToEnablePriorityBoost.ps1 + - xSQLServerEndpoint + - 1-CreateEndpointWithDefaultValues.ps1 + - 2-CreateEndpointWithSpecificPortAndIPAddress.ps1 + - 3-RemoveEndpoint.ps1 +- Changes to xSQLServerDatabaseRole + - Fixed code style, added updated parameter descriptions to schema.mof and README.md. +- Changes to xSQLServer + - Raised the CodeCov target to 70% which is the minimum and required target for + HQRM resource. +- Changes to xSQLServerRole + - **BREAKING CHANGE: The resource has been reworked in it's entirely.** Below + is what has changed. + - The mandatory parameters now also include ServerRoleName. + - The ServerRole parameter was before an array of server roles, now this parameter + is renamed to ServerRoleName and can only be set to one server role. + - ServerRoleName are no longer limited to built-in server roles. To add members + to a built-in server role, set ServerRoleName to the name of the built-in + server role. + - The ServerRoleName will be created when Ensure is set to 'Present' (if it + does not already exist), or removed if Ensure is set to 'Absent'. + - Three new parameters are added; Members, MembersToInclude and MembersToExclude. + - Members can be set to one or more logins, and those will _replace all_ the + memberships in the server role. + - MembersToInclude and MembersToExclude can be set to one or more logins that + will add or remove memberships, respectively, in the server role. MembersToInclude + and MembersToExclude _can not_ be used at the same time as parameter Members. + But both MembersToInclude and MembersToExclude can be used together at the + same time. +- Changes to xSQLServerSetup + - Added a note to the README.md saying that it is not possible to add or remove + features from a SQL Server failover cluster (issue #433). + - Changed so that it reports false if the desired state is not correct (issue #432). + - Added a test to make sure we always return false if a SQL Server failover + cluster is missing features. + - Helper function Connect-SQLAnalysis + - Now has correct error handling, and throw does not used the unknown named + parameter '-Message' (issue #436) + - Added tests for Connect-SQLAnalysis + - Changed to localized error messages. + - Minor changes to error handling. + - This adds better support for Addnode (issue #369). + - Now it skips cluster validation för add node (issue #442). + - Now it ignores parameters that are not allowed for action Addnode (issue #441). + - Added support for vNext CTP 1.4 (issue #472). +- Added new resource + - xSQLServerAlwaysOnAvailabilityGroupReplica +- Changes to xSQLServerDatabaseRecoveryModel + - Fixed code style, removed SQLServerDatabaseRecoveryModel functions from xSQLServerHelper. +- Changes to xSQLServerAlwaysOnAvailabilityGroup + - Fixed the permissions check loop so that it exits the loop after the function + determines the required permissions are in place. +- Changes to xSQLServerAvailabilityGroupListener + - Removed the dependency of SQLPS provider (issue #460). + - Cleaned up code. + - Added test for more coverage. + - Fixed PSSA rule warnings (issue #255). + - Parameter Ensure now defaults to 'Present' (issue #450). +- Changes to xSQLServerFirewall + - Now it will correctly create rules when the resource is used for two or more + instances on the same server (issue #461). +- Changes to xSQLServerEndpointPermission + - Added description to the README.md + - Cleaned up code (issue #257 and issue #231) + - Now the default value for Ensure is 'Present'. + - Removed dependency of SQLPS provider (issue #483). + - Refactored tests so they use less code. +- Changes to README.md + - Adding deprecated tag to xSQLServerFailoverClusterSetup, xSQLAOGroupEnsure and + xSQLAOGroupJoin in README.md so it it more clear that these resources has been + replaced by xSQLServerSetup, xSQLServerAlwaysOnAvailabilityGroup and + xSQLServerAlwaysOnAvailabilityGroupReplica respectively. +- Changes to xSQLServerEndpoint + - BREAKING CHANGE: Now SQLInstanceName is mandatory, and is a key, so + SQLInstanceName has no longer a default value (issue #279). + - BREAKING CHANGE: Parameter AuthorizedUser has been removed (issue #466, + issue #275 and issue #80). Connect permissions can be set using the resource + xSQLServerEndpointPermission. + - Optional parameter IpAddress has been added. Default is to listen on any + valid IP-address. (issue #232) + - Parameter Port now has a default value of 5022. + - Parameter Ensure now defaults to 'Present'. + - Resource now supports changing IP address and changing port. + - Added unit tests (issue #289) + - Added examples. +- Changes to xSQLServerEndpointState + - Cleaned up code, removed SupportsShouldProcess and fixed PSSA rules warnings + (issue #258 and issue #230). + - Now the default value for the parameter State is 'Started'. + - Updated README.md with a description for the resources and revised the + parameter descriptions. + - Removed dependency of SQLPS provider (issue #481). + - The parameter NodeName is no longer mandatory and has now the default value + of $env:COMPUTERNAME. + - The parameter Name is now a key so it is now possible to change the state on + more than one endpoint on the same instance. _Note: The resource still only + supports Database Mirror endpoints at this time._ +- Changes to xSQLServerHelper module + - Removing helper function Get-SQLAlwaysOnEndpoint because there is no resource + using it any longer. + - BREAKING CHANGE: Changed helper function Import-SQLPSModule to support SqlServer + module (issue #91). The SqlServer module is the preferred module so if it is + found it will be used, and if not found an attempt will be done to load SQLPS + module instead. +- Changes to xSQLServerScript + - Updated tests for this resource, because they failed when Import-SQLPSModule + was updated. + +## [6.0.0.0] - 2017-03-08 + +### Changed + +- Changes to xSQLServerConfiguration + - BREAKING CHANGE: The parameter SQLInstanceName is now mandatory. + - Resource can now be used to define the configuration of two or more different + DB instances on the same server. +- Changes to xSQLServerRole + - xSQLServerRole now correctly reports that the desired state is present when + the login is already a member of the server roles. +- Added new resources + - xSQLServerAlwaysOnAvailabilityGroup +- Changes to xSQLServerSetup + - Properly checks for use of SQLSysAdminAccounts parameter in $PSBoundParameters. + The test now also properly evaluates the setup argument for SQLSysAdminAccounts. + - xSQLServerSetup should now function correctly for the InstallFailoverCluster + action, and also supports cluster shared volumes. Note that the AddNode action + is not currently working. + - It now detects that feature Client Connectivity Tools (CONN) and Client + Connectivity Backwards Compatibility Tools (BC) is installed. + - Now it can correctly determine the right cluster when only parameter + InstallSQLDataDir is assigned a path (issue #401). + - Now the only mandatory path parameter is InstallSQLDataDir when installing + Database Engine (issue #400). + - It now can handle mandatory parameters, and are not using wildcard to find + the variables containing paths (issue #394). + - Changed so that instead of connection to localhost it is using $env:COMPUTERNAME + as the host name to which it connects. And for cluster installation it uses + the parameter FailoverClusterNetworkName as the host name to which it connects + (issue #407). + - When called with Action = 'PrepareFailoverCluster', the SQLSysAdminAccounts + and FailoverClusterGroup parameters are no longer passed to the setup process + (issues #410 and 411). + - Solved the problem that InstanceDir and InstallSQLDataDir could not be set to + just a qualifier, i.e 'E:' (issue #418). All paths (except SourcePath) can now + be set to just the qualifier. +- Enables CodeCov.io code coverage reporting. +- Added badge for CodeCov.io to README.md. +- Examples + - xSQLServerMaxDop + - 1-SetMaxDopToOne.ps1 + - 2-SetMaxDopToAuto.ps1 + - 3-SetMaxDopToDefault.ps1 + - xSQLServerMemory + - 1-SetMaxMemoryTo12GB.ps1 + - 2-SetMaxMemoryToAuto.ps1 + - 3-SetMinMaxMemoryToAuto.ps1 + - 4-SetMaxMemoryToDefault.ps1 + - xSQLServerDatabase + - 1-CreateDatabase.ps1 + - 2-DeleteDatabase.ps1 +- Added tests for resources + - xSQLServerMaxDop + - xSQLServerMemory +- Changes to xSQLServerMemory + - BREAKING CHANGE: The mandatory parameter now include SQLInstanceName. The + DynamicAlloc parameter is no longer mandatory +- Changes to xSQLServerDatabase + - When the system is not in desired state the Test-TargetResource will now output + verbose messages saying so. +- Changes to xSQLServerDatabaseOwner + - Fixed code style, added updated parameter descriptions to schema.mof and README.md. + +## [5.0.0.0] - 2017-01-25 + +### Changed + + Improvements how tests are initiated in AppVeyor + - Removed previous workaround (issue #201) from unit tests. + - Changes in appveyor.yml so that SQL modules are removed before common test is + run. + - Now the deploy step are no longer failing when merging code into Dev. Neither + is the deploy step failing if a contributor had AppVeyor connected to the fork + of xSQLServer and pushing code to the fork. +- Changes to README.md + - Changed the contributing section to help new contributors. + - Added links for each resource so it is easier to navigate to the parameter list + for each resource. + - Moved the list of resources in alphabetical order. + - Moved each resource parameter list into alphabetical order. + - Removed old text mentioning System Center. + - Now the correct product name is written in the installation section, and a typo + was also fixed. + - Fixed a typo in the Requirements section. + - Added link to Examples folder in the Examples section. + - Change the layout of the README.md to closer match the one of PSDscResources + - Added more detailed text explaining what operating systems WMF5.0 can be installed + on. + - Verified all resource schema files with the README.md and fixed some errors + (descriptions was not verified). + - Added security requirements section for resource xSQLServerEndpoint and + xSQLAOGroupEnsure. +- Changes to xSQLServerSetup + - The resource no longer uses Win32_Product WMI class when evaluating if + SQL Server Management Studio is installed. See article + [kb974524](https://support.microsoft.com/en-us/kb/974524) for more information. + - Now it uses CIM cmdlets to get information from WMI classes. + - Resolved all of the PSScriptAnalyzer warnings that was triggered in the common + tests. + - Improvement for service accounts to enable support for Managed Service Accounts + as well as other nt authority accounts + - Changes to the helper function Copy-ItemWithRoboCopy + - Robocopy is now started using Start-Process and the error handling has been + improved. + - Robocopy now removes files at the destination path if they no longer exists + at the source. + - Robocopy copies using unbuffered I/O when available (recommended for large + files). + - Added a more descriptive text for the parameter `SourceCredential` to further + explain how the parameter work. + - BREAKING CHANGE: Removed parameter SourceFolder. + - BREAKING CHANGE: Removed default value "$PSScriptRoot\..\..\" from parameter + SourcePath. + - Old code, that no longer filled any function, has been replaced. + - Function `ResolvePath` has been replaced with + `[Environment]::ExpandEnvironmentVariables($SourcePath)` so that environment + variables still can be used in Source Path. + - Function `NetUse` has been replaced with `New-SmbMapping` and + `Remove-SmbMapping`. + - Renamed function `GetSQLVersion` to `Get-SqlMajorVersion`. + - BREAKING CHANGE: Renamed parameter PID to ProductKey to avoid collision with + automatic variable $PID +- Changes to xSQLServerScript + - All credential parameters now also has the type + [System.Management.Automation.Credential()] to better work with PowerShell 4.0. + - It is now possible to configure two instances on the same node, with the same + script. + - Added to the description text for the parameter `Credential` describing how + to authenticate using Windows Authentication. + - Added examples to show how to authenticate using either SQL or Windows + authentication. + - A recent issue showed that there is a known problem running this resource + using PowerShell 4.0. For more information, see [issue #273](https://github.com/PowerShell/xSQLServer/issues/273) +- Changes to xSQLServerFirewall + - BREAKING CHANGE: Removed parameter SourceFolder. + - BREAKING CHANGE: Removed default value "$PSScriptRoot\..\..\" from parameter + SourcePath. + - Old code, that no longer filled any function, has been replaced. + - Function `ResolvePath` has been replaced with + `[Environment]::ExpandEnvironmentVariables($SourcePath)` so that environment + variables still can be used in Source Path. + - Adding new optional parameter SourceCredential that can be used to authenticate + against SourcePath. + - Solved PSSA rules errors in the code. + - Get-TargetResource no longer return $true when no products was installed. +- Changes to the unit test for resource + - xSQLServerSetup + - Added test coverage for helper function Copy-ItemWithRoboCopy +- Changes to xSQLServerLogin + - Removed ShouldProcess statements + - Added the ability to enforce password policies on SQL logins +- Added common test (xSQLServerCommon.Tests) for xSQLServer module + - Now all markdown files will be style checked when tests are running in AppVeyor + after sending in a pull request. + - Now all [Examples](/source/Examples/Resources) will be tested by compiling to a .mof + file after sending in a pull request. +- Changes to xSQLServerDatabaseOwner + - The example 'SetDatabaseOwner' can now compile, it wrongly had a `DependsOn` + in the example. +- Changes to SQLServerRole + - The examples 'AddServerRole' and 'RemoveServerRole' can now compile, it wrongly + had a `DependsOn` in the example. +- Changes to CONTRIBUTING.md + - Added section 'Tests for examples files' + - Added section 'Tests for style check of Markdown files' + - Added section 'Documentation with Markdown' + - Added texts to section 'Tests' +- Changes to xSQLServerHelper + - added functions + - Get-SqlDatabaseRecoveryModel + - Set-SqlDatabaseRecoveryModel +- Examples + - xSQLServerDatabaseRecoveryModel + - 1-SetDatabaseRecoveryModel.ps1 + - xSQLServerDatabasePermission + - 1-GrantDatabasePermissions.ps1 + - 2-RevokeDatabasePermissions.ps1 + - 3-DenyDatabasePermissions.ps1 + - xSQLServerFirewall + - 1-CreateInboundFirewallRules + - 2-RemoveInboundFirewallRules +- Added tests for resources + - xSQLServerDatabaseRecoveryModel + - xSQLServerDatabasePermissions + - xSQLServerFirewall +- Changes to xSQLServerDatabaseRecoveryModel + - BREAKING CHANGE: Renamed xSQLDatabaseRecoveryModel to + xSQLServerDatabaseRecoveryModel to align with naming convention. + - BREAKING CHANGE: The mandatory parameters now include SQLServer, and + SQLInstanceName. +- Changes to xSQLServerDatabasePermission + - BREAKING CHANGE: Renamed xSQLServerDatabasePermissions to + xSQLServerDatabasePermission to align with naming convention. + - BREAKING CHANGE: The mandatory parameters now include PermissionState, + SQLServer, and SQLInstanceName. +- Added support for clustered installations to xSQLServerSetup + - Migrated relevant code from xSQLServerFailoverClusterSetup + - Removed Get-WmiObject usage + - Clustered storage mapping now supports asymmetric cluster storage + - Added support for multi-subnet clusters + - Added localized error messages for cluster object mapping + - Updated README.md to reflect new parameters +- Updated description for xSQLServerFailoverClusterSetup to indicate it is deprecated. +- xPDT helper module + - Function GetxPDTVariable was removed since it no longer was used by any resources. + - File xPDT.xml was removed since it was not used by any resources, and did not + provide any value to the module. +- Changes xSQLServerHelper module + - Removed the globally defined `$VerbosePreference = 'Continue'` from xSQLServerHelper. + - Fixed a typo in a variable name in the function New-ListenerADObject. + - Now Restart-SqlService will correctly show the services it restarts. Also + fixed PSSA warnings. + +## [4.0.0.0] - 2016-12-14 + +### Changed + +- Fixes in xSQLServerConfiguration + - Added support for clustered SQL instances. + - BREAKING CHANGE: Updated parameters to align with other resources + (SQLServer / SQLInstanceName). + - Updated code to utilize CIM rather than WMI. +- Added tests for resources + - xSQLServerConfiguration + - xSQLServerSetup + - xSQLServerDatabaseRole + - xSQLAOGroupJoin + - xSQLServerHelper and moved the existing tests for Restart-SqlService to it. + - xSQLServerAlwaysOnService +- Fixes in xSQLAOGroupJoin + - Availability Group name now appears in the error message for a failed. + Availability Group join attempt. + - Get-TargetResource now works with Get-DscConfiguration. +- Fixes in xSQLServerRole + - Updated Ensure parameter to 'Present' default value. + - Renamed helper functions *-SqlServerRole to *-SqlServerRoleMember. +- Changes to xSQLAlias + - Add UseDynamicTcpPort parameter for option "Dynamically determine port". + - Change Get-WmiObject to Get-CimInstance in Resource and associated pester file. +- Added CHANGELOG.md file. +- Added issue template file (ISSUE\_TEMPLATE.md) for 'New Issue' and pull request + template file (PULL\_REQUEST\_TEMPLATE.md) for 'New Pull Request'. +- Add Contributing.md file. +- Changes to xSQLServerSetup + - Now `Features` parameter is case-insensitive. +- BREAKING CHANGE: Removed xSQLServerPowerPlan from this module. The resource has + been moved to [xComputerManagement](https://github.com/PowerShell/xComputerManagement) + and is now called xPowerPlan. +- Changes and enhancements in xSQLServerDatabaseRole + - BREAKING CHANGE: Fixed so the same user can now be added to a role in one or + more databases, and/or one or more instances. Now the parameters `SQLServer` + and `SQLInstanceName` are mandatory. + - Enhanced so the same user can now be added to more than one role +- BREAKING CHANGE: Renamed xSQLAlias to xSQLServerAlias to align with naming convention. +- Changes to xSQLServerAlwaysOnService + - Added RestartTimeout parameter + - Fixed bug where the SQL Agent service did not get restarted after the + IsHadrEnabled property was set. + - BREAKING CHANGE: The mandatory parameters now include Ensure, SQLServer, and + SQLInstanceName. SQLServer and SQLInstanceName are keys which will be used to + uniquely identify the resource which allows AlwaysOn to be enabled on multiple + instances on the same machine. +- Moved Restart-SqlService from MSFT_xSQLServerConfiguration.psm1 to xSQLServerHelper.psm1. + +## [3.0.0.0] - 2016-11-02 + +### Changed + +- xSQLServerHelper + - added functions + - Test-SQLDscParameterState + - Get-SqlDatabaseOwner + - Set-SqlDatabaseOwner +- Examples + - xSQLServerDatabaseOwner + - 1-SetDatabaseOwner.ps1 +- Added tests for resources + - MSFT_xSQLServerDatabaseOwner + +## [2.0.0.0] - 2016-09-21 + +### Changed + +- Added resources + - xSQLServerReplication + - xSQLServerScript + - xSQLAlias + - xSQLServerRole +- Added tests for resources + - xSQLServerPermission + - xSQLServerEndpointState + - xSQLServerEndpointPermission + - xSQLServerAvailabilityGroupListener + - xSQLServerLogin + - xSQLAOGroupEnsure + - xSQLAlias + - xSQLServerRole +- Fixes in xSQLServerAvailabilityGroupListener + - In one case the Get-method did not report that DHCP was configured. + - Now the resource will throw 'Not supported' when IP is changed between Static + and DHCP. + - Fixed an issue where sometimes the listener wasn't removed. + - Fixed the issue when trying to add a static IP to a listener was ignored. +- Fix in xSQLServerDatabase + - Fixed so dropping a database no longer throws an error + - BREAKING CHANGE: Fixed an issue where it was not possible to add the same + database to two instances on the same server. + - BREAKING CHANGE: The name of the parameter Database has changed. It is now + called Name. +- Fixes in xSQLAOGroupEnsure + - Added parameters to New-ListenerADObject to allow usage of a named instance. + - pass setup credential correctly +- Changes to xSQLServerLogin + - Fixed an issue when dropping logins. + - BREAKING CHANGE: Fixed an issue where it was not possible to add the same + login to two instances on the same server. +- Changes to xSQLServerMaxDop + - BREAKING CHANGE: Made SQLInstance parameter a key so that multiple instances + on the same server can be configured + +## [1.8.0.0] - 2016-08-10 + +### Changed + +- Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey. +- Added Support for SQL Server 2016 +- xSQLAOGroupEnsure + - Fixed spelling mistake in AutoBackupPreference property + - Added BackupPriority property +- Added resources + - xSQLServerPermission + - xSQLServerEndpointState + - xSQLServerEndpointPermission + - xSQLServerAvailabilityGroupListener +- xSQLServerHelper + - added functions + - Import-SQLPSModule + - Get-SQLPSInstanceName + - Get-SQLPSInstance + - Get-SQLAlwaysOnEndpoint + - modified functions + - New-TerminatingError - *added optional parameter `InnerException` to be able + to give the user more information in the returned message* + +## [1.7.0.0] - 2016-06-29 + +### Changed + +- Resources Added + - xSQLServerConfiguration + +## [1.6.0.0] - 2016-05-18 + +### Changed + +- Resources Added + - xSQLAOGroupEnsure + - xSQLAOGroupJoin + - xWaitForAvailabilityGroup + - xSQLServerEndPoint + - xSQLServerAlwaysOnService +- xSQLServerHelper + - added functions + - Connect-SQL + - New-VerboseMessage + - Grant-ServerPerms + - Grant-CNOPerms + - New-ListenerADObject +- xSQLDatabaseRecoveryModel + - Updated Verbose statements to use new function New-VerboseMessage +- xSQLServerDatabase + - Updated Verbose statements to use new function New-VerboseMessage + - Removed ConnectSQL function and replaced with new Connect-SQL function +- xSQLServerDatabaseOwner + - Removed ConnectSQL function and replaced with new Connect-SQL function +- xSQLServerDatabasePermissions + - Removed ConnectSQL function and replaced with new Connect-SQL function +- xSQLServerDatabaseRole + - Removed ConnectSQL function and replaced with new Connect-SQL function +- xSQLServerLogin + - Removed ConnectSQL function and replaced with new Connect-SQL function +- xSQLServerMaxDop + - Updated Verbose statements to use new function New-VerboseMessage + - Removed ConnectSQL function and replaced with new Connect-SQL function +- xSQLServerMemory + - Updated Verbose statements to use new function New-VerboseMessage + - Removed ConnectSQL function and replaced with new Connect-SQL function +- xSQLServerPowerPlan + - Updated Verbose statements to use new function New-VerboseMessage +- Examples + - Added xSQLServerConfiguration resource example + +## [1.5.0.0] - 2016-03-30 + +### Changed + +- Added new resource xSQLServerDatabase that allows adding an empty database to + a server + +## [1.4.0.0] - 2016-02-02 + +### Changed + +- Resources Added + - xSQLDatabaseRecoveryModeAdded + - xSQLServerDatabaseOwner + - xSQLServerDatabasePermissions + - xSQLServerDatabaseRole + - xSQLServerLogin + - xSQLServerMaxDop + - xSQLServerMemory + - xSQLServerPowerPlan + - xSQLServerDatabase +- xSQLServerSetup: + - Corrected bug in GetFirstItemPropertyValue to correctly handle registry keys + with only one value. + - Added support for SQL Server + - 2008 R2 installation + - Removed default values for parameters, to avoid compatibility issues and setup + errors + - Added Replication sub feature detection + - Added setup parameter BrowserSvcStartupType + - Change SourceFolder to Source to allow for multi version Support + - Add Source Credential for accessing source files + - Add Parameters for SQL Server configuration + - Add Parameters to SuppressReboot or ForceReboot +- xSQLServerFirewall + - Removed default values for parameters, to avoid compatibility issues + - Updated firewall rule name to not use 2012 version, since package supports 2008, + 2012 and 2014 versions + - Additional of SQLHelper Function and error handling + - Change SourceFolder to Source to allow for multi version Support +- xSQLServerNetwork + - Added new resource that configures network settings. + - Currently supports only tcp network protocol + - Allows to enable and disable network protocol for specified instance service + - Allows to set custom or dynamic port values +- xSQLServerRSSecureConnectionLevel + - Additional of SQLHelper Function and error handling +- xSqlServerRSConfig +- xSQLServerFailoverClusterSetup + - Additional of SQLHelper Function and error handling + - Change SourceFolder to Source to allow for multi version Support + - Add Parameters to SuppressReboot or ForceReboot +- Examples + - Updated example files to use correct DebugMode parameter value ForceModuleImport, + this is not boolean in WMF 5.0 RTM + - Added xSQLServerNetwork example + +## [1.3.0.0] - 2015-05-01 + +### Changed + +- xSqlServerSetup + - Make Features case-insensitive. + +## [1.2.1.0] - 2015-04-23 + +### Changed + +- Increased timeout for setup process to start to 60 seconds. + +## [1.2.0.0] - 2014-12-18 + +### Changed + +- Updated release with the following new resources + - xSQLServerFailoverClusterSetup + - xSQLServerRSConfig + +## [1.1.0.0] - 2014-10-24 + +### Changed + +- Initial release with the following resources + - xSQLServerSetup + - xSQLServerFirewall + - xSQLServerRSSecureConnectionLevel diff --git a/LICENSE b/LICENSE index 6bf8d3abb..f4c3ee927 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018 Microsoft Corporation. +Copyright (c) DSC Community contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 0d1927a94..a0a03d281 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,30 @@ # SqlServerDsc -The **SqlServerDsc** module contains DSC resources -for deployment and configuration of SQL Server. +The **SqlServerDsc** module contains DSC resources for deployment and +configuration of Microsoft SQL Server. -This project has adopted [this code of conduct](CODE_OF_CONDUCT.md). +[![Build Status](https://dev.azure.com/dsccommunity/SqlServerDsc/_apis/build/status/dsccommunity.SqlServerDsc?branchName=master)](https://dev.azure.com/dsccommunity/SqlServerDsc/_build/latest?definitionId=11&branchName=master) +![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/dsccommunity/SqlServerDsc/11/master) +[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/SqlServerDsc/11/master)](https://dsccommunity.visualstudio.com/SqlServerDsc/_test/analytics?definitionId=11&contextType=build) +[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/SqlServerDsc?label=SqlServerDsc%20Preview)](https://www.powershellgallery.com/packages/SqlServerDsc/) +[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/SqlServerDsc?label=SqlServerDsc)](https://www.powershellgallery.com/packages/SqlServerDsc/) -## Branches +## Code of Conduct -### master +This project has adopted this [Code of Conduct](CODE_OF_CONDUCT.md). -[![Build status](https://ci.appveyor.com/api/projects/status/b3g8f7kftx64n26l/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) +## Releases -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/b3g8f7kftx64n26l/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/). +For each merge to the branch `master` a preview release will be +deployed to [PowerShell Gallery](https://www.powershellgallery.com/). +Periodically a release version tag will be pushed which will deploy a +full release 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/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/SqlServerDsc/pulls) - and look for those pull requests with label 'needs review'. -* If you want to improve this resource module, - then please check out the following guidelines. - * The specific [Contributing to SqlServerDsc](https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md) - guidelines. - * The common [Style Guidelines & Best Practices](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md). - * 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 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. +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing) +and the specific [Contributing to SqlServerDsc](https://github.com/dsccommunity/SqlServerDsc/blob/dev/CONTRIBUTING.md) +guidelines. ## Installation @@ -94,7 +58,7 @@ Windows Server 2008 R2 SP1, Windows Server 2012 and Windows Server 2012 R2. ## Examples -You can review the [Examples](/Examples) directory in the SqlServerDsc module +You can review the [Examples](/source/Examples) directory in the SqlServerDsc module for some general use scenarios for all of the resources that are in the module. ## Change log @@ -244,13 +208,13 @@ It will also manage the Availability Group replica on the specified node. #### Examples -* [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) +* [Add a SQL Server Always On Availability Group](/source/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1) +* [Add a SQL Server Always On Availability Group and explicitly defines its properties](/source/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1) +* [Remove a SQL Server Always On Availability Group](/source/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAG). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAG). ### SqlAGDatabase @@ -315,13 +279,13 @@ group. #### Examples -* [Add a database to an Availability Group](/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1) -* [Remove a database from an Availability Group](/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1) -* [Enforce only specified databases as member in an Availability Group](/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1) +* [Add a database to an Availability Group](/source/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1) +* [Remove a database from an Availability Group](/source/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1) +* [Enforce only specified databases as member in an Availability Group](/source/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAGDatabase). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAGDatabase). ### SqlAgentAlert @@ -346,12 +310,12 @@ update the severity or message id. #### Examples -* [Add a SQL Agent Alert](/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1) -* [Remove a SQL Agent Alert](/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1) +* [Add a SQL Agent Alert](/source/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1) +* [Remove a SQL Agent Alert](/source/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAgentAlert). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAgentAlert). ### SqlAgentFailsafe @@ -376,12 +340,12 @@ update the Notification method. #### Examples -* [Add SQL Agent Failsafe Operator](/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1) -* [Remove SQL Agent Failsafe Operator](/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1) +* [Add SQL Agent Failsafe Operator](/source/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1) +* [Remove SQL Agent Failsafe Operator](/source/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAgentFailsafe). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAgentFailsafe). ### SqlAgentOperator @@ -406,12 +370,12 @@ the operators email address. #### Examples -* [Add a SQL Agent Operator](/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1) -* [Remove a SQL Agent Operator](/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1) +* [Add a SQL Agent Operator](/source/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1) +* [Remove a SQL Agent Operator](/source/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAgentOperator). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAgentOperator). ### SqlAGListener @@ -448,16 +412,16 @@ No description. #### Examples -* [Adds an Availability Group listener with the same name as the 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/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1) -* [Removes an Availability Group listener with the same name as the 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/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) +* [Adds an Availability Group listener with the same name as the Availability Group VCO](/source/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1) +* [Adds an Availability Group listener with a different name than the Availability Group VCO](/source/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1) +* [Removes an Availability Group listener with the same name as the Availability Group VCO](/source/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1) +* [Removes an Availability Group listener with a different name than the Availability Group VCO](/source/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1) +* [Adds an Availability Group listener using DHCP on the default server subnet](/source/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1) +* [Adds an Availability Group listener using DHCP with a specific subnet](/source/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAGListener). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAGListener). ### SqlAGReplica @@ -527,12 +491,12 @@ Always On Availability Group Replica. #### Examples -* [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) +* [Add a SQL Server Always On Availability Group Replica](/source/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1) +* [Remove a SQL Server Always On Availability Group Replica](/source/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAGReplica). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAGReplica). ### SqlAlias @@ -564,12 +528,12 @@ No description. #### Examples -* [Add an SQL Server alias](/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1) -* [Remove an SQL Server alias](/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1) +* [Add an SQL Server alias](/source/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1) +* [Remove an SQL Server alias](/source/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAlias). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAlias). ### SqlAlwaysOnService @@ -598,12 +562,12 @@ Enables or disabled SQL Server Always On high availability and disaster recovery #### Examples -* [Enable SQL Server Always On](/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1) -* [Disable SQL Server Always On](/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1) +* [Enable SQL Server Always On](/source/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1) +* [Disable SQL Server Always On](/source/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAlwaysOnService). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAlwaysOnService). ### SqlDatabase @@ -628,12 +592,12 @@ and [Delete a Database](https://docs.microsoft.com/en-us/sql/relational-database #### Examples -* [Create a Database](/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1) -* [Delete a database](/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1) +* [Create a Database](/source/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1) +* [Delete a database](/source/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabase). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabase). ### SqlDatabaseDefaultLocation @@ -669,11 +633,11 @@ more information about database default locations, please read the article #### Examples -* [Set database default locations](/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1) +* [Set database default locations](/source/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseDefaultLocation). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseDefaultLocation). ### SqlDatabaseOwner @@ -696,11 +660,11 @@ For more information about database owner, please read the article #### Examples -* [Set database owner](/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1) +* [Set database owner](/source/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseOwner). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseOwner). ### SqlDatabasePermission @@ -736,13 +700,13 @@ will also get their permission revoked. #### Examples -* [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) +* [Grant Database Permission](/source/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1) +* [Revoke Database Permission](/source/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1) +* [Deny Database Permission](/source/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabasePermission). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabasePermission). ### SqlDatabaseRecoveryModel @@ -768,11 +732,11 @@ Read more about recovery model in this article #### Examples -* [Set the RecoveryModel of a database](/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1) +* [Set the RecoveryModel of a database](/source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseRecoveryModel). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseRecoveryModel). ### SqlDatabaseRole @@ -814,16 +778,16 @@ manages members in both built-in and user created database roles. #### Examples -* [Add Role to a database](/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1) -* [Remove Role from a database](/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1) -* [Enforce Role membership](/Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1) -* [Members to include in database role](/Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1) -* [Members to exclude from database role](/Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1) -* [Members to include and exclude in a database role](/Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1) +* [Add Role to a database](/source/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1) +* [Remove Role from a database](/source/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1) +* [Enforce Role membership](/source/Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1) +* [Members to include in database role](/source/Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1) +* [Members to exclude from database role](/source/Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1) +* [Members to include and exclude in a database role](/source/Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseRole). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseRole). ### SqlDatabaseUser @@ -885,15 +849,15 @@ SQL login. #### Examples -* [Add a database user to a database, with a SQL login](/Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1) -* [Add a database user to a database, without a SQL login](/Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1) -* [Add a database user to a database, mapped to an asymmetric key](/Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1) -* [Add a database user to a database, mapped to a certificate](/Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1) -* [Remove database user from a database](/Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1) +* [Add a database user to a database, with a SQL login](/source/Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1) +* [Add a database user to a database, without a SQL login](/source/Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1) +* [Add a database user to a database, mapped to an asymmetric key](/source/Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1) +* [Add a database user to a database, mapped to a certificate](/source/Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1) +* [Remove database user from a database](/source/Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseUser). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseUser). ### SqlRS @@ -941,18 +905,18 @@ Initializes and configures SQL Reporting Services server. #### Examples -* [Default configuration](Examples/Resources/SqlRS/1-DefaultConfiguration.ps1) -* [Custom virtual directories and reserved URLs](Examples/Resources/SqlRS/2-CustomConfiguration.ps1) -* [Custom virtual directory and using SSL](Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1) -* [Complete example with two instances in default configuration](/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1) +* [Default configuration](/source/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1) +* [Custom virtual directories and reserved URLs](/source/Examples/Resources/SqlRS/2-CustomConfiguration.ps1) +* [Custom virtual directory and using SSL](/source/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1) +* [Complete example with two instances in default configuration](/source/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1) #### Known issues * This resource does not currently have full SSL support, please see - [issue #587](https://github.com/PowerShell/SqlServerDsc/issues/587) for more + [issue #587](https://github.com/dsccommunity/SqlServerDsc/issues/587) for more information. -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlRS). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlRS). #### Error messages @@ -1062,14 +1026,14 @@ used, then the installation will run as SYSTEM. #### Examples -* [Install Reporting Services](Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1) -* [Uninstall Reporting Services](Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1) +* [Install Reporting Services](/source/Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1) +* [Uninstall Reporting Services](/source/Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1) #### Known issues -* [SqlRSSetup: Will always make an edition upgrade](https://github.com/PowerShell/SqlServerDsc/issues/1311) +* [SqlRSSetup: Will always make an edition upgrade](https://github.com/dsccommunity/SqlServerDsc/issues/1311) -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlRSSetup). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlRSSetup). ### SqlScript @@ -1102,7 +1066,7 @@ 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/SqlServerDsc/issues/273) +See [issue #273](https://github.com/dsccommunity/SqlServerDsc/issues/273) for more information._ #### Parameters @@ -1141,13 +1105,13 @@ for more information._ #### Examples -* [Run a script using SQL Authentication](/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1) -* [Run a script using Windows Authentication](/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1) -* [This example shows one way to create the SQL script files and how to run those files](/Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1) +* [Run a script using SQL Authentication](/source/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1) +* [Run a script using Windows Authentication](/source/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1) +* [This example shows one way to create the SQL script files and how to run those files](/source/Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlScript). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlScript). ### SqlScriptQuery @@ -1215,13 +1179,13 @@ The Set T-SQL script performs the actual change when Test T-SQL script fails. #### Examples -* [Run a script using SQL Authentication](/Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1) -* [Run a script using Windows Authentication](/Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1) -* [This example shows one way to create the SQL script files and how to run those files](/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1) +* [Run a script using SQL Authentication](/source/Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1) +* [Run a script using Windows Authentication](/source/Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1) +* [This example shows one way to create the SQL script files and how to run those files](/source/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlScript). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlScript). ### SqlServerConfiguration @@ -1249,12 +1213,12 @@ on a SQL Server instance. #### Examples -* [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) +* [Configure two instances on the same server to have CLR enabled](/source/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1) +* [Configure a instance to have 'Priority Boost' enabled](/source/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerConfiguration). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerConfiguration). ### SqlServerDatabaseMail @@ -1299,12 +1263,12 @@ Resource to manage SQL Server Database Mail. #### Examples -* [Enable Database Mail](/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1) -* [Disable Database Mail](/Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1) +* [Enable Database Mail](/source/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1) +* [Disable Database Mail](/source/Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerDatabaseMail). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerDatabaseMail). ### SqlServerEndpoint @@ -1343,13 +1307,13 @@ the resource [**SqlServerEndpointPermission**](#sqlserverendpointpermission). #### Examples -* [Create an endpoint with default values](/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1) -* [Create an endpoint with specific port and IP address](/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1) -* [Remove an endpoint](/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1) +* [Create an endpoint with default values](/source/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1) +* [Create an endpoint with specific port and IP address](/source/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1) +* [Remove an endpoint](/source/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerEndpoint). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerEndpoint). ### SqlServerEndpointPermission @@ -1373,14 +1337,14 @@ This resource is used to give connect permission to an endpoint for a user (logi #### Examples -* [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/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.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/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1) +* [Add connect permission to an Endpoint](/source/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1) +* [Remove the connect permission for an Endpoint](/source/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](/source/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.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](/source/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerEndpointPermission). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerEndpointPermission). ### SqlServerEndpointState @@ -1407,12 +1371,12 @@ This resource is used to set the state of an endpoint. #### Examples -* [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) +* [Make sure that an endpoint is started](/source/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1) +* [Make sure that an endpoint is stopped](/source/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerEndpointState). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerEndpointState). ### SqlServerLogin @@ -1453,12 +1417,12 @@ No description. #### Examples -* [Add a login](/Examples/Resources/SqlServerLogin/1-AddLogin.ps1) -* [Remove a login](/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1) +* [Add a login](/source/Examples/Resources/SqlServerLogin/1-AddLogin.ps1) +* [Remove a login](/source/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerLogin). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerLogin). ### SqlServerMaxDop @@ -1510,13 +1474,13 @@ Read more about max degree of parallelism in this article #### Examples -* [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) +* [Set SQLServerMaxDop to 1](/source/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1) +* [Set SQLServerMaxDop to Auto](/source/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1) +* [Set SQLServerMaxDop to Default](/source/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerMaxDop). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerMaxDop). ### SqlServerMemory @@ -1589,14 +1553,14 @@ SQL Max Memory = TotalPhysicalMemory - (NumOfSQLThreads\*ThreadStackSize) - #### Examples -* [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/4-SetMaxMemoryToDefault.ps1) +* [Set SQLServerMaxMemory to 12GB](/source/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1) +* [Set SQLServerMaxMemory to Auto](/source/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1) +* [Set SQLServerMinMemory to 2GB and SQLServerMaxMemory to Auto](/source/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1) +* [Set SQLServerMaxMemory to Default](/source/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerMemory). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerMemory). ### SqlServerNetwork @@ -1635,12 +1599,12 @@ Read more about the network settings in the article #### Examples -* [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) +* [Enable TCP/IP with static port and restart SQL Server](/source/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1) +* [Enable TCP/IP with dynamic port](/source/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerNetwork). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerNetwork). ### SqlServerPermission @@ -1670,12 +1634,12 @@ AlterAnyEndPoint and ViewServerState. #### Examples -* [Add server permission for a login](/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1) -* [Remove server permission for a login](/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1) +* [Add server permission for a login](/source/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1) +* [Remove server permission for a login](/source/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerPermission). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerPermission). ### SqlServerReplication @@ -1710,12 +1674,12 @@ This resource manage SQL Replication distribution and publishing. #### Examples -* [Configure a instance as the distributor](/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1) -* [Configure a instance as the publisher](/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1) +* [Configure a instance as the distributor](/source/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1) +* [Configure a instance as the publisher](/source/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerReplication). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerReplication). ### SqlServerRole @@ -1753,15 +1717,15 @@ server roles, please read the below articles. #### Examples -* [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) +* [Add server role](/source/Examples/Resources/SqlServerRole/1-AddServerRole.ps1) +* [Remove server role](/source/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1) +* [Add members to server role](/source/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1) +* [Members to include in server role](/source/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1) +* [Members to exclude from server role](/source/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerRole). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerRole). ### SqlServerSecureConnection @@ -1806,14 +1770,14 @@ In that case, the 'SYSTEM' service account can be used. #### Examples -* [Force Secure Connection](Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1). -* [Secure Connection but not required](Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1). -* [Secure Connection disabled](Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1). -* [Secure Connection Using "SYSTEM" Account](/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1). +* [Force Secure Connection](/source/Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1). +* [Secure Connection but not required](/source/Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1). +* [Secure Connection disabled](/source/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1). +* [Secure Connection Using "SYSTEM" Account](/source/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1). #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerSecureConnection). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServerSecureConnection). ### SqlServiceAccount @@ -1850,12 +1814,12 @@ Manage the service account for SQL Server services. #### Examples -* [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) +* [Run service under a user account](/source/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1) +* [Run service with a virtual account](/source/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServiceAccount). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlServiceAccount). ### SqlSetup @@ -2071,17 +2035,17 @@ need a '*SVCPASSWORD' argument in the setup arguments. #### Examples -* [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) -* [Install a named instance with the Agent Service set to Disabled](/Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1) -* [Install a default instance on a single server (Sql Server 2016 or Later)](/Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1) +* [Install a default instance on a single server](/source/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1) +* [Install a named instance on a single server](/source/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1) +* [Install a named instance on a single server from an UNC path using SourceCredential](/source/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1) +* [Install a named instance as the first node in SQL Server Failover Cluster](/source/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1) +* [Install a named instance as the second node in SQL Server Failover Cluster](/source/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1) +* [Install a named instance with the Agent Service set to Disabled](/source/Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1) +* [Install a default instance on a single server (Sql Server 2016 or Later)](/source/Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlSetup). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlSetup). ### SqlWaitForAG @@ -2122,12 +2086,12 @@ or that it has finished creating the Availability Group. #### Examples -* [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) +* [Wait for a cluster role/group to be available](/source/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1) +* [Wait for multiple cluster roles/groups to be available](/source/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlWaitForAG). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlWaitForAG). ### SqlWindowsFirewall @@ -2211,9 +2175,9 @@ Port: tcp/135 | SQL Server Integration Services Port #### Examples -* [Create inbound firewall rules](/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1) -* [Remove inbound firewall rules](/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1) +* [Create inbound firewall rules](/source/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1) +* [Remove inbound firewall rules](/source/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1) #### Known issues -All issues are not listed here, see [here for all open issues](https://github.com/PowerShell/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlWindowsFirewall). +All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlWindowsFirewall). diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 new file mode 100644 index 000000000..a59563819 --- /dev/null +++ b/RequiredModules.psd1 @@ -0,0 +1,28 @@ +@{ + PSDependOptions = @{ + AddToPath = $true + Target = 'output\RequiredModules' + Parameters = @{ + } + } + + InvokeBuild = 'latest' + PSScriptAnalyzer = 'latest' + Pester = 'latest' + Plaster = 'latest' + ModuleBuilder = '1.0.0' + ChangelogManagement = 'latest' + Sampler = 'latest' + MarkdownLinkCheck = 'latest' + 'DscResource.Test' = 'latest' + 'DscResource.AnalyzerRules' = 'latest' + xDscResourceDesigner = 'latest' + + # Dependency for integration tests + LoopbackAdapter = 'latest' + + # Prerequisites modules needed for examples or integration tests + PSDscResources = '2.12.0.0' + StorageDsc = '4.9.0.0' + NetworkingDsc = '7.4.0.0' +} diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 new file mode 100644 index 000000000..4928e6242 --- /dev/null +++ b/Resolve-Dependency.ps1 @@ -0,0 +1,289 @@ +[CmdletBinding()] +param +( + + [Parameter()] + [String] + $DependencyFile = 'RequiredModules.psd1', + + [Parameter()] + [String] + # Path for PSDepend to be bootstrapped and save other dependencies. + # Can also be CurrentUser or AllUsers if you wish to install the modules in such scope + # Default to $PWD.Path/output/modules + $PSDependTarget = (Join-Path $PSScriptRoot './output/RequiredModules'), + + [Parameter()] + [uri] + # URI to use for Proxy when attempting to Bootstrap PackageProvider & PowerShellGet + $Proxy, + + [Parameter()] + # Credential to contact the Proxy when provided + [PSCredential]$ProxyCredential, + + [Parameter()] + [ValidateSet('CurrentUser', 'AllUsers')] + [String] + # Scope to bootstrap the PackageProvider and PSGet if not available + $Scope = 'CurrentUser', + + [Parameter()] + [String] + # Gallery to use when bootstrapping PackageProvider, PSGet and when calling PSDepend (can be overridden in Dependency files) + $Gallery = 'PSGallery', + + [Parameter()] + [PSCredential] + # Credentials to use with the Gallery specified above + $GalleryCredential, + + + [Parameter()] + [switch] + # Allow you to use a locally installed version of PowerShellGet older than 1.6.0 (not recommended, default to $False) + $AllowOldPowerShellGetModule, + + [Parameter()] + [String] + # Allow you to specify a minimum version fo PSDepend, if you're after specific features. + $MinimumPSDependVersion, + + [Parameter()] + [Switch] + $AllowPrerelease, + + [Parameter()] + [Switch] + $WithYAML +) + +# Load Defaults for parameters values from Resolve-Dependency.psd1 if not provided as parameter +try +{ + Write-Verbose -Message "Importing Bootstrap default parameters from '$PSScriptRoot/Resolve-Dependency.psd1'." + $ResolveDependencyDefaults = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1' -Resolve -ErrorAction Stop) + $ParameterToDefault = $MyInvocation.MyCommand.ParameterSets.Where{ $_.Name -eq $PSCmdlet.ParameterSetName }.Parameters.Keys + if ($ParameterToDefault.Count -eq 0) + { + $ParameterToDefault = $MyInvocation.MyCommand.Parameters.Keys + } + # Set the parameters available in the Parameter Set, or it's not possible to choose yet, so all parameters are an option + foreach ($ParamName in $ParameterToDefault) + { + if (-Not $PSBoundParameters.Keys.Contains($ParamName) -and $ResolveDependencyDefaults.ContainsKey($ParamName)) + { + Write-Verbose -Message "Setting $ParamName with $($ResolveDependencyDefaults[$ParamName])" + try + { + $variableValue = $ResolveDependencyDefaults[$ParamName] + if ($variableValue -is [string]) + { + $variableValue = $ExecutionContext.InvokeCommand.ExpandString($variableValue) + } + $PSBoundParameters.Add($ParamName, $variableValue) + Set-Variable -Name $ParamName -value $variableValue -Force -ErrorAction SilentlyContinue + } + catch + { + Write-Verbose -Message "Error adding default for $ParamName : $($_.Exception.Message)" + } + } + } +} +catch +{ + Write-Warning -Message "Error attempting to import Bootstrap's default parameters from $(Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1'): $($_.Exception.Message)." +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 0 -CurrentOperation "NuGet Bootstrap" + +if (!(Get-PackageProvider -Name NuGet -ForceBootstrap -ErrorAction SilentlyContinue)) +{ + $providerBootstrapParams = @{ + Name = 'nuget' + force = $true + ForceBootstrap = $true + ErrorAction = 'Stop' + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $providerBootstrapParams.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $providerBootstrapParams.Add('ProxyCredential', $ProxyCredential) + } + 'Scope' + { + $providerBootstrapParams.Add('Scope', $Scope) + } + } + + if ($AllowPrerelease) + { + $providerBootstrapParams.Add('AllowPrerelease', $true) + } + + Write-Information "Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed)" + $null = Install-PackageProvider @providerBootstrapParams + $latestNuGetVersion = (Get-PackageProvider -Name NuGet -ListAvailable | Select-Object -First 1).Version.ToString() + Write-Information "Bootstrap: Importing NuGet Package Provider version $latestNuGetVersion to current session." + $Null = Import-PackageProvider -Name NuGet -RequiredVersion $latestNuGetVersion -Force +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 10 -CurrentOperation "Ensuring Gallery $Gallery is trusted" + +# Fail if the given PSGallery is not Registered +$Policy = (Get-PSRepository $Gallery -ErrorAction Stop).InstallationPolicy +Set-PSRepository -Name $Gallery -InstallationPolicy Trusted -ErrorAction Ignore +try +{ + Write-Progress -Activity "Bootstrap:" -PercentComplete 25 -CurrentOperation "Checking PowerShellGet" + # Ensure the module is loaded and retrieve the version you have + $PowerShellGetVersion = (Import-Module PowerShellGet -PassThru -ErrorAction SilentlyContinue).Version + + Write-Verbose "Bootstrap: The PowerShellGet version is $PowerShellGetVersion" + # Versions below 1.6.0 are considered old, unreliable & not recommended + if (!$PowerShellGetVersion -or ($PowerShellGetVersion -lt [System.version]'1.6.0' -and !$AllowOldPowerShellGetModule)) + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 40 -CurrentOperation "Installing newer version of PowerShellGet" + $InstallPSGetParam = @{ + Name = 'PowerShellGet' + Force = $True + SkipPublisherCheck = $true + AllowClobber = $true + Scope = $Scope + Repository = $Gallery + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $InstallPSGetParam.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $InstallPSGetParam.Add('ProxyCredential', $ProxyCredential) + } + 'GalleryCredential' + { + $InstallPSGetParam.Add('Credential', $GalleryCredential) + } + } + + Install-Module @InstallPSGetParam + Remove-Module PowerShellGet -force -ErrorAction SilentlyContinue + Import-Module PowerShellGet -Force + $NewLoadedVersion = (Get-Module PowerShellGet).Version.ToString() + Write-Information "Bootstrap: PowerShellGet version loaded is $NewLoadedVersion" + Write-Progress -Activity "Bootstrap:" -PercentComplete 60 -CurrentOperation "Installing newer version of PowerShellGet" + } + + # Try to import the PSDepend module from the available modules + try + { + $ImportPSDependParam = @{ + Name = 'PSDepend' + ErrorAction = 'Stop' + Force = $true + } + + if ($MinimumPSDependVersion) + { + $ImportPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + $null = Import-Module @ImportPSDependParam + } + catch + { + # PSDepend module not found, installing or saving it + if ($PSDependTarget -in 'CurrentUser', 'AllUsers') + { + Write-Debug "PSDepend module not found. Attempting to install from Gallery $Gallery" + Write-Warning "Installing PSDepend in $PSDependTarget Scope" + $InstallPSDependParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Force = $true + Scope = $PSDependTarget + SkipPublisherCheck = $true + AllowClobber = $true + } + + if ($MinimumPSDependVersion) + { + $InstallPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Installing PSDepend from $Gallery" + Install-Module @InstallPSDependParam + } + else + { + Write-Debug "PSDepend module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Path = $PSDependTarget + } + + if ($MinimumPSDependVersion) + { + $SaveModuleParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Saving & Importing PSDepend from $Gallery to $Scope" + Save-Module @SaveModuleParam + } + } + finally + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 100 -CurrentOperation "Loading PSDepend" + # We should have successfully bootstrapped PSDepend. Fail if not available + Import-Module PSDepend -ErrorAction Stop + } + + if ($WithYAML) + { + if (-Not (Get-Module -ListAvailable -Name 'PowerShell-Yaml')) + { + Write-Verbose "PowerShell-Yaml module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PowerShell-Yaml' + Repository = $Gallery + Path = $PSDependTarget + } + + Save-Module @SaveModuleParam + Import-Module "PowerShell-Yaml" -ErrorAction Stop + } + else + { + Write-Verbose "PowerShell-Yaml is already available" + } + } + + Write-Progress -Activity "PSDepend:" -PercentComplete 0 -CurrentOperation "Restoring Build Dependencies" + if (Test-Path $DependencyFile) + { + $PSDependParams = @{ + Force = $true + Path = $DependencyFile + } + + # TODO: Handle when the Dependency file is in YAML, and -WithYAML is specified + Invoke-PSDepend @PSDependParams + } + Write-Progress -Activity "PSDepend:" -PercentComplete 100 -CurrentOperation "Dependencies restored" -Completed +} +finally +{ + # Reverting the Installation Policy for the given gallery + Set-PSRepository -Name $Gallery -InstallationPolicy $Policy + Write-Verbose "Project Bootstrapped, returning to Invoke-Build" +} diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 new file mode 100644 index 000000000..2ae8c0dac --- /dev/null +++ b/Resolve-Dependency.psd1 @@ -0,0 +1,5 @@ +@{ + Gallery = 'PSGallery' + AllowPrerelease = $false + WithYAML = $true +} diff --git a/SqlServerDsc.psd1 b/SqlServerDsc.psd1 deleted file mode 100644 index 6394532bd..000000000 --- a/SqlServerDsc.psd1 +++ /dev/null @@ -1,86 +0,0 @@ -@{ - # Version number of this module. - moduleVersion = '13.2.0.0' - - # ID used to uniquely identify this module - GUID = '693ee082-ed36-45a7-b490-88b07c86b42f' - - # Author of this module - Author = 'Microsoft Corporation' - - # Company or vendor of this module - CompanyName = 'Microsoft Corporation' - - # Copyright statement for this module - Copyright = '(c) 2018 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 SqlServerDsc - - Fix keywords to lower-case to align with guideline. - - Fix keywords to have space before a parenthesis to align with guideline. - -' - - } # End of PSData hashtable - - } # End of PrivateData hashtable - } - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7abad0b23..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,130 +0,0 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# -version: 9.0.{build}.0 -environment: - gallery_api: - secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv - # The job where deploy step should run (normally the last job) - DeployInJobNumber: 4 - -# The image that will be used when building the job matrix. -image: Visual Studio 2017 - -# The configuration that will be used when building the job matrix. -# Meta = Test Framework Common Test -# Unit = Module Unit Tests. -# Integration = Module Integration Tests. -configuration: - - Meta - - Unit - - Integration_SQL2016 - - Integration_SQL2017 - -install: - - git clone https://github.com/PowerShell/DscResource.Tests - - ps: Write-Verbose -Message "PowerShell version $($PSVersionTable.PSVersion)" -Verbose - - ps: Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - - ps: Invoke-AppveyorInstallTask - -#---------------------------------# -# build configuration # -#---------------------------------# - -build: false - -#---------------------------------# -# test configuration # -#---------------------------------# - -# This will build the job matrix -# -# Job 1: Run meta test (common tests) on image Visual Studio 2017. -# Job 2: Run unit tests on image Visual Studio 2017, including Codecov report. -# Job 3: Run integration tests on image Visual Studio 2017. - -for: -- - matrix: - only: - - configuration: Meta - - test_script: - - ps: | - Invoke-AppveyorTestScriptTask -ExcludeTag @() - -- - matrix: - only: - - configuration: Integration_SQL2016 - - configuration: Integration_SQL2017 - environment: - SkipAllCommonTests: True - - test_script: - - ps: | - Write-Verbose -Message '--- WORKAROUND FOR ISSUE #239 AND ISSUE #774 ---' -Verbose - $sqlModules = Get-Module -ListAvailable -Name 'sql*' - $sqlUniqueModulePath = Split-Path -Path (Split-Path $sqlModules.Path -Parent) -Parent | Sort-Object -Unique - $sqlUniqueModulePath | ForEach-Object -Process { - $newFolderName = '{0}.old' -f (Split-Path -Path $_ -Leaf) - Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose - Rename-Item $_ -NewName $newFolderName -Force - } - Write-Verbose -Message '' -Verbose - # Workaround for issue #798 - Write-Verbose -Message '--- WORKAROUND FOR ISSUE #798 ---' -Verbose - $azureModules = Get-Module -ListAvailable -Name 'Azure*' | Where-Object -FilterScript { $_.Name -notlike 'AzureRm*' } - $azureUniqueModulePath = Split-Path -Path (Split-Path $azureModules.Path -Parent) -Parent | Sort-Object -Unique - $azureUniqueModulePath | ForEach-Object -Process { - $newFolderName = '{0}.old' -f (Split-Path -Path $_ -Leaf) - Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose - Rename-Item $_ -NewName $newFolderName -Force - } - Write-Verbose -Message '' -Verbose - - Invoke-AppveyorTestScriptTask -ExcludeTag @() -RunTestInOrder - -- - matrix: - only: - - configuration: Unit - environment: - SkipAllCommonTests: True - - test_script: - - ps: | - # Workaround for issue #239 and issue #774. - Write-Verbose -Message '--- WORKAROUND FOR ISSUE #239 AND ISSUE #774 ---' -Verbose - $sqlModules = Get-Module -ListAvailable -Name 'sql*' - $sqlUniqueModulePath = Split-Path -Path (Split-Path $sqlModules.Path -Parent) -Parent | Sort-Object -Unique - $sqlUniqueModulePath | ForEach-Object -Process { - $newFolderName = '{0}.old' -f (Split-Path -Path $_ -Leaf) - Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose - Rename-Item $_ -NewName $newFolderName -Force - } - Write-Verbose -Message '' -Verbose - - Invoke-AppveyorTestScriptTask -CodeCoverage -CodeCovIo -ExcludeTag @() -RunTestInOrder - -# Runs for all jobs. -after_test: - - ps: | - Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorAfterTestTask - -#---------------------------------# -# deployment configuration # -#---------------------------------# - -# Runs only in a branch (not in PR). -deploy_script: - - ps: | - if ($env:APPVEYOR_JOB_NUMBER -eq $env:DeployInJobNumber) - { - Invoke-AppVeyorDeployTask - } - else - { - Write-Verbose -Message ('Skipping deploy step. Deploy step was requested to run in job number {0}. Current job number is {1}.' -f $env:DeployInJobNumber, $env:APPVEYOR_JOB_NUMBER) -Verbose - } diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..e071aba96 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,255 @@ +trigger: + branches: + include: + - master + tags: + include: + - "v*" + exclude: + - "*-*" + +stages: + - stage: Build + jobs: + - job: BuildModuleJob + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: GitVersion@5 + name: gitversion + inputs: + runtime: 'core' + configFilePath: 'GitVersion.yml' + + - task: PowerShell@2 + name: Build + inputs: + filePath: './build.ps1' + arguments: '-ResolveDependency -tasks pack' + pwsh: true + env: + ModuleVersion: $(GitVersion.Informationalversion) + + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: 'output/' + ArtifactName: 'output' + publishLocation: 'Container' + + - stage: Test + dependsOn: Build + jobs: + - job: Test_HQRM + pool: + vmImage: 'win1803' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: Test + inputs: + filePath: './build.ps1' + arguments: '-Tasks hqrmtest' + pwsh: false + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'HQRM' + + - job: Test_Unit + pool: + vmImage: 'win1803' + timeoutInMinutes: 0 + steps: + - powershell: | + $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + name: DscBuildVariable + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: Test + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Unit'" + pwsh: false + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Unit (Windows Server Core)' + - task: PublishCodeCoverageResults@1 + condition: succeededOrFailed() + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: 'output/testResults/CodeCov*.xml' + pathToSources: '$(Build.SourcesDirectory)/output/$(DscBuildVariable.RepositoryName)' + + - job: Test_Integration_SQL2016 + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + variables: + # This sets environment variable $env:CI. + CI: true + # This sets environment variable $env:CONFIGURATION. + configuration: Integration_SQL2016 + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: ConfigureWinRM + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterScript @( + # Run the integration tests in a specific group order. + # Group 1 + 'tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1' + # Group 2 + 'tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1' + # Group 3 + 'tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlRS.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1' + # Group 4 + 'tests/Integration/MSFT_SqlScript.Integration.Tests.ps1' + # Group 5 + 'tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1' + ) + name: Test + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (SQL Server 2016 / Windows Server 2019)' + + - job: Test_Integration_SQL2017 + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + variables: + # This sets environment variable $env:CI. + CI: true + # This sets environment variable $env:CONFIGURATION. + configuration: Integration_SQL2017 + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: ConfigureWinRM + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterScript @( + # Run the integration tests in a specific group order. + # Group 1 + 'tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1' + # Group 2 + 'tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1' + # Group 3 + 'tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlRS.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1' + # Group 4 + 'tests/Integration/MSFT_SqlScript.Integration.Tests.ps1' + # Group 5 + 'tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1' + 'tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1' + ) + name: Test + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (SQL Server 2017 / Windows Server 2019)' + + - stage: Deploy + dependsOn: Test + # Only execute deploy stage if we're on master and previous stage succeeded + condition: | + and( + succeeded(), + or( + eq(variables['Build.SourceBranch'], 'refs/heads/master'), + startsWith(variables['Build.SourceBranch'], 'refs/tags/') + ) + ) + jobs: + - job: Deploy_Artefact + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: publish_prerelease + inputs: + filePath: './build.ps1' + arguments: '-tasks publish' + pwsh: true + env: + GitHubToken: $(GitHubToken) + GalleryApiToken: $(GalleryApiToken) + - task: PowerShell@2 + name: send_changelog_PR + inputs: + filePath: './build.ps1' + arguments: '-tasks Create_ChangeLog_GitHub_PR' + pwsh: true + env: + GitHubToken: $(GitHubToken) diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 000000000..a94f13bdd --- /dev/null +++ b/build.ps1 @@ -0,0 +1,353 @@ +<# + +.DESCRIPTION + Bootstrap and build script for PowerShell module pipeline + +#> +[CmdletBinding()] +param +( + [Parameter(Position = 0)] + [string[]]$Tasks = '.', + + [Parameter()] + [String] + $CodeCoverageThreshold = '', + + [Parameter()] + [validateScript( + { Test-Path -Path $_ } + )] + $BuildConfig = './build.yaml', + + [Parameter()] + # A Specific folder to build the artefact into. + $OutputDirectory = 'output', + + [Parameter()] + # Subdirectory name to build the module (under $OutputDirectory) + $BuiltModuleSubdirectory = '', + + # Can be a path (relative to $PSScriptRoot or absolute) to tell Resolve-Dependency & PSDepend where to save the required modules, + # or use CurrentUser, AllUsers to target where to install missing dependencies + # You can override the value for PSDepend in the Build.psd1 build manifest + # This defaults to $OutputDirectory/modules (by default: ./output/modules) + [Parameter()] + $RequiredModulesDirectory = $(Join-Path 'output' 'RequiredModules'), + + # Filter which tags to run when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterTag, + + [Parameter()] + [string[]] + $PesterScript, + + # Filter which tags to exclude when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterExcludeTag, + + [Parameter()] + [Alias('bootstrap')] + [switch]$ResolveDependency, + + [Parameter(DontShow)] + [AllowNull()] + $BuildInfo, + + [Parameter()] + [switch] + $AutoRestore +) + +# The BEGIN block (at the end of this file) handles the Bootstrap of the Environment before Invoke-Build can run the tasks +# if the -ResolveDependency (aka Bootstrap) is specified, the modules are already available, and can be auto loaded + +process +{ + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + # Only run the process block through InvokeBuild (Look at the Begin block at the bottom of this script) + return + } + + # Execute the Build Process from the .build.ps1 path. + Push-Location -Path $PSScriptRoot -StackName BeforeBuild + + try + { + Write-Host -ForeGroundColor magenta "[build] Parsing defined tasks" + + # Load Default BuildInfo if not provided as parameter + if (!$PSBoundParameters.ContainsKey('BuildInfo')) + { + try + { + if (Test-Path $BuildConfig) + { + $ConfigFile = (Get-Item -Path $BuildConfig) + Write-Host "[build] Loading Configuration from $ConfigFile" + $BuildInfo = switch -Regex ($ConfigFile.Extension) + { + # Native Support for PSD1 + '\.psd1' + { + Import-PowerShellDataFile -Path $BuildConfig + } + # Support for yaml when module PowerShell-Yaml is available + '\.[yaml|yml]' + { + Import-Module -ErrorAction Stop -Name 'powershell-yaml' + ConvertFrom-Yaml -Yaml (Get-Content -Raw $ConfigFile) + } + # Native Support for JSON and JSONC (by Removing comments) + '\.[json|jsonc]' + { + $JSONC = (Get-Content -Raw -Path $ConfigFile) + $JSON = $JSONC -replace '(?m)\s*//.*?$' -replace '(?ms)/\*.*?\*/' + # This should probably be converted to hashtable for splatting + $JSON | ConvertFrom-Json + } + default + { + Write-Error "Extension '$_' not supported. using @{}" + @{ } + } + } + } + else + { + Write-Host -Object "Configuration file $BuildConfig not found" -ForegroundColor Red + $BuildInfo = @{ } + } + } + catch + { + Write-Host -Object "Error loading Config $ConfigFile.`r`n Are you missing dependencies?" -ForegroundColor Yellow + Write-Host -Object "Make sure you run './build.ps1 -ResolveDependency -tasks noop' to restore the Required modules the first time" -ForegroundColor Yellow + $BuildInfo = @{ } + Write-Error $_.Exception.Message + } + } + + # If the Invoke-Build Task Header is specified in the Build Info, set it + if ($BuildInfo.TaskHeader) + { + Set-BuildHeader ([scriptblock]::Create($BuildInfo.TaskHeader)) + } + + # Import Tasks from modules via their exported aliases when defined in BUild Manifest + # https://github.com/nightroman/Invoke-Build/tree/master/Tasks/Import#example-2-import-from-a-module-with-tasks + if ($BuildInfo.containsKey('ModuleBuildTasks')) + { + foreach ($Module in $BuildInfo['ModuleBuildTasks'].Keys) + { + try + { + Write-Host -ForegroundColor DarkGray -Verbose "Importing tasks from module $Module" + $LoadedModule = Import-Module $Module -PassThru -ErrorAction Stop + foreach ($TaskToExport in $BuildInfo['ModuleBuildTasks'].($Module)) + { + $LoadedModule.ExportedAliases.GetEnumerator().Where{ + # using -like to support wildcard + Write-Host -ForegroundColor DarkGray "`t Loading $($_.Key)..." + $_.Key -like $TaskToExport + }.ForEach{ + # Dot sourcing the Tasks via their exported aliases + . (Get-Alias $_.Key) + } + } + } + catch + { + Write-Host -ForegroundColor Red -Object "Could not load tasks for module $Module." + Write-Error $_ + } + } + } + + # Loading Build Tasks defined in the .build/ folder (will override the ones imported above if same task name) + Get-ChildItem -Path ".build/" -Recurse -Include *.ps1 -ErrorAction Ignore | ForEach-Object { + "Importing file $($_.BaseName)" | Write-Verbose + . $_.FullName + } + + # Synopsis: Empty task, useful to test the bootstrap process + task noop { } + + # Define default task sequence ("."), can be overridden in the $BuildInfo + task . { + Write-Build Yellow "No sequence currently defined for the default task" + } + + # Load Invoke-Build task sequences/workflows from $BuildInfo + Write-Host -ForegroundColor DarkGray "Adding Workflow from configuration:" + foreach ($Workflow in $BuildInfo.BuildWorkflow.keys) + { + Write-Verbose "Creating Build Workflow '$Workflow' with tasks $($BuildInfo.BuildWorkflow.($Workflow) -join ', ')" + $WorkflowItem = $BuildInfo.BuildWorkflow.($Workflow) + if ($WorkflowItem.Trim() -match '^\{(?[\w\W]*)\}$') + { + $WorkflowItem = [ScriptBlock]::Create($Matches['sb']) + } + Write-Host -ForegroundColor DarkGray " +-> $Workflow" + task $Workflow $WorkflowItem + } + + Write-Host -ForeGroundColor magenta "[build] Executing requested workflow: $($Tasks -join ', ')" + + } + finally + { + Pop-Location -StackName BeforeBuild + } +} + +Begin +{ + # Bootstrapping the environment before using Invoke-Build as task runner + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Host -foregroundColor Green "[pre-build] Starting Build Init" + Push-Location $PSScriptRoot -StackName BuildModule + } + + if ($RequiredModulesDirectory -in @('CurrentUser', 'AllUsers')) + { + # Installing modules instead of saving them + Write-Host -foregroundColor Green "[pre-build] Required Modules will be installed for $RequiredModulesDirectory, not saved." + # Tell Resolve-Dependency to use provided scope as the -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesDirectory + } + else + { + if (-Not (Split-Path -IsAbsolute -Path $OutputDirectory)) + { + $OutputDirectory = Join-Path -Path $PSScriptRoot -ChildPath $OutputDirectory + } + + # Resolving the absolute path to save the required modules to + if (-Not (Split-Path -IsAbsolute -Path $RequiredModulesDirectory)) + { + $RequiredModulesDirectory = Join-Path -Path $PSScriptRoot -ChildPath $RequiredModulesDirectory + } + + # Create the output/modules folder if not exists, or resolve the Absolute path otherwise + if (Resolve-Path $RequiredModulesDirectory -ErrorAction SilentlyContinue) + { + Write-Debug "[pre-build] Required Modules path already exist at $RequiredModulesDirectory" + $RequiredModulesPath = Convert-Path $RequiredModulesDirectory + } + else + { + Write-Host -foregroundColor Green "[pre-build] Creating required modules directory $RequiredModulesDirectory." + $RequiredModulesPath = (New-Item -ItemType Directory -Force -Path $RequiredModulesDirectory).FullName + } + + # Prepending $RequiredModulesPath folder to PSModulePath to resolve from this folder FIRST + if ($RequiredModulesDirectory -notIn @('CurrentUser', 'AllUsers') -and + (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $RequiredModulesDirectory)) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$RequiredModulesDirectory' folder to PSModulePath" + $Env:PSModulePath = $RequiredModulesDirectory + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Checking if the user should -ResolveDependency + if ((!(Get-Module -ListAvailable powershell-yaml) -or !(Get-Module -ListAvailable InvokeBuild) -or !(Get-Module -ListAvailable PSDepend)) -and !$ResolveDependency) + { + if ($AutoRestore -or !$PSBoundParameters.ContainsKey('Tasks') -or $Tasks -contains 'build') + { + Write-Host -ForegroundColor Yellow "[pre-build] Dependency missing, running './build.ps1 -ResolveDependency -Tasks noop' for you `r`n" + $ResolveDependency = $true + } + else + { + Write-Warning "Some required Modules are missing, make sure you first run with the '-ResolveDependency' parameter." + Write-Warning "Running 'build.ps1 -ResolveDependency -Tasks noop' will pull required modules without running the build task." + } + } + + if ($BuiltModuleSubdirectory) + { + if (-Not (Split-Path -IsAbsolute $BuiltModuleSubdirectory)) + { + $BuildModuleOutput = Join-Path $OutputDirectory $BuiltModuleSubdirectory + } + else + { + $BuildModuleOutput = $BuiltModuleSubdirectory + } + } + else + { + $BuildModuleOutput = $OutputDirectory + } + + # Prepending $BuildModuleOutput folder to PSModulePath to resolve built module from this folder + if (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $BuildModuleOutput) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$BuildModuleOutput' folder to PSModulePath" + $Env:PSModulePath = $BuildModuleOutput + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Tell Resolve-Dependency to use $RequiredModulesPath as -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesPath + } + + if ($ResolveDependency) + { + Write-Host -Object "[pre-build] Resolving dependencies." -foregroundColor Green + $ResolveDependencyParams = @{ } + + # If BuildConfig is a Yaml file, bootstrap powershell-yaml via ResolveDependency + if ($BuildConfig -match '\.[yaml|yml]$') + { + $ResolveDependencyParams.add('WithYaml', $True) + } + + $ResolveDependencyAvailableParams = (Get-Command -Name '.\Resolve-Dependency.ps1').parameters.keys + foreach ($CmdParameter in $ResolveDependencyAvailableParams) + { + + # The parameter has been explicitly used for calling the .build.ps1 + if ($MyInvocation.BoundParameters.ContainsKey($CmdParameter)) + { + $ParamValue = $MyInvocation.BoundParameters.ContainsKey($CmdParameter) + Write-Debug " adding $CmdParameter :: $ParamValue [from user-provided parameters to Build.ps1]" + $ResolveDependencyParams.Add($CmdParameter, $ParamValue) + } + # Use defaults parameter value from Build.ps1, if any + else + { + if ($ParamValue = Get-Variable -Name $CmdParameter -ValueOnly -ErrorAction Ignore) + { + Write-Debug " adding $CmdParameter :: $ParamValue [from default Build.ps1 variable]" + $ResolveDependencyParams.add($CmdParameter, $ParamValue) + } + } + } + + Write-Host -foregroundColor Green "[pre-build] Starting bootstrap process." + .\Resolve-Dependency.ps1 @ResolveDependencyParams + } + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Verbose "Bootstrap completed. Handing back to InvokeBuild." + if ($PSBoundParameters.ContainsKey('ResolveDependency')) + { + Write-Verbose "Dependency already resolved. Removing task" + $null = $PSBoundParameters.Remove('ResolveDependency') + } + Write-Host -foregroundColor Green "[build] Starting build with InvokeBuild." + Invoke-Build @PSBoundParameters -Task $Tasks -File $MyInvocation.MyCommand.Path + Pop-Location -StackName BuildModule + return + } +} diff --git a/build.yaml b/build.yaml new file mode 100644 index 000000000..3faf33b65 --- /dev/null +++ b/build.yaml @@ -0,0 +1,88 @@ +--- +#################################################### +# ModuleBuilder Configuration # +#################################################### +CopyDirectories: + - DSCResources + - en-US + - Modules +Encoding: UTF8 +VersionedOutputDirectory: true + +#################################################### +# Pipeline Configuration # +#################################################### +BuildWorkflow: + '.': + - build + - test + + build: + - Clean + - Build_Module_ModuleBuilder + - Build_NestedModules_ModuleBuilder + - Create_changelog_release_output + + pack: + - build + - package_module_nupkg + + hqrmtest: + - DscResource_Tests_Stop_On_Fail + + test: + - Pester_Tests_Stop_On_Fail + - Pester_if_Code_Coverage_Under_Threshold + + publish: + - Publish_release_to_GitHub + - publish_module_to_gallery + + +#################################################### +# PESTER Configuration # +#################################################### + +Pester: + OutputFormat: NUnitXML + ExcludeFromCodeCoverage: + Script: + - tests/Unit + ExcludeTag: + Tag: + CodeCoverageThreshold: 85 + +DscTest: + ExcludeTag: + - "Common Tests - New Error-Level Script Analyzer Rules" + Tag: + ExcludeSourceFile: + - output + ExcludeModuleFile: + +Resolve-Dependency: + Gallery: 'PSGallery' + AllowPrerelease: false + Verbose: false + +ModuleBuildTasks: + Sampler: + - '*.build.Sampler.ib.tasks' + +TaskHeader: | + param($Path) + "" + "=" * 79 + Write-Build Cyan "`t`t`t$($Task.Name.replace("_"," ").ToUpper())" + Write-Build DarkGray "$(Get-BuildSynopsis $Task)" + "-" * 79 + Write-Build DarkGray " $Path" + Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)" + "" + +GitHubConfig: + GitHubFilesToAdd: + - 'CHANGELOG.md' + GitHubConfigUserName: dscbot + GitHubConfigUserEmail: dsccommunity@outlook.com + UpdateChangelogOnPrerelease: false diff --git a/source/Build.psd1 b/source/Build.psd1 new file mode 100644 index 000000000..22d303f88 --- /dev/null +++ b/source/Build.psd1 @@ -0,0 +1,5 @@ +@{ + Path = 'SqlServerDsc.psd1' +} +# Waiting for ModuleBuilder to do away with this file +# when all parameters are provided to the function diff --git a/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 b/source/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 rename to source/DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1 diff --git a/DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof b/source/DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof rename to source/DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof diff --git a/DSCResources/MSFT_SqlAG/en-US/MSFT_SqlAG.strings.psd1 b/source/DSCResources/MSFT_SqlAG/en-US/MSFT_SqlAG.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAG/en-US/MSFT_SqlAG.strings.psd1 rename to source/DSCResources/MSFT_SqlAG/en-US/MSFT_SqlAG.strings.psd1 diff --git a/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 b/source/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 rename to source/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1 diff --git a/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof b/source/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof rename to source/DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.schema.mof diff --git a/DSCResources/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 b/source/DSCResources/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 rename to source/DSCResources/MSFT_SqlAGDatabase/en-US/MSFT_SqlAGDatabase.strings.psd1 diff --git a/DSCResources/MSFT_SqlAGDatabase/en-US/about_SqlAGDatabase.help.txt b/source/DSCResources/MSFT_SqlAGDatabase/en-US/about_SqlAGDatabase.help.txt similarity index 100% rename from DSCResources/MSFT_SqlAGDatabase/en-US/about_SqlAGDatabase.help.txt rename to source/DSCResources/MSFT_SqlAGDatabase/en-US/about_SqlAGDatabase.help.txt diff --git a/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 b/source/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 rename to source/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1 diff --git a/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof b/source/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof rename to source/DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.schema.mof diff --git a/DSCResources/MSFT_SqlAGListener/en-US/MSFT_SqlAGListener.strings.psd1 b/source/DSCResources/MSFT_SqlAGListener/en-US/MSFT_SqlAGListener.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAGListener/en-US/MSFT_SqlAGListener.strings.psd1 rename to source/DSCResources/MSFT_SqlAGListener/en-US/MSFT_SqlAGListener.strings.psd1 diff --git a/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 b/source/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 rename to source/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1 diff --git a/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof b/source/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof rename to source/DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.schema.mof diff --git a/DSCResources/MSFT_SqlAGReplica/en-US/MSFT_SqlAGReplica.strings.psd1 b/source/DSCResources/MSFT_SqlAGReplica/en-US/MSFT_SqlAGReplica.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAGReplica/en-US/MSFT_SqlAGReplica.strings.psd1 rename to source/DSCResources/MSFT_SqlAGReplica/en-US/MSFT_SqlAGReplica.strings.psd1 diff --git a/DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.psm1 b/source/DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.psm1 rename to source/DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.psm1 diff --git a/DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.schema.mof b/source/DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.schema.mof rename to source/DSCResources/MSFT_SqlAgentAlert/MSFT_SqlAgentAlert.schema.mof diff --git a/DSCResources/MSFT_SqlAgentAlert/en-US/MSFT_SqlAgentAlert.strings.psd1 b/source/DSCResources/MSFT_SqlAgentAlert/en-US/MSFT_SqlAgentAlert.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAgentAlert/en-US/MSFT_SqlAgentAlert.strings.psd1 rename to source/DSCResources/MSFT_SqlAgentAlert/en-US/MSFT_SqlAgentAlert.strings.psd1 diff --git a/DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.psm1 b/source/DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.psm1 rename to source/DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.psm1 diff --git a/DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.schema.mof b/source/DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.schema.mof rename to source/DSCResources/MSFT_SqlAgentFailsafe/MSFT_SqlAgentFailsafe.schema.mof diff --git a/DSCResources/MSFT_SqlAgentFailsafe/en-US/MSFT_SqlAgentFailsafe.strings.psd1 b/source/DSCResources/MSFT_SqlAgentFailsafe/en-US/MSFT_SqlAgentFailsafe.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAgentFailsafe/en-US/MSFT_SqlAgentFailsafe.strings.psd1 rename to source/DSCResources/MSFT_SqlAgentFailsafe/en-US/MSFT_SqlAgentFailsafe.strings.psd1 diff --git a/DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.psm1 b/source/DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.psm1 rename to source/DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.psm1 diff --git a/DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.schema.mof b/source/DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.schema.mof rename to source/DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.schema.mof diff --git a/DSCResources/MSFT_SqlAgentOperator/en-US/MSFT_SqlAgentOperator.strings.psd1 b/source/DSCResources/MSFT_SqlAgentOperator/en-US/MSFT_SqlAgentOperator.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAgentOperator/en-US/MSFT_SqlAgentOperator.strings.psd1 rename to source/DSCResources/MSFT_SqlAgentOperator/en-US/MSFT_SqlAgentOperator.strings.psd1 diff --git a/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1 b/source/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1 similarity index 100% rename from DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1 rename to source/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1 diff --git a/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof b/source/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof rename to source/DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.schema.mof diff --git a/DSCResources/MSFT_SqlAlias/en-US/MSFT_SqlAlias.strings.psd1 b/source/DSCResources/MSFT_SqlAlias/en-US/MSFT_SqlAlias.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAlias/en-US/MSFT_SqlAlias.strings.psd1 rename to source/DSCResources/MSFT_SqlAlias/en-US/MSFT_SqlAlias.strings.psd1 diff --git a/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 b/source/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 similarity index 98% rename from DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 rename to source/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 index 053f479c2..a9dae13d6 100644 --- a/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 +++ b/source/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.psm1 @@ -129,7 +129,7 @@ function Set-TargetResource $script:localizedData.DisableAlwaysOnAvailabilityGroup -f $ServerName, $InstanceName ) - Disable-SqlAlwaysOn -ServerInstance $serverInstance -NoServiceRestart + Disable-SqlAlwaysOn -ServerInstance $serverInstance -NoServiceRestart -ErrorAction 'Stop' } 'Present' @@ -141,7 +141,7 @@ function Set-TargetResource $script:localizedData.EnableAlwaysOnAvailabilityGroup -f $ServerName, $InstanceName ) - Enable-SqlAlwaysOn -ServerInstance $serverInstance -NoServiceRestart + Enable-SqlAlwaysOn -ServerInstance $serverInstance -NoServiceRestart -ErrorAction 'Stop' } } diff --git a/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof b/source/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof rename to source/DSCResources/MSFT_SqlAlwaysOnService/MSFT_SqlAlwaysOnService.schema.mof diff --git a/DSCResources/MSFT_SqlAlwaysOnService/en-US/MSFT_SqlAlwaysOnService.strings.psd1 b/source/DSCResources/MSFT_SqlAlwaysOnService/en-US/MSFT_SqlAlwaysOnService.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlAlwaysOnService/en-US/MSFT_SqlAlwaysOnService.strings.psd1 rename to source/DSCResources/MSFT_SqlAlwaysOnService/en-US/MSFT_SqlAlwaysOnService.strings.psd1 diff --git a/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 b/source/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 similarity index 100% rename from DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 rename to source/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1 diff --git a/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof b/source/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof rename to source/DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.schema.mof diff --git a/DSCResources/MSFT_SqlDatabase/en-US/MSFT_SqlDatabase.strings.psd1 b/source/DSCResources/MSFT_SqlDatabase/en-US/MSFT_SqlDatabase.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlDatabase/en-US/MSFT_SqlDatabase.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabase/en-US/MSFT_SqlDatabase.strings.psd1 diff --git a/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 b/source/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 rename to source/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.psm1 diff --git a/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof b/source/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof rename to source/DSCResources/MSFT_SqlDatabaseDefaultLocation/MSFT_SqlDatabaseDefaultLocation.schema.mof diff --git a/DSCResources/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 b/source/DSCResources/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabaseDefaultLocation/en-US/MSFT_SqlDatabaseDefaultLocation.strings.psd1 diff --git a/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 b/source/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 rename to source/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 diff --git a/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof b/source/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof rename to source/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.schema.mof diff --git a/DSCResources/MSFT_SqlDatabaseOwner/en-US/MSFT_SqlDatabaseOwner.strings.psd1 b/source/DSCResources/MSFT_SqlDatabaseOwner/en-US/MSFT_SqlDatabaseOwner.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseOwner/en-US/MSFT_SqlDatabaseOwner.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabaseOwner/en-US/MSFT_SqlDatabaseOwner.strings.psd1 diff --git a/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 b/source/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 similarity index 100% rename from DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 rename to source/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.psm1 diff --git a/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof b/source/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof rename to source/DSCResources/MSFT_SqlDatabasePermission/MSFT_SqlDatabasePermission.schema.mof diff --git a/DSCResources/MSFT_SqlDatabasePermission/en-US/MSFT_SqlDatabasePermission.strings.psd1 b/source/DSCResources/MSFT_SqlDatabasePermission/en-US/MSFT_SqlDatabasePermission.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlDatabasePermission/en-US/MSFT_SqlDatabasePermission.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabasePermission/en-US/MSFT_SqlDatabasePermission.strings.psd1 diff --git a/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 rename to source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 diff --git a/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof rename to source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof diff --git a/DSCResources/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 diff --git a/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 b/source/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 rename to source/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1 diff --git a/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof b/source/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof rename to source/DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.schema.mof diff --git a/DSCResources/MSFT_SqlDatabaseRole/en-US/MSFT_SqlDatabaseRole.strings.psd1 b/source/DSCResources/MSFT_SqlDatabaseRole/en-US/MSFT_SqlDatabaseRole.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseRole/en-US/MSFT_SqlDatabaseRole.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabaseRole/en-US/MSFT_SqlDatabaseRole.strings.psd1 diff --git a/DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.psm1 b/source/DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.psm1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.psm1 rename to source/DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.psm1 diff --git a/DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.schema.mof b/source/DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.schema.mof rename to source/DSCResources/MSFT_SqlDatabaseUser/MSFT_SqlDatabaseUser.schema.mof diff --git a/DSCResources/MSFT_SqlDatabaseUser/en-US/MSFT_SqlDatabaseUser.strings.psd1 b/source/DSCResources/MSFT_SqlDatabaseUser/en-US/MSFT_SqlDatabaseUser.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlDatabaseUser/en-US/MSFT_SqlDatabaseUser.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabaseUser/en-US/MSFT_SqlDatabaseUser.strings.psd1 diff --git a/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 b/source/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 similarity index 100% rename from DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 rename to source/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 diff --git a/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof b/source/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof rename to source/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof diff --git a/DSCResources/MSFT_SqlRS/en-US/MSFT_SqlRS.strings.psd1 b/source/DSCResources/MSFT_SqlRS/en-US/MSFT_SqlRS.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlRS/en-US/MSFT_SqlRS.strings.psd1 rename to source/DSCResources/MSFT_SqlRS/en-US/MSFT_SqlRS.strings.psd1 diff --git a/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 b/source/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 similarity index 99% rename from DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 rename to source/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 index 92be43e53..da20530b7 100644 --- a/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 +++ b/source/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.psm1 @@ -224,7 +224,7 @@ function Set-TargetResource Suppressing this rule because $global:DSCMachineStatus is only set, never used (by design of Desired State Configuration). #> - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function', Target='DSCMachineStatus')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] [CmdletBinding()] param ( diff --git a/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.schema.mof b/source/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.schema.mof rename to source/DSCResources/MSFT_SqlRSSetup/MSFT_SqlRSSetup.schema.mof diff --git a/DSCResources/MSFT_SqlRSSetup/en-US/MSFT_SqlRSSetup.strings.psd1 b/source/DSCResources/MSFT_SqlRSSetup/en-US/MSFT_SqlRSSetup.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlRSSetup/en-US/MSFT_SqlRSSetup.strings.psd1 rename to source/DSCResources/MSFT_SqlRSSetup/en-US/MSFT_SqlRSSetup.strings.psd1 diff --git a/DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1 b/source/DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1 similarity index 100% rename from DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1 rename to source/DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1 diff --git a/DSCResources/MSFT_SqlScript/MSFT_SqlScript.schema.mof b/source/DSCResources/MSFT_SqlScript/MSFT_SqlScript.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlScript/MSFT_SqlScript.schema.mof rename to source/DSCResources/MSFT_SqlScript/MSFT_SqlScript.schema.mof diff --git a/DSCResources/MSFT_SqlScript/en-US/MSFT_SqlScript.strings.psd1 b/source/DSCResources/MSFT_SqlScript/en-US/MSFT_SqlScript.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlScript/en-US/MSFT_SqlScript.strings.psd1 rename to source/DSCResources/MSFT_SqlScript/en-US/MSFT_SqlScript.strings.psd1 diff --git a/DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.psm1 b/source/DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.psm1 similarity index 100% rename from DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.psm1 rename to source/DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.psm1 diff --git a/DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.schema.mof b/source/DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.schema.mof rename to source/DSCResources/MSFT_SqlScriptQuery/MSFT_SqlScriptQuery.schema.mof diff --git a/DSCResources/MSFT_SqlScriptQuery/en-US/MSFT_SqlScriptQuery.strings.psd1 b/source/DSCResources/MSFT_SqlScriptQuery/en-US/MSFT_SqlScriptQuery.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlScriptQuery/en-US/MSFT_SqlScriptQuery.strings.psd1 rename to source/DSCResources/MSFT_SqlScriptQuery/en-US/MSFT_SqlScriptQuery.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 b/source/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 rename to source/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1 diff --git a/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof b/source/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof rename to source/DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof diff --git a/DSCResources/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1 b/source/DSCResources/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1 rename to source/DSCResources/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 b/source/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 rename to source/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.psm1 diff --git a/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.schema.mof b/source/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.schema.mof rename to source/DSCResources/MSFT_SqlServerDatabaseMail/MSFT_SqlServerDatabaseMail.schema.mof diff --git a/DSCResources/MSFT_SqlServerDatabaseMail/en-US/MSFT_SqlServerDatabaseMail.strings.psd1 b/source/DSCResources/MSFT_SqlServerDatabaseMail/en-US/MSFT_SqlServerDatabaseMail.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerDatabaseMail/en-US/MSFT_SqlServerDatabaseMail.strings.psd1 rename to source/DSCResources/MSFT_SqlServerDatabaseMail/en-US/MSFT_SqlServerDatabaseMail.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 b/source/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 rename to source/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.psm1 diff --git a/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof b/source/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof rename to source/DSCResources/MSFT_SqlServerEndpoint/MSFT_SqlServerEndpoint.schema.mof diff --git a/DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 b/source/DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 rename to source/DSCResources/MSFT_SqlServerEndpoint/en-US/MSFT_SqlServerEndpoint.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 b/source/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 rename to source/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.psm1 diff --git a/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof b/source/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof rename to source/DSCResources/MSFT_SqlServerEndpointPermission/MSFT_SqlServerEndpointPermission.schema.mof diff --git a/DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 b/source/DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 rename to source/DSCResources/MSFT_SqlServerEndpointPermission/en-US/MSFT_SqlServerEndpointPermission.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 b/source/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 rename to source/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.psm1 diff --git a/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof b/source/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof rename to source/DSCResources/MSFT_SqlServerEndpointState/MSFT_SqlServerEndpointState.schema.mof diff --git a/DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 b/source/DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 rename to source/DSCResources/MSFT_SqlServerEndpointState/en-US/MSFT_SqlServerEndpointState.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 b/source/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 rename to source/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1 diff --git a/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof b/source/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof rename to source/DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.schema.mof diff --git a/DSCResources/MSFT_SqlServerLogin/en-US/MSFT_SqlServerLogin.strings.psd1 b/source/DSCResources/MSFT_SqlServerLogin/en-US/MSFT_SqlServerLogin.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerLogin/en-US/MSFT_SqlServerLogin.strings.psd1 rename to source/DSCResources/MSFT_SqlServerLogin/en-US/MSFT_SqlServerLogin.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 b/source/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 rename to source/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1 diff --git a/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof b/source/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof rename to source/DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.schema.mof diff --git a/DSCResources/MSFT_SqlServerMaxDop/en-US/MSFT_SqlServerMaxDop.strings.psd1 b/source/DSCResources/MSFT_SqlServerMaxDop/en-US/MSFT_SqlServerMaxDop.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerMaxDop/en-US/MSFT_SqlServerMaxDop.strings.psd1 rename to source/DSCResources/MSFT_SqlServerMaxDop/en-US/MSFT_SqlServerMaxDop.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 b/source/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 rename to source/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.psm1 diff --git a/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof b/source/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof rename to source/DSCResources/MSFT_SqlServerMemory/MSFT_SqlServerMemory.schema.mof diff --git a/DSCResources/MSFT_SqlServerMemory/en-US/MSFT_SqlServerMemory.strings.psd1 b/source/DSCResources/MSFT_SqlServerMemory/en-US/MSFT_SqlServerMemory.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerMemory/en-US/MSFT_SqlServerMemory.strings.psd1 rename to source/DSCResources/MSFT_SqlServerMemory/en-US/MSFT_SqlServerMemory.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 b/source/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 rename to source/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.psm1 diff --git a/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof b/source/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof rename to source/DSCResources/MSFT_SqlServerNetwork/MSFT_SqlServerNetwork.schema.mof diff --git a/DSCResources/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 b/source/DSCResources/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 rename to source/DSCResources/MSFT_SqlServerNetwork/en-US/MSFT_SqlServerNetwork.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 b/source/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 rename to source/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.psm1 diff --git a/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof b/source/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof rename to source/DSCResources/MSFT_SqlServerPermission/MSFT_SqlServerPermission.schema.mof diff --git a/DSCResources/MSFT_SqlServerPermission/en-US/MSFT_SqlServerPermission.strings.psd1 b/source/DSCResources/MSFT_SqlServerPermission/en-US/MSFT_SqlServerPermission.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerPermission/en-US/MSFT_SqlServerPermission.strings.psd1 rename to source/DSCResources/MSFT_SqlServerPermission/en-US/MSFT_SqlServerPermission.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 b/source/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 rename to source/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.psm1 diff --git a/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof b/source/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof rename to source/DSCResources/MSFT_SqlServerReplication/MSFT_SqlServerReplication.schema.mof diff --git a/DSCResources/MSFT_SqlServerReplication/en-US/MSFT_SqlServerReplication.strings.psd1 b/source/DSCResources/MSFT_SqlServerReplication/en-US/MSFT_SqlServerReplication.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerReplication/en-US/MSFT_SqlServerReplication.strings.psd1 rename to source/DSCResources/MSFT_SqlServerReplication/en-US/MSFT_SqlServerReplication.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 b/source/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 rename to source/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.psm1 diff --git a/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof b/source/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof rename to source/DSCResources/MSFT_SqlServerRole/MSFT_SqlServerRole.schema.mof diff --git a/DSCResources/MSFT_SqlServerRole/en-US/MSFT_SqlServerRole.strings.psd1 b/source/DSCResources/MSFT_SqlServerRole/en-US/MSFT_SqlServerRole.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerRole/en-US/MSFT_SqlServerRole.strings.psd1 rename to source/DSCResources/MSFT_SqlServerRole/en-US/MSFT_SqlServerRole.strings.psd1 diff --git a/DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.psm1 b/source/DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.psm1 rename to source/DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.psm1 diff --git a/DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.schema.mof b/source/DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.schema.mof rename to source/DSCResources/MSFT_SqlServerSecureConnection/MSFT_SqlServerSecureConnection.schema.mof diff --git a/DSCResources/MSFT_SqlServerSecureConnection/en-US/MSFT_SqlServerSecureConnection.strings.psd1 b/source/DSCResources/MSFT_SqlServerSecureConnection/en-US/MSFT_SqlServerSecureConnection.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServerSecureConnection/en-US/MSFT_SqlServerSecureConnection.strings.psd1 rename to source/DSCResources/MSFT_SqlServerSecureConnection/en-US/MSFT_SqlServerSecureConnection.strings.psd1 diff --git a/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 b/source/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 similarity index 100% rename from DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 rename to source/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.psm1 diff --git a/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof b/source/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof rename to source/DSCResources/MSFT_SqlServiceAccount/MSFT_SqlServiceAccount.schema.mof diff --git a/DSCResources/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 b/source/DSCResources/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 rename to source/DSCResources/MSFT_SqlServiceAccount/en-US/MSFT_SqlServiceAccount.strings.psd1 diff --git a/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 b/source/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 similarity index 99% rename from DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 rename to source/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 index d2b49957d..e4ac8d098 100644 --- a/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 +++ b/source/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1 @@ -781,7 +781,7 @@ function Set-TargetResource Suppressing this rule because $global:DSCMachineStatus is only set, never used (by design of Desired State Configuration). #> - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function', Target='DSCMachineStatus')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','')] [CmdletBinding()] param ( diff --git a/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof b/source/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof rename to source/DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.schema.mof diff --git a/DSCResources/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 b/source/DSCResources/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 rename to source/DSCResources/MSFT_SqlSetup/en-US/MSFT_SqlSetup.strings.psd1 diff --git a/DSCResources/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 b/source/DSCResources/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 rename to source/DSCResources/MSFT_SqlSetup/sv-SE/MSFT_SqlSetup.strings.psd1 diff --git a/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 b/source/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 similarity index 100% rename from DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 rename to source/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.psm1 diff --git a/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof b/source/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof rename to source/DSCResources/MSFT_SqlWaitForAG/MSFT_SqlWaitForAG.schema.mof diff --git a/DSCResources/MSFT_SqlWaitForAG/en-US/MSFT_SqlWaitForAG.strings.psd1 b/source/DSCResources/MSFT_SqlWaitForAG/en-US/MSFT_SqlWaitForAG.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlWaitForAG/en-US/MSFT_SqlWaitForAG.strings.psd1 rename to source/DSCResources/MSFT_SqlWaitForAG/en-US/MSFT_SqlWaitForAG.strings.psd1 diff --git a/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 b/source/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 similarity index 99% rename from DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 rename to source/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 index 12469ec55..59b403beb 100644 --- a/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 +++ b/source/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.psm1 @@ -441,9 +441,11 @@ function Set-TargetResource if (-not (Test-IsFirewallRuleInDesiredState @databaseEngineFirewallRuleParameters)) { - if (Get-NetFirewallRule | Where-Object -FilterScript { + $databaseEngineFirewallRule = Get-NetFirewallRule | Where-Object -FilterScript { $_.DisplayName -eq $databaseEngineFirewallRuleDisplayName - }) + } + + if ($databaseEngineFirewallRule) { Set-NetFirewallRule @databaseEngineFirewallRuleParameters } diff --git a/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof b/source/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof similarity index 100% rename from DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof rename to source/DSCResources/MSFT_SqlWindowsFirewall/MSFT_SqlWindowsFirewall.schema.mof diff --git a/DSCResources/MSFT_SqlWindowsFirewall/en-US/MSFT_SqlWindowsFirewall.strings.psd1 b/source/DSCResources/MSFT_SqlWindowsFirewall/en-US/MSFT_SqlWindowsFirewall.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SqlWindowsFirewall/en-US/MSFT_SqlWindowsFirewall.strings.psd1 rename to source/DSCResources/MSFT_SqlWindowsFirewall/en-US/MSFT_SqlWindowsFirewall.strings.psd1 diff --git a/Examples/README.md b/source/Examples/README.md similarity index 100% rename from Examples/README.md rename to source/Examples/README.md diff --git a/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 b/source/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 similarity index 53% rename from Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 rename to source/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 index 9f9a91b51..57164eaca 100644 --- a/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 +++ b/source/Examples/Resources/SqlAG/1-CreateAvailabilityGroup.ps1 @@ -1,89 +1,79 @@ <# -.EXAMPLE - This example shows how to ensure that the Availability Group 'TestAG' exists. + .DESCRIPTION + This example shows how to ensure that the Availability Group 'TestAG' exists. #> -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = '*' - InstanceName = 'MSSQLSERVER' - }, - - @{ - NodeName = 'SP23-VM-SQL1' - Role = 'PrimaryReplica' - } - ) -} - Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' Node $AllNodes.NodeName { # Adding the required service account to allow the cluster to log into SQL - SqlServerLogin AddNTServiceClusSvc + SqlServerLogin 'AddNTServiceClusSvc' { Ensure = 'Present' Name = 'NT SERVICE\ClusSvc' LoginType = 'WindowsUser' ServerName = $Node.NodeName - InstanceName = $Node.InstanceName + InstanceName = 'MSSQLSERVER' + PsDscRunAsCredential = $SqlAdministratorCredential } # Add the required permissions to the cluster service login - SqlServerPermission AddNTServiceClusSvcPermissions + SqlServerPermission 'AddNTServiceClusSvcPermissions' { DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' Ensure = 'Present' ServerName = $Node.NodeName - InstanceName = $Node.InstanceName + InstanceName = 'MSSQLSERVER' Principal = 'NT SERVICE\ClusSvc' Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' + PsDscRunAsCredential = $SqlAdministratorCredential } # Create a DatabaseMirroring endpoint - SqlServerEndpoint HADREndpoint + SqlServerEndpoint 'HADREndpoint' { EndPointName = 'HADR' Ensure = 'Present' Port = 5022 ServerName = $Node.NodeName - InstanceName = $Node.InstanceName + InstanceName = 'MSSQLSERVER' + PsDscRunAsCredential = $SqlAdministratorCredential } # Ensure the HADR option is enabled for the instance - SqlAlwaysOnService EnableHADR + SqlAlwaysOnService 'EnableHADR' { Ensure = 'Present' - InstanceName = $Node.InstanceName + InstanceName = 'MSSQLSERVER' ServerName = $Node.NodeName + PsDscRunAsCredential = $SqlAdministratorCredential } - if ( $Node.Role -eq 'PrimaryReplica' ) + # Create the availability group on the instance tagged as the primary replica + SqlAG 'AddTestAG' { - # Create the availability group on the instance tagged as the primary replica - SqlAG AddTestAG - { - Ensure = 'Present' - Name = 'TestAG' - InstanceName = $Node.InstanceName - ServerName = $Node.NodeName - DependsOn = '[SqlAlwaysOnService]EnableHADR', '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' - PsDscRunAsCredential = $SqlAdministratorCredential - } + Ensure = 'Present' + Name = 'TestAG' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + + DependsOn = '[SqlAlwaysOnService]EnableHADR', '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' + + PsDscRunAsCredential = $SqlAdministratorCredential } } } diff --git a/source/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 b/source/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 new file mode 100644 index 000000000..afd357642 --- /dev/null +++ b/source/Examples/Resources/SqlAG/2-RemoveAvailabilityGroup.ps1 @@ -0,0 +1,30 @@ +<# + .DESCRIPTION + This example shows how to ensure that the Availability Group 'TestAG' does not exist. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node $AllNodes.NodeName + { + # Create the availability group on the instance tagged as the primary replica + SqlAG 'RemoveTestAG' + { + Ensure = 'Absent' + Name = 'TestAG' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 b/source/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 new file mode 100644 index 000000000..79ac51ef1 --- /dev/null +++ b/source/Examples/Resources/SqlAG/3-CreateAvailabilityGroupDetailed.ps1 @@ -0,0 +1,92 @@ +<# + .DESCRIPTION + This example shows how to ensure that the Availability Group 'TestAG' exists. + + In the event this is applied to a Failover Cluster Instance (FCI), the + ProcessOnlyOnActiveNode property will tell the Test-TargetResource function + to evaluate if any changes are needed if the node is actively hosting the + SQL Server Instance. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node $AllNodes.NodeName + { + # Adding the required service account to allow the cluster to log into SQL + SqlServerLogin 'AddNTServiceClusSvc' + { + Ensure = 'Present' + Name = 'NT SERVICE\ClusSvc' + LoginType = 'WindowsUser' + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + PsDscRunAsCredential = $SqlAdministratorCredential + } + + # Add the required permissions to the cluster service login + SqlServerPermission 'AddNTServiceClusSvcPermissions' + { + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' + Ensure = 'Present' + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + Principal = 'NT SERVICE\ClusSvc' + Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' + PsDscRunAsCredential = $SqlAdministratorCredential + } + + # Create a DatabaseMirroring endpoint + SqlServerEndpoint 'HADREndpoint' + { + EndPointName = 'HADR' + Ensure = 'Present' + Port = 5022 + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + PsDscRunAsCredential = $SqlAdministratorCredential + } + + SqlAlwaysOnService 'EnableHADR' + { + Ensure = 'Present' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + PsDscRunAsCredential = $SqlAdministratorCredential + } + + SqlAG 'AddTestAG' + { + Ensure = 'Present' + Name = 'TestAG' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + ProcessOnlyOnActiveNode = $true + + AutomatedBackupPreference = 'Primary' + AvailabilityMode = 'SynchronousCommit' + BackupPriority = 50 + ConnectionModeInPrimaryRole = 'AllowAllConnections' + ConnectionModeInSecondaryRole = 'AllowNoConnections' + FailoverMode = 'Automatic' + HealthCheckTimeout = 15000 + + # SQl Server 2016 or later only + BasicAvailabilityGroup = $false + DatabaseHealthTrigger = $true + DtcSupportEnabled = $true + + DependsOn = '[SqlAlwaysOnService]EnableHADR', '[SqlServerEndpoint]HADREndpoint', '[SqlServerPermission]AddNTServiceClusSvcPermissions' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 b/source/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 new file mode 100644 index 000000000..518b8dd60 --- /dev/null +++ b/source/Examples/Resources/SqlAGDatabase/1-AddDatabaseToAvailabilityGroup.ps1 @@ -0,0 +1,38 @@ +<# + .DESCRIPTION + This example shows how to ensure that the databases 'DB*' and 'AdventureWorks' + are members in the Availability Group 'TestAG'. + + In the event this is applied to a Failover Cluster Instance (FCI), the + ProcessOnlyOnActiveNode property will tell the Test-TargetResource function + to evaluate if any changes are needed if the node is actively hosting the + SQL Server Instance. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node $AllNodes.NodeName + { + SqlAGDatabase 'AddAGDatabaseMemberships' + { + AvailabilityGroupName = 'TestAG' + BackupPath = '\\SQL1\AgInitialize' + DatabaseName = 'DB*', 'AdventureWorks' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + Ensure = 'Present' + ProcessOnlyOnActiveNode = $true + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 b/source/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 new file mode 100644 index 000000000..2e730e2db --- /dev/null +++ b/source/Examples/Resources/SqlAGDatabase/2-RemoveDatabaseFromAvailabilityGroup.ps1 @@ -0,0 +1,32 @@ +<# + .DESCRIPTION + This example shows how to ensure that the databases 'DB*' and 'AdventureWorks' + are not members of the Availability Group 'TestAG'. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node $AllNodes.NodeName + { + SqlAGDatabase 'RemoveAGDatabaseMemberships' + { + AvailabilityGroupName = 'TestAG' + BackupPath = '\\SQL1\AgInitialize' + DatabaseName = 'DB*', 'AdventureWorks' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + Ensure = 'Absent' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 b/source/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 new file mode 100644 index 000000000..0e316bbec --- /dev/null +++ b/source/Examples/Resources/SqlAGDatabase/3-MatchDefinedDatabaseInAvailabilityGroup.ps1 @@ -0,0 +1,33 @@ +<# + .DESCRIPTION + This example shows how to ensure that the databases 'DB*' and 'AdventureWorks' + 'are the only members of the Availability Group 'TestAG'. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node $AllNodes.NodeName + { + SqlAGDatabase 'TestAGDatabaseMemberships' + { + AvailabilityGroupName = 'TestAG' + BackupPath = '\\SQL1\AgInitialize' + DatabaseName = 'DB*', 'AdventureWorks' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + Ensure = 'Present' + Force = $true + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 b/source/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 similarity index 72% rename from Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 rename to source/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 index 10f070892..3a5a39c6b 100644 --- a/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 +++ b/source/Examples/Resources/SqlAGListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 @@ -1,6 +1,7 @@ <# -.EXAMPLE - This example will add an Availability Group listener with the same name as the cluster role VCO. + .DESCRIPTION + This example will add an Availability Group listener with the same name + as the cluster role VCO. #> Configuration Example { @@ -11,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlAGListener AvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener 'AvailabilityGroupListenerWithSameNameAsVCO' { Ensure = 'Present' ServerName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 b/source/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 similarity index 72% rename from Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 rename to source/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 index 0c8326e4b..6e3f417df 100644 --- a/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 +++ b/source/Examples/Resources/SqlAGListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 @@ -1,6 +1,7 @@ <# -.EXAMPLE - This example will add an Availability Group listener with a different than the cluster role VCO. + .DESCRIPTION + This example will add an Availability Group listener with a different + than the cluster role VCO. #> Configuration Example { @@ -11,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlAGListener AvailabilityGroupListenerWithDifferentNameAsVCO + SqlAGListener 'AvailabilityGroupListenerWithDifferentNameAsVCO' { Ensure = 'Present' ServerName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 b/source/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 similarity index 67% rename from Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 rename to source/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 index 87683db07..503d847a7 100644 --- a/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 +++ b/source/Examples/Resources/SqlAGListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 @@ -1,6 +1,7 @@ <# -.EXAMPLE - This example will remove an Availability Group listener with a different name than cluster role VCO. + .DESCRIPTION + This example will remove an Availability Group listener with a different + name than cluster role VCO. #> Configuration Example { @@ -11,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlAGListener RemoveAvailabilityGroupListenerWithDifferentNameAsVCO + SqlAGListener 'RemoveAvailabilityGroupListenerWithDifferentNameAsVCO' { Ensure = 'Absent' ServerName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 b/source/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 similarity index 67% rename from Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 rename to source/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 index b1c822454..79d92612a 100644 --- a/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 +++ b/source/Examples/Resources/SqlAGListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 @@ -1,6 +1,7 @@ <# -.EXAMPLE - This example will remove an Availability Group listener with the same name as the cluster role VCO. + .DESCRIPTION + This example will remove an Availability Group listener with the same + name as the cluster role VCO. #> Configuration Example { @@ -11,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlAGListener RemoveAvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener 'RemoveAvailabilityGroupListenerWithSameNameAsVCO' { Ensure = 'Absent' ServerName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 b/source/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 similarity index 56% rename from Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 rename to source/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 index 59de8667f..c0c71539b 100644 --- a/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 +++ b/source/Examples/Resources/SqlAGListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 @@ -1,6 +1,7 @@ <# -.EXAMPLE - This example will add an Availability Group listener using DHCP on the default server subnet. + .DESCRIPTION + This example will add an Availability Group listener using DHCP on the + default server subnet. #> Configuration Example { @@ -11,18 +12,22 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlAGListener AvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener 'AvailabilityGroupListenerWithSameNameAsVCO' { Ensure = 'Present' ServerName = 'SQLNODE01.company.local' InstanceName = 'MSSQLSERVER' AvailabilityGroup = 'AG-01' Name = 'AG-01' - DHCP = $true # Also not specifying parameter DHCP will default to using DHCP with the default server subnet. + <# + If not specifying parameter DHCP, then the default will be + DHCP with the default server subnet. + #> + DHCP = $true Port = 5301 PsDscRunAsCredential = $SqlAdministratorCredential diff --git a/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 b/source/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 similarity index 74% rename from Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 rename to source/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 index 3cb8ff512..decdb0bdb 100644 --- a/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 +++ b/source/Examples/Resources/SqlAGListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 @@ -1,6 +1,6 @@ <# -.EXAMPLE - This example will add an Availability Group listener using DHCP with a specific subnet. + .DESCRIPTION + This example will add an Availability Group listener using DHCP with a specific subnet. #> Configuration Example { @@ -11,11 +11,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlAGListener AvailabilityGroupListenerWithSameNameAsVCO + SqlAGListener 'AvailabilityGroupListenerWithSameNameAsVCO' { Ensure = 'Present' ServerName = 'SQLNODE01.company.local' diff --git a/source/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 b/source/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 new file mode 100644 index 000000000..21d66147b --- /dev/null +++ b/source/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1 @@ -0,0 +1,88 @@ +<# + .DESCRIPTION + This example shows how to ensure that the Availability Group Replica 'SQL2' + exists in the Availability Group 'TestAG'. + + In the event this is applied to a Failover Cluster Instance (FCI), the + ProcessOnlyOnActiveNode property will tell the Test-TargetResource function + to evaluate if any changes are needed if the node is actively hosting the + SQL Server Instance. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node $AllNodes.NodeName + { + # Adding the required service account to allow the cluster to log into SQL + SqlServerLogin 'AddNTServiceClusSvc' + { + Ensure = 'Present' + Name = 'NT SERVICE\ClusSvc' + LoginType = 'WindowsUser' + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + + # Add the required permissions to the cluster service login + SqlServerPermission 'AddNTServiceClusSvcPermissions' + { + DependsOn = '[SqlServerLogin]AddNTServiceClusSvc' + Ensure = 'Present' + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + Principal = 'NT SERVICE\ClusSvc' + Permission = 'AlterAnyAvailabilityGroup', 'ViewServerState' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + + # Create a DatabaseMirroring endpoint + SqlServerEndpoint 'HADREndpoint' + { + EndPointName = 'HADR' + Ensure = 'Present' + Port = 5022 + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + + SqlAlwaysOnService EnableHADR + { + Ensure = 'Present' + InstanceName = 'MSSQLSERVER' + ServerName = $Node.NodeName + + PsDscRunAsCredential = $SqlAdministratorCredential + } + + # Add the availability group replica to the availability group + SqlAGReplica 'AddReplica' + { + Ensure = 'Present' + Name = $Node.NodeName + AvailabilityGroupName = 'TestAG' + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + PrimaryReplicaServerName = 'SQL1' + PrimaryReplicaInstanceName = 'MSSQLSERVER' + ProcessOnlyOnActiveNode = $true + + DependsOn = '[SqlAlwaysOnService]EnableHADR' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 b/source/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 new file mode 100644 index 000000000..5ecd963e7 --- /dev/null +++ b/source/Examples/Resources/SqlAGReplica/2-RemoveAvailabilityGroupReplica.ps1 @@ -0,0 +1,34 @@ +<# + .DESCRIPTION + This example shows how to ensure that the Availability Group Replica 'SQL2' + does not exist in the Availability Group 'TestAG'. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node $AllNodes.NodeName + { + # Add the availability group replica to the availability group + SqlAGReplica 'RemoveReplica' + { + Ensure = 'Absent' + Name = $Node.NodeName + AvailabilityGroupName = 'TestAG' + ServerName = $Node.NodeName + InstanceName = 'MSSQLSERVER' + PrimaryReplicaServerName = 'SQL1' + PrimaryReplicaInstanceName = 'MSSQLSERVER' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 b/source/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 new file mode 100644 index 000000000..4d5e95096 --- /dev/null +++ b/source/Examples/Resources/SqlAgentAlert/1-AddAlert.ps1 @@ -0,0 +1,32 @@ +<# + .DESCRIPTION + This example shows how to ensure that the SQL Agent Alert + Sev17 exists with the correct severity level, and SQL + Agent Alert Msg825 with the correct message id. +#> + +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlAgentAlert 'Add_Sev17' + { + Ensure = 'Present' + Name = 'Sev17' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + Severity = '17' + } + + SqlAgentAlert 'Add_Msg825' + { + Ensure = 'Present' + Name = 'Msg825' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + MessageId = '825' + } + } +} diff --git a/source/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 b/source/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 new file mode 100644 index 000000000..27461a657 --- /dev/null +++ b/source/Examples/Resources/SqlAgentAlert/2-RemoveAlert.ps1 @@ -0,0 +1,29 @@ +<# + .DESCRIPTION + This example shows how to ensure that the SQL Agent Alert + Sev17 does not exist, or that the SQL Agent Alert + Msg825 does not exist. +#> +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlAgentAlert 'Remove_Sev17' + { + Ensure = 'Absent' + Name = 'Sev17' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + } + + SqlAgentAlert 'Remove_Msg825' + { + Ensure = 'Absent' + Name = 'Msg825' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + } + } +} diff --git a/source/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 b/source/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 new file mode 100644 index 000000000..54d38d70b --- /dev/null +++ b/source/Examples/Resources/SqlAgentFailsafe/1-AddFailsafe.ps1 @@ -0,0 +1,22 @@ +<# + .DESCRIPTION + This example shows how to ensure that the SQL Agent + Failsafe Operator 'FailsafeOp' exists with the correct Notification. +#> + +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlAgentFailsafe 'Add_FailsafeOp' + { + Ensure = 'Present' + Name = 'FailsafeOp' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + NotificationMethod = 'NotifyEmail' + } + } +} diff --git a/source/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 b/source/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 new file mode 100644 index 000000000..f2d9da01d --- /dev/null +++ b/source/Examples/Resources/SqlAgentFailsafe/2-RemoveFailsafe.ps1 @@ -0,0 +1,21 @@ +<# + .DESCRIPTION + This example shows how to ensure that the SQL Agent + failsafe operator FailsafeOp does not exist. +#> + +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlAgentFailsafe 'Remove_FailsafeOp' + { + Ensure = 'Absent' + Name = 'FailsafeOp' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + } + } +} diff --git a/source/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 b/source/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 new file mode 100644 index 000000000..2dd57cd99 --- /dev/null +++ b/source/Examples/Resources/SqlAgentOperator/1-AddOperator.ps1 @@ -0,0 +1,22 @@ +<# + .DESCRIPTION + This example shows how to ensure that the SQL Agent Operator + DbaTeam exists with the correct email address. +#> + +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlAgentOperator 'Add_DbaTeam' + { + Ensure = 'Present' + Name = 'DbaTeam' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + EmailAddress = 'dbateam@company.com' + } + } +} diff --git a/source/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 b/source/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 new file mode 100644 index 000000000..61d2e6af4 --- /dev/null +++ b/source/Examples/Resources/SqlAgentOperator/2-RemoveOperator.ps1 @@ -0,0 +1,22 @@ +<# + .DESCRIPTION + This example shows how to ensure that the SQL Agent Operator + DbaTeam does not exist. +#> + +Configuration Example +{ + + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlAgentOperator 'Remove_DbaTeam' + { + Ensure = 'Absent' + Name = 'DbaTeam' + ServerName = 'TestServer' + InstanceName = 'MSSQLServer' + } + } +} diff --git a/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 b/source/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 similarity index 76% rename from Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 rename to source/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 index 0992fa9ce..de4f1da84 100644 --- a/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 +++ b/source/Examples/Resources/SqlAlias/1-AddSqlAlias.ps1 @@ -1,46 +1,51 @@ <# -.EXAMPLE - This example shows how to ensure that the SQL Alias - SQLDSC* exists with Named Pipes or TCP. + .DESCRIPTION + This example shows how to ensure that the SQL Alias + SQLDSC* exists with Named Pipes or TCP. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlAlias Add_SqlAlias_TCP + node localhost + { + SqlAlias 'Add_SqlAlias_TCP' { Ensure = 'Present' Name = 'SQLDSC-TCP' ServerName = 'sqltest.company.local\DSC' Protocol = 'TCP' TcpPort = 1777 + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlAlias Add_SqlAlias_TCPUseDynamicTcpPort + SqlAlias 'Add_SqlAlias_TCPUseDynamicTcpPort' { Ensure = 'Present' Name = 'SQLDSC-DYN' ServerName = 'sqltest.company.local\DSC' Protocol = 'TCP' UseDynamicTcpPort = $true + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlAlias Add_SqlAlias_NP + SqlAlias 'Add_SqlAlias_NP' { Ensure = 'Present' Name = 'SQLDSC-NP' ServerName = '\\sqlnode\PIPE\sql\query' Protocol = 'NP' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 b/source/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 similarity index 71% rename from Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 rename to source/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 index 30a93b25e..4426bea8a 100644 --- a/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 +++ b/source/Examples/Resources/SqlAlias/2-RemoveSqlAlias.ps1 @@ -1,36 +1,40 @@ <# -.EXAMPLE - This example shows how to ensure that the SQL Alias - SQLDSC* does not exist with Named Pipes or TCP. + .DESCRIPTION + This example shows how to ensure that the SQL Alias + SQLDSC* does not exist with Named Pipes or TCP. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlAlias Remove_SqlAlias_TCP + node localhost + { + SqlAlias 'Remove_SqlAlias_TCP' { Ensure = 'Absent' Name = 'SQLDSC-TCP' ServerName = 'sqltest.company.local\DSC' Protocol = 'TCP' TcpPort = 1777 + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlAlias Remove_SqlAlias_NP + SqlAlias 'Remove_SqlAlias_NP' { Ensure = 'Absent' Name = 'SQLDSC-NP' ServerName = '\\sqlnode\PIPE\sql\query' Protocol = 'NP' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 b/source/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 similarity index 73% rename from Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 rename to source/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 index c7d0acd83..3ea3eaa4c 100644 --- a/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 +++ b/source/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to enable SQL Server Always On high availability and - disaster recovery (HADR). + .DESCRIPTION + This example shows how to enable SQL Server Always On high availability and + disaster recovery (HADR). #> Configuration Example { @@ -12,7 +12,7 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 b/source/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 similarity index 73% rename from Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 rename to source/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 index ba8876e6d..7b24f63d3 100644 --- a/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 +++ b/source/Examples/Resources/SqlAlwaysOnService/2-DisableAlwaysOn.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to disable SQL Server Always On high availability and - disaster recovery (HADR). + .DESCRIPTION + This example shows how to disable SQL Server Always On high availability and + disaster recovery (HADR). #> Configuration Example { @@ -12,7 +12,7 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/source/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 b/source/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 new file mode 100644 index 000000000..91904cf1a --- /dev/null +++ b/source/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 @@ -0,0 +1,43 @@ +<# + .DESCRIPTION + This example shows how to create a database with + the database name equal to 'Contoso'. + + The second example shows how to create a database + with a different collation. +#> +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlDatabase 'Create_Database' + { + Ensure = 'Present' + ServerName = 'sqltest.company.local' + InstanceName = 'DSC' + Name = 'Contoso' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + + SqlDatabase 'Create_Database_with_different_collation' + { + Ensure = 'Present' + ServerName = 'sqltest.company.local' + InstanceName = 'DSC' + Name = 'AdventureWorks' + Collation = 'SQL_Latin1_General_Pref_CP850_CI_AS' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 b/source/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 new file mode 100644 index 000000000..e8923964b --- /dev/null +++ b/source/Examples/Resources/SqlDatabase/2-DeleteDatabase.ps1 @@ -0,0 +1,29 @@ +<# + .DESCRIPTION + This example shows how to remove a database with + the database name equal to 'AdventureWorks'. +#> +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlDatabase 'Delete_Database' + { + Ensure = 'Absent' + ServerName = 'sqltest.company.local' + InstanceName = 'DSC' + Name = 'AdventureWorks' + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 b/source/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 similarity index 65% rename from Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 rename to source/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 index c97a9af9f..acd6a6d07 100644 --- a/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 +++ b/source/Examples/Resources/SqlDatabaseDefaultLocation/1-SetDatabaseDefaultLocation.ps1 @@ -1,11 +1,11 @@ <# -.EXAMPLE - This example shows how to manage database default locations for Data, Logs, and Backups for SQL Server. + .DESCRIPTION + This example shows how to manage database default locations for Data, Logs, and Backups for SQL Server. - In the event this is applied to a Failover Cluster Instance (FCI), the - ProcessOnlyOnActiveNode property will tell the Test-TargetResource function - to evaluate if any changes are needed if the node is actively hosting the - SQL Server Instance. + In the event this is applied to a Failover Cluster Instance (FCI), the + ProcessOnlyOnActiveNode property will tell the Test-TargetResource function + to evaluate if any changes are needed if the node is actively hosting the + SQL Server Instance. #> Configuration Example { @@ -16,37 +16,40 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Data + SqlDatabaseDefaultLocation 'Set_SqlDatabaseDefaultDirectory_Data' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' ProcessOnlyOnActiveNode = $true Type = 'Data' Path = 'C:\Program Files\Microsoft SQL Server' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Log + SqlDatabaseDefaultLocation 'Set_SqlDatabaseDefaultDirectory_Log' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' ProcessOnlyOnActiveNode = $true Type = 'Log' Path = 'C:\Program Files\Microsoft SQL Server' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseDefaultLocation Set_SqlDatabaseDefaultDirectory_Backup + SqlDatabaseDefaultLocation 'Set_SqlDatabaseDefaultDirectory_Backup' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' ProcessOnlyOnActiveNode = $true Type = 'Backup' Path = 'C:\Program Files\Microsoft SQL Server' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 b/source/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 similarity index 76% rename from Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 rename to source/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 index ed823b5ba..442e55b20 100644 --- a/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 +++ b/source/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to ensure that the user account CONTOSO\SQLAdmin - is "Owner" of SQL database "AdventureWorks". + .DESCRIPTION + This example shows how to ensure that the user account CONTOSO\SQLAdmin + is "Owner" of SQL database "AdventureWorks". #> Configuration Example { @@ -12,45 +12,49 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerLogin Add_SqlServerLogin_SQLAdmin_DSC + SqlServerLogin 'Add_SqlServerLogin_SQLAdmin_DSC' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' LoginType = 'WindowsUser' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerLogin Add_SqlServerLogin_SQLAdmin_DSC2 + SqlServerLogin 'Add_SqlServerLogin_SQLAdmin_DSC2' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' LoginType = 'WindowsUser' ServerName = 'sqltest.company.local' InstanceName = 'DSC2' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseOwner Set_SqlDatabaseOwner_SQLAdmin_DSC + SqlDatabaseOwner 'Set_SqlDatabaseOwner_SQLAdmin_DSC' { Name = 'CONTOSO\SQLAdmin' Database = 'AdventureWorks' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseOwner Set_SqlDatabaseOwner_SQLAdmin_DSC2 + SqlDatabaseOwner 'Set_SqlDatabaseOwner_SQLAdmin_DSC2' { Name = 'CONTOSO\SQLAdmin' Database = 'AdventureWorks' ServerName = 'sqltest.company.local' InstanceName = 'DSC2' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 b/source/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 similarity index 77% rename from Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 rename to source/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 index 218e356b1..07afa49ef 100644 --- a/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 +++ b/source/Examples/Resources/SqlDatabasePermission/1-GrantDatabasePermissions.ps1 @@ -1,41 +1,45 @@ <# -.DESCRIPTION - This example shows how to ensure that the user account CONTOSO\SQLAdmin - has "Connect" and "Update" SQL Permissions for database "AdventureWorks". + .DESCRIPTION + This example shows how to ensure that the user account CONTOSO\SQLAdmin + has "Connect" and "Update" SQL Permissions for database "AdventureWorks". #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerLogin Add_SqlServerLogin_SQLAdmin + node localhost + { + SqlServerLogin 'Add_SqlServerLogin_SQLAdmin' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' LoginType = 'WindowsUser' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerLogin Add_SqlServerLogin_SQLUser + SqlServerLogin 'Add_SqlServerLogin_SQLUser' { Ensure = 'Present' Name = 'CONTOSO\SQLUser' LoginType = 'WindowsUser' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabasePermission Grant_SqlDatabasePermissions_SQLAdmin_Db01 + SqlDatabasePermission 'Grant_SqlDatabasePermissions_SQLAdmin_Db01' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -44,10 +48,11 @@ Configuration Example Permissions = 'Connect', 'Update' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabasePermission Grant_SqlDatabasePermissions_SQLUser_Db01 + SqlDatabasePermission 'Grant_SqlDatabasePermissions_SQLUser_Db01' { Ensure = 'Present' Name = 'CONTOSO\SQLUser' @@ -56,10 +61,11 @@ Configuration Example Permissions = 'Connect', 'Update' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabasePermission Grant_SqlDatabasePermissions_SQLAdmin_Db02 + SqlDatabasePermission 'Grant_SqlDatabasePermissions_SQLAdmin_Db02' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -68,6 +74,7 @@ Configuration Example Permissions = 'Connect', 'Update' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 b/source/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 similarity index 70% rename from Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 rename to source/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 index bc0d052a6..5a08175ed 100644 --- a/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 +++ b/source/Examples/Resources/SqlDatabasePermission/2-RevokeDatabasePermissions.ps1 @@ -1,21 +1,23 @@ <# -.DESCRIPTION - This example shows how to ensure that the user account CONTOSO\SQLAdmin - hasn't "Select" and "Create Table" SQL Permissions for database "AdventureWorks". + .DESCRIPTION + This example shows how to ensure that the user account CONTOSO\SQLAdmin + hasn't "Select" and "Create Table" SQL Permissions for database "AdventureWorks". #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlDatabasePermission RevokeGrant_SqlDatabasePermissions_SQLAdmin + node localhost + { + SqlDatabasePermission 'RevokeGrant_SqlDatabasePermissions_SQLAdmin' { Ensure = 'Absent' Name = 'CONTOSO\SQLAdmin' @@ -24,10 +26,11 @@ Configuration Example Permissions = 'Connect', 'Update' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabasePermission RevokeDeny_SqlDatabasePermissions_SQLAdmin + SqlDatabasePermission 'RevokeDeny_SqlDatabasePermissions_SQLAdmin' { Ensure = 'Absent' Name = 'CONTOSO\SQLAdmin' @@ -36,6 +39,7 @@ Configuration Example Permissions = 'Select', 'Create Table' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 b/source/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 similarity index 78% rename from Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 rename to source/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 index 672bf4d74..59877ef3e 100644 --- a/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 +++ b/source/Examples/Resources/SqlDatabasePermission/3-DenyDatabasePermissions.ps1 @@ -1,41 +1,45 @@ <# -.DESCRIPTION - This example shows how to ensure that the user account CONTOSO\SQLAdmin - has "Connect" and "Update" SQL Permissions for database "AdventureWorks". + .DESCRIPTION + This example shows how to ensure that the user account CONTOSO\SQLAdmin + has "Connect" and "Update" SQL Permissions for database "AdventureWorks". #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerLogin Add_SqlServerLogin_SQLAdmin + node localhost + { + SqlServerLogin 'Add_SqlServerLogin_SQLAdmin' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' LoginType = 'WindowsUser' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerLogin Add_SqlServerLogin_SQLUser + SqlServerLogin 'Add_SqlServerLogin_SQLUser' { Ensure = 'Present' Name = 'CONTOSO\SQLUser' LoginType = 'WindowsUser' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabasePermission Deny_SqlDatabasePermissions_SQLAdmin_Db01 + SqlDatabasePermission 'Deny_SqlDatabasePermissions_SQLAdmin_Db01' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -44,10 +48,11 @@ Configuration Example Permissions = 'Select', 'Create Table' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabasePermission Deny_SqlDatabasePermissions_SQLUser_Db01 + SqlDatabasePermission 'Deny_SqlDatabasePermissions_SQLUser_Db01' { Ensure = 'Present' Name = 'CONTOSO\SQLUser' @@ -56,10 +61,11 @@ Configuration Example Permissions = 'Select', 'Create Table' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabasePermission Deny_SqlDatabasePermissions_SQLAdmin_Db02 + SqlDatabasePermission 'Deny_SqlDatabasePermissions_SQLAdmin_Db02' { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -68,6 +74,7 @@ Configuration Example Permissions = 'Select', 'Create Table' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 b/source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 similarity index 74% rename from Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 rename to source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 index afc8483e5..e984228db 100644 --- a/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 +++ b/source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to set the Recovery Model - to "Full" for SQL database "AdventureWorks". + .DESCRIPTION + This example shows how to set the Recovery Model + to "Full" for SQL database "AdventureWorks". #> Configuration Example @@ -13,43 +13,47 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabase Add_SqlDatabaseAdventureworks + SqlDatabase 'Add_SqlDatabaseAdventureworks' { Ensure = 'Present' Name = 'Adventureworks' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabase Add_SqlDatabaseAdventureWorks2012 + SqlDatabase 'Add_SqlDatabaseAdventureWorks2012' { Ensure = 'Present' Name = 'AdventureWorks2012' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseRecoveryModel Set_SqlDatabaseRecoveryModel_Adventureworks + SqlDatabaseRecoveryModel 'Set_SqlDatabaseRecoveryModel_Adventureworks' { Name = 'Adventureworks' RecoveryModel = 'Full' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseRecoveryModel Set_SqlDatabaseRecoveryModel_AdventureWorks2012 + SqlDatabaseRecoveryModel 'Set_SqlDatabaseRecoveryModel_AdventureWorks2012' { Name = 'AdventureWorks2012' RecoveryModel = 'Simple' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 b/source/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 similarity index 70% rename from Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 rename to source/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 index d5c43ad5a..45be8d759 100644 --- a/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 +++ b/source/Examples/Resources/SqlDatabaseRole/1-AddDatabaseRole.ps1 @@ -1,7 +1,8 @@ <# -.EXAMPLE - This example shows how to ensure that the database roles named ReportEditor and ReportViewer are present in the - AdventureWorks database on instance sqltest.company.local\DSC. + .DESCRIPTION + This example shows how to ensure that the database roles named ReportEditor + and ReportViewer are present in the AdventureWorks database on instance + sqltest.company.local\DSC. #> Configuration Example @@ -13,27 +14,29 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseRole ReportEditor_AddRole + SqlDatabaseRole 'ReportEditor_AddRole' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' Database = 'AdventureWorks' Name = 'ReportEditor' Ensure = 'Present' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseRole ReportViewer_AddRole + SqlDatabaseRole 'ReportViewer_AddRole' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' Database = 'AdventureWorks' Name = 'ReportViewer' Ensure = 'Present' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 b/source/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 similarity index 64% rename from Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 rename to source/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 index 6a13bfdeb..557bfc105 100644 --- a/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 +++ b/source/Examples/Resources/SqlDatabaseRole/2-RemoveDatabaseRole.ps1 @@ -1,7 +1,8 @@ <# -.EXAMPLE - This example shows how to ensure that the database role named ReportViewer is not present in the AdventureWorks - database on instance sqltest.company.local\DSC. + .DESCRIPTION + This example shows how to ensure that the database role named + ReportViewer is not present in the AdventureWorks database on + instance sqltest.company.local\DSC. #> Configuration Example @@ -13,17 +14,18 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseRole ReportViewer_DropRole + SqlDatabaseRole 'ReportViewer_DropRole' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' Database = 'AdventureWorks' Name = 'ReportViewer' Ensure = 'Absent' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1 b/source/Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1 similarity index 56% rename from Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1 rename to source/Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1 index eb7a7bc24..7bb0fbe3d 100644 --- a/Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1 +++ b/source/Examples/Resources/SqlDatabaseRole/3-EnforceDatabaseRoleMembers.ps1 @@ -1,25 +1,27 @@ <# -.EXAMPLE - This example shows how to do the following: + .DESCRIPTION + This example shows how to do the following: - 1. Ensure that the database role named ReportViewer is present in the AdventureWorks database on instance - sqltest.company.local\DSC - 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will always be the only members of the role + 1. Ensure that the database role named ReportViewer is present in the + AdventureWorks database on instance sqltest.company.local\DSC. + 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will always be + the only members of the role. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseRole ReportViewer_EnforceRoleMembers + SqlDatabaseRole 'ReportViewer_EnforceRoleMembers' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' @@ -27,6 +29,7 @@ Configuration Example Name = 'ReportViewer' Members = @('CONTOSO\Barbara', 'CONTOSO\Fred') Ensure = 'Present' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1 b/source/Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1 similarity index 56% rename from Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1 rename to source/Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1 index a7b35d465..b8c33b979 100644 --- a/Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1 +++ b/source/Examples/Resources/SqlDatabaseRole/4-MembersToIncludeInDatabaseRole.ps1 @@ -1,25 +1,27 @@ <# -.EXAMPLE - This example shows how to do the following: + .DESCRIPTION + This example shows how to do the following: - 1. Ensure that the database role named ReportViewer is present in the AdventureWorks database on instance - sqltest.company.local\DSC - 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will always be members of the role + 1. Ensure that the database role named ReportViewer is present in the + AdventureWorks database on instance sqltest.company.local\DSC. + 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will always be + members of the role. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseRole ReportViewer_IncludeRoleMembers + SqlDatabaseRole 'ReportViewer_IncludeRoleMembers' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' @@ -27,6 +29,7 @@ Configuration Example Name = 'ReportViewer' MembersToInclude = @('CONTOSO\Barbara', 'CONTOSO\Fred') Ensure = 'Present' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1 b/source/Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1 similarity index 57% rename from Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1 rename to source/Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1 index 99415f548..760d21bf9 100644 --- a/Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1 +++ b/source/Examples/Resources/SqlDatabaseRole/5-MembersToExcludeFromDatabaseRole.ps1 @@ -1,25 +1,27 @@ <# -.EXAMPLE - This example shows how to do the following: + .DESCRIPTION + This example shows how to do the following: - 1. Ensure that the database role named ReportViewer is present in the AdventureWorks database on instance - sqltest.company.local\DSC - 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will never be members of the role + 1. Ensure that the database role named ReportViewer is present in the + AdventureWorks database on instance sqltest.company.local\DSC. + 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will never be + members of the role. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseRole ReportViewer_ExcludeRoleMembers + SqlDatabaseRole 'ReportViewer_ExcludeRoleMembers' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' @@ -27,6 +29,7 @@ Configuration Example Name = 'ReportViewer' MembersToExclude = @('CONTOSO\Barbara', 'CONTOSO\Fred') Ensure = 'Present' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1 b/source/Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1 similarity index 55% rename from Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1 rename to source/Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1 index c1fad2191..d3cb47d6a 100644 --- a/Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1 +++ b/source/Examples/Resources/SqlDatabaseRole/6-MembersToIncludeAndExcludeInDatabaseRole.ps1 @@ -1,11 +1,13 @@ <# -.EXAMPLE - This example shows how to do the following: + .DESCRIPTION + This example shows how to do the following: - 1. Ensure that the database role named ReportViewer is present in the AdventureWorks database on instance - sqltest.company.local\DSC - 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will always be members of the role - 3. Ensure that the user CONSOSO\Intern1 will never be a member of the role + 1. Ensure that the database role named ReportViewer is present in the + AdventureWorks database on instance sqltest.company.local\DSC. + 2. Ensure that users CONTOSO\Barbara and CONTOSO\Fred will always be + members of the role. + 3. Ensure that the user CONSOSO\Intern1 will never be a member of the + role. #> Configuration Example @@ -17,11 +19,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseRole ReportViewer_IncludeAndExcludeRoleMembers + SqlDatabaseRole 'ReportViewer_IncludeAndExcludeRoleMembers' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' @@ -30,6 +32,7 @@ Configuration Example MembersToInclude = @('CONTOSO\Barbara', 'CONTOSO\Fred') MembersToExclude = @('CONTOSO\Intern1') Ensure = 'Present' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1 b/source/Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1 similarity index 87% rename from Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1 rename to source/Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1 index 302b1df1b..a81609e04 100644 --- a/Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1 +++ b/source/Examples/Resources/SqlDatabaseUser/1-AddDatabaseUserWithLogin.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to ensure that the database users ReportAdmin, CONTOSO\ReportEditors, and CONTOSO\ReportViewers are present in the AdventureWorks database in the instance sqltest.company.local\DSC. @@ -13,11 +13,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseUser ReportAdmin_AddUser + SqlDatabaseUser 'ReportAdmin_AddUser' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' @@ -29,7 +29,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseUser ContosoReportEditor_AddUser + SqlDatabaseUser 'ContosoReportEditor_AddUser' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' @@ -41,7 +41,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseUser ContosoReportViewer_AddUser + SqlDatabaseUser 'ContosoReportViewer_AddUser' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' diff --git a/Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1 b/source/Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1 similarity index 86% rename from Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1 rename to source/Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1 index 129aeee24..cfe19a71e 100644 --- a/Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1 +++ b/source/Examples/Resources/SqlDatabaseUser/2-AddDatabaseUserWithoutLogin.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to ensure that the database user User1 are present in the AdventureWorks database in the instance sqltest.company.local\DSC. #> @@ -12,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseUser AddUser1 + SqlDatabaseUser 'AddUser1' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' diff --git a/Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1 b/source/Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1 similarity index 87% rename from Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1 rename to source/Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1 index 8c1a80ae5..282109054 100644 --- a/Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1 +++ b/source/Examples/Resources/SqlDatabaseUser/3-AddDatabaseUserMappedToAsymmetricKey.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to ensure that the database user User1 are mapped to the asymmetric key Key1 in the AdventureWorks database in the instance sqltest.company.local\DSC. @@ -13,11 +13,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseUser ReportAdmin_AddUser + SqlDatabaseUser 'ReportAdmin_AddUser' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' diff --git a/Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1 b/source/Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1 similarity index 87% rename from Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1 rename to source/Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1 index a45939d35..6e0d02076 100644 --- a/Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1 +++ b/source/Examples/Resources/SqlDatabaseUser/4-AddDatabaseUserMappedToCertificate.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to ensure that the database user User1 are mapped to the certificate Certificate1 in the AdventureWorks database in the instance sqltest.company.local\DSC. @@ -13,11 +13,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseUser ReportAdmin_AddUser + SqlDatabaseUser 'ReportAdmin_AddUser' { ServerName = 'sqltest.company.local' InstanceName = 'DSC' diff --git a/Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1 b/source/Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1 similarity index 85% rename from Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1 rename to source/Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1 index 00aa9d325..7c24e507b 100644 --- a/Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1 +++ b/source/Examples/Resources/SqlDatabaseUser/5-RemoveDatabaseUser.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to ensure that the database user CONTOSO\ReportViewers is absent from the AdventureWorks database in the instance sqltest.company.local\DSC. #> @@ -12,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlDatabaseUser ContosoReportViewer_RemoveUser + SqlDatabaseUser 'ContosoReportViewer_RemoveUser' { Ensure = 'Absent' ServerName = 'sqltest.company.local' diff --git a/source/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 b/source/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 new file mode 100644 index 000000000..503c07f18 --- /dev/null +++ b/source/Examples/Resources/SqlRS/1-DefaultConfiguration.ps1 @@ -0,0 +1,23 @@ +<# + .DESCRIPTION + This example performs a default SQL Server Reporting Services configuration. + It will initialize SQL Server Reporting Services and register default + Report Server Web Service and Report Manager URLs. + + Report Server Web Service: http://localhost:80/ReportServer + Report Manager: http://localhost:80/Reports +#> +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlRS 'DefaultConfiguration' + { + InstanceName = 'MSSQLSERVER' + DatabaseServerName = 'localhost' + DatabaseInstanceName = 'MSSQLSERVER' + } + } +} diff --git a/source/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 b/source/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 new file mode 100644 index 000000000..46211f0a0 --- /dev/null +++ b/source/Examples/Resources/SqlRS/2-CustomConfiguration.ps1 @@ -0,0 +1,34 @@ +<# + .DESCRIPTION + This example performs a custom SQL Server Reporting Services configuration. + It will initialize SQL Server Reporting Services and register the below + custom Report Server Web Service and Report Manager URLs. + + Report Server Web Service: + http://localhost:80/MyReportServer + https://localhost:443/MyReportServer + + Report Manager: + http://localhost:80/MyReports + https://localhost:443/MyReports + + Note: this resource does not currently handle SSL bindings for HTTPS endpoints. +#> +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlRS 'DefaultConfiguration' + { + InstanceName = 'MSSQLSERVER' + DatabaseServerName = 'localhost' + DatabaseInstanceName = 'MSSQLSERVER' + ReportServerVirtualDirectory = 'MyReportServer' + ReportsVirtualDirectory = 'MyReports' + ReportServerReservedUrl = @('http://+:80', 'https://+:443') + ReportsReservedUrl = @('http://+:80', 'https://+:443') + } + } +} diff --git a/source/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 b/source/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 new file mode 100644 index 000000000..0e8041cca --- /dev/null +++ b/source/Examples/Resources/SqlRS/3-CustomConfigurationUsingSsl.ps1 @@ -0,0 +1,30 @@ +<# + .DESCRIPTION + This example performs a custom SQL Server Reporting Services configuration. + It will initialize SQL Server Reporting Services and register the below + custom Report Server Web Service and Report Manager URLs and enable SSL. + + Report Server Web Service: https://localhost:443/MyReportServer () + Report Manager: https://localhost:443/MyReports + + Note: this resource does not currently handle SSL bindings for HTTPS endpoints. +#> +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlRS 'DefaultConfiguration' + { + InstanceName = 'MSSQLSERVER' + DatabaseServerName = 'localhost' + DatabaseInstanceName = 'MSSQLSERVER' + ReportServerVirtualDirectory = 'MyReportServer' + ReportsVirtualDirectory = 'MyReports' + ReportServerReservedUrl = @('https://+:443') + ReportsReservedUrl = @('https://+:443') + UseSsl = $true + } + } +} diff --git a/source/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 b/source/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 new file mode 100644 index 000000000..a53da5259 --- /dev/null +++ b/source/Examples/Resources/SqlRS/4-CompleteWithTwoInstances.ps1 @@ -0,0 +1,120 @@ +<# + .DESCRIPTION + This example installs to instances where the first named instance is used for + the Reporting Services databases, and the second named instance is used for + Reporting Services. After installing the two instances, the configuration + performs a default SQL Server Reporting Services configuration. It will + initialize SQL Server Reporting Services and register the default + Report Server Web Service and Report Manager URLs: + + Report Manager: http://localhost:80/Reports_RS + Report Server Web Service: http://localhost:80/ReportServer_RS +#> + +Configuration Example +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + $SqlInstallCredential, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + $SqlServiceCredential, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + $SqlAgentServiceCredential, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + $ReportingServicesServiceCredential + ) + + Import-DscResource -ModuleName PSDscResources -ModuleVersion '2.12.0.0' + Import-DscResource -ModuleName 'SqlServerDsc' + + Node localhost + { + WindowsFeature 'NetFramework45' + { + Name = 'NET-Framework-45-Core' + Ensure = 'Present' + } + + SqlSetup 'InstallDatabaseEngine' + { + InstanceName = 'RSDB' + Features = 'SQLENGINE' + SourcePath = 'Z:\Sql2016Media' + BrowserSvcStartupType = 'Automatic' + SQLCollation = 'Finnish_Swedish_CI_AS' + SQLSvcAccount = $SqlServiceCredential + AgtSvcAccount = $SqlAgentServiceCredential + InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' + InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' + UpdateEnabled = 'False' + + SQLSysAdminAccounts = @( + $SqlAdministratorCredential.UserName + ) + + PsDscRunAsCredential = $SqlInstallCredential + + DependsOn = @( + '[WindowsFeature]NetFramework45' + ) + } + + SqlSetup 'InstallReportingServicesInstance' + { + InstanceName = 'RS' + Features = 'RS' + SourcePath = 'Z:\Sql2016Media' + BrowserSvcStartupType = 'Automatic' + RSSvcAccount = $ReportingServicesServiceCredential + InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' + InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' + UpdateEnabled = 'False' + + PsDscRunAsCredential = $SqlInstallCredential + + DependsOn = @( + '[WindowsFeature]NetFramework45' + '[SqlSetup]InstallDatabaseEngine' + ) + } + + SqlRS 'ConfigureReportingServiceInstance' + { + # Instance name for the Reporting Services. + InstanceName = 'RS' + + <# + Instance for Reporting Services databases. + Tge value $env:COMPUTERNAME can only be used if the configuration + is compiled on the node that should contain the instance 'RSDB'. + If not, set to the node name. + #> + DatabaseServerName = $env:COMPUTERNAME + DatabaseInstanceName = 'RSDB' + + PsDscRunAsCredential = $SqlInstallCredential + + DependsOn = @( + '[SqlSetup]InstallReportingServicesInstance' + ) + } + } +} diff --git a/Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1 b/source/Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1 similarity index 91% rename from Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1 rename to source/Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1 index da99e9f55..4d061812d 100644 --- a/Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1 +++ b/source/Examples/Resources/SqlRSSetup/1-InstallReportingServices.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install a Microsoft SQL Server Reporting Service instance (2017 or newer). #> @@ -14,7 +14,7 @@ Configuration Example $SqlInstallCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1 b/source/Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1 similarity index 92% rename from Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1 rename to source/Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1 index 4c7a4f61a..700c1946f 100644 --- a/Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1 +++ b/source/Examples/Resources/SqlRSSetup/2-UninstallReportingServices.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install a Microsoft SQL Server Reporting Service instance (2017 or newer). #> @@ -14,7 +14,7 @@ Configuration Example $SqlInstallCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 b/source/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 similarity index 79% rename from Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 rename to source/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 index 8dd3a22c3..d3281ad29 100644 --- a/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 +++ b/source/Examples/Resources/SqlScript/1-RunScriptUsingSQLAuthentication.ps1 @@ -1,17 +1,18 @@ <# -.EXAMPLE - This example shows how to run SQL script using SQL Authentication. + .DESCRIPTION + This example shows how to run SQL script using SQL Authentication. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' Node localhost { diff --git a/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 b/source/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 similarity index 84% rename from Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 rename to source/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 index d780ce113..5ae191d6b 100644 --- a/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 +++ b/source/Examples/Resources/SqlScript/2-RunScriptUsingWindowsAuthentication.ps1 @@ -1,18 +1,20 @@ <# -.EXAMPLE - These two example shows how to run SQL script using Windows Authentication. - First example shows how the resource is run as account SYSTEM. And the second example shows how the resource is run with a user account. + .DESCRIPTION + These two example shows how to run SQL script using Windows Authentication. + First example shows how the resource is run as account SYSTEM. And the second + example shows how the resource is run with a user account. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $WindowsCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' Node localhost { diff --git a/Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1 b/source/Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1 similarity index 92% rename from Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1 rename to source/Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1 index 757533553..202b8f7cd 100644 --- a/Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1 +++ b/source/Examples/Resources/SqlScript/3-RunScriptCompleteExample.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows one way to create the SQL script files and how to run - those files. + .DESCRIPTION + This example shows one way to create the SQL script files and how to run + those files. #> $ConfigurationData = @{ @@ -36,6 +36,8 @@ END SetSqlScript = @' CREATE DATABASE [$(DatabaseName)] '@ + # Not recommended in production. Only set here to pass CI. + PsDscAllowPlainTextPassword = $true } ) } @@ -50,10 +52,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { + node localhost + { Script 'CreateFile_GetSqlScript' { SetScript = { diff --git a/Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1 b/source/Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1 similarity index 77% rename from Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1 rename to source/Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1 index 303cf9f90..1499e757c 100644 --- a/Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1 +++ b/source/Examples/Resources/SqlScriptQuery/1-RunScriptUsingSQLAuthentication.ps1 @@ -1,17 +1,18 @@ <# -.EXAMPLE - This example shows how to run SQL script using SQL Authentication. + .DESCRIPTION + This example shows how to run SQL script using SQL Authentication. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' Node localhost { diff --git a/Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1 b/source/Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1 similarity index 80% rename from Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1 rename to source/Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1 index 4ca42215a..c6ac1e268 100644 --- a/Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1 +++ b/source/Examples/Resources/SqlScriptQuery/2-RunScriptUsingWindowsAuthentication.ps1 @@ -1,18 +1,20 @@ <# -.EXAMPLE - These two example shows how to run SQL script using Windows Authentication. - First example shows how the resource is run as account SYSTEM. And the second example shows how the resource is run with a user account. + .DESCRIPTION + These two example shows how to run SQL script using Windows Authentication. + First example shows how the resource is run as account SYSTEM. And the second + example shows how the resource is run with a user account. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $WindowsCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' Node localhost { diff --git a/source/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 b/source/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 new file mode 100644 index 000000000..7f6012022 --- /dev/null +++ b/source/Examples/Resources/SqlScriptQuery/3-RunScriptCompleteExample.ps1 @@ -0,0 +1,53 @@ +<# + .DESCRIPTION + This example uses the Configuration Data to pass the Query Strings fo SqlScriptQuery Resource. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + $SqlAdministratorCredential + ) + + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlScriptQuery 'CreateDatabase_ScriptDatabase1' + { + ServerInstance = "$($env:COMPUTERNAME)\DSCTEST" + + GetQuery = @' +SELECT Name FROM sys.databases WHERE Name = '$(DatabaseName)' FOR JSON AUTO +'@ + + TestQuery = @' +if (select count(name) from sys.databases where name = '$(DatabaseName)') = 0 +BEGIN + RAISERROR ('Did not find database [$(DatabaseName)]', 16, 1) +END +ELSE +BEGIN + PRINT 'Found database [$(DatabaseName)]' +END +'@ + + SetQuery = @' +CREATE DATABASE [$(DatabaseName)] +'@ + + Variable = @( + ('DatabaseName={0}' -f 'ScriptDatabase1') + ) + + QueryTimeout = 30 + + PsDscRunAsCredential = $SqlAdministratorCredential + } + } +} diff --git a/source/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 b/source/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 new file mode 100644 index 000000000..79fbc8906 --- /dev/null +++ b/source/Examples/Resources/SqlServerConfiguration/1-ConfigureTwoInstancesOnTheSameServerToEnableClr.ps1 @@ -0,0 +1,28 @@ +<# + .DESCRIPTION + This example shows how to configure two SQL Server instances on the same + server to have CLR enabled. + + .NOTES + To get all available options run sp_configure on the SQL Server instance, + or refer to https://msdn.microsoft.com/en-us/library/ms189631.aspx +#> + +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + foreach ($sqlInstance in @('CONTENT', 'DIST')) + { + SqlServerConfiguration ('SQLConfigCLR_{0}' -f $sqlInstance) + { + ServerName = $Node.NodeName + InstanceName = $sqlInstance + OptionName = 'clr enabled' + OptionValue = 1 + } + } + } +} diff --git a/source/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 b/source/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 new file mode 100644 index 000000000..79cac479a --- /dev/null +++ b/source/Examples/Resources/SqlServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 @@ -0,0 +1,27 @@ +<# + .DESCRIPTION + This example shows how to configure two SQL Server instances on the same + server to have the setting 'priority boost' enabled. + + .NOTES + To get all available options run sp_configure on the SQL Server instance, + or refer to https://msdn.microsoft.com/en-us/library/ms189631.aspx +#> + +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlServerConfiguration 'SQLConfigPriorityBoost' + { + + ServerName = 'localhost' + InstanceName = 'MSSQLSERVER' + OptionName = 'priority boost' + OptionValue = 1 + RestartService = $false + } + } +} diff --git a/source/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 b/source/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 new file mode 100644 index 000000000..6619e5525 --- /dev/null +++ b/source/Examples/Resources/SqlServerDatabaseMail/1-EnableDatabaseMail.ps1 @@ -0,0 +1,50 @@ +<# + .DESCRIPTION + This example will enable Database Mail on a SQL Server instance and + create a mail account with a default public profile. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.Management.Automation.PSCredential] + $SqlInstallCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlServerConfiguration 'EnableDatabaseMailXPs' + { + + ServerName = $Node.NodeName + InstanceName = 'DSCSQLTEST' + OptionName = 'Database Mail XPs' + OptionValue = 1 + RestartService = $false + } + + SqlServerDatabaseMail 'EnableDatabaseMail' + { + Ensure = 'Present' + ServerName = $Node.NodeName + InstanceName = 'DSCSQLTEST' + AccountName = 'MyMail' + ProfileName = 'MyMailProfile' + EmailAddress = 'NoReply@company.local' + ReplyToAddress = 'NoReply@company.local' + DisplayName = 'mail.company.local' + MailServerName = 'mail.company.local' + Description = 'Default mail account and profile.' + LoggingLevel = 'Normal' + TcpPort = 25 + + PsDscRunAsCredential = $SqlInstallCredential + } + } +} + diff --git a/Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1 b/source/Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1 similarity index 51% rename from Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1 rename to source/Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1 index ab58510a1..227935a0c 100644 --- a/Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1 +++ b/source/Examples/Resources/SqlServerDatabaseMail/2-DisableDatabaseMail.ps1 @@ -1,26 +1,8 @@ <# - .EXAMPLE + .DESCRIPTION This example will remove the mail profile and the mail account and disable Database Mail on a SQL Server instance. - #> -$ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - ServerName = $env:COMPUTERNAME - InstanceName = 'DSCSQLTEST' - - MailServerName = 'mail.company.local' - AccountName = 'MyMail' - ProfileName = 'MyMailProfile' - EmailAddress = 'NoReply@company.local' - Description = 'Default mail account and profile.' - LoggingLevel = 'Normal' - TcpPort = 25 - } - ) -} Configuration Example { @@ -38,12 +20,12 @@ Configuration Example SqlServerDatabaseMail 'DisableDatabaseMail' { Ensure = 'Absent' - ServerName = $Node.ServerName - InstanceName = $Node.InstanceName - AccountName = $Node.AccountName - ProfileName = $Node.ProfileName - EmailAddress = $Node.EmailAddress - MailServerName = $Node.MailServerName + ServerName = $Node.NodeName + InstanceName = 'DSCSQLTEST' + AccountName = 'MyMail' + ProfileName = 'MyMailProfile' + EmailAddress = 'NoReply@company.local' + MailServerName = 'mail.company.local' PsDscRunAsCredential = $SqlInstallCredential } @@ -55,8 +37,8 @@ Configuration Example SqlServerConfiguration 'DisableDatabaseMailXPs' { - ServerName = $Node.ServerName - InstanceName = $Node.InstanceName + ServerName = $Node.NodeName + InstanceName = 'DSCSQLTEST' OptionName = 'Database Mail XPs' OptionValue = 0 RestartService = $false diff --git a/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 b/source/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 similarity index 72% rename from Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 rename to source/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 index be4ee6a8a..f69bd46ba 100644 --- a/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 +++ b/source/Examples/Resources/SqlServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 @@ -1,6 +1,7 @@ <# - .EXAMPLE - This example will add a Database Mirror endpoint, to two instances, using the default values. + .DESCRIPTION + This example will add a Database Mirror endpoint, to two instances, using + the default values. #> Configuration Example @@ -12,11 +13,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerEndpoint SQLConfigureEndpoint-Instance1 + SqlServerEndpoint 'SQLConfigureEndpoint-Instance1' { EndpointName = 'HADR' InstanceName = 'INST1' @@ -24,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerEndpoint SQLConfigureEndpoint-Instances2 + SqlServerEndpoint 'SQLConfigureEndpoint-Instances2' { EndpointName = 'HADR' InstanceName = 'INST2' diff --git a/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1 b/source/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1 similarity index 79% rename from Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1 rename to source/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1 index e3e4c4d8c..e72c1c80e 100644 --- a/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1 +++ b/source/Examples/Resources/SqlServerEndpoint/2-CreateEndpointWithSpecificPortIPAddressOwner.ps1 @@ -1,6 +1,7 @@ <# - .EXAMPLE - This example will add a Database Mirror endpoint with specific listener port, listener IP address and owner. + .DESCRIPTION + This example will add a Database Mirror endpoint with specific listener port, + listener IP address and owner. #> Configuration Example { @@ -11,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerEndpoint SQLConfigureEndpoint + SqlServerEndpoint 'SQLConfigureEndpoint' { Ensure = 'Present' diff --git a/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 b/source/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 similarity index 70% rename from Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 rename to source/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 index b792bb17a..6d4d02403 100644 --- a/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 +++ b/source/Examples/Resources/SqlServerEndpoint/3-RemoveEndpoint.ps1 @@ -1,7 +1,6 @@ <# - .EXAMPLE + .DESCRIPTION This example will remove an Database Mirror endpoint from two instances. - #> Configuration Example { @@ -12,26 +11,26 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerEndpoint SQLConfigureEndpoint-Instance1 + SqlServerEndpoint 'SQLConfigureEndpoint-Instance1' { Ensure = 'Absent' EndpointName = 'HADR' - InstanceName = 'INST1' + InstanceName = 'INST1' PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerEndpoint SQLConfigureEndpoint-Instance2 + SqlServerEndpoint 'SQLConfigureEndpoint-Instance2' { Ensure = 'Absent' EndpointName = 'HADR' - InstanceName = 'INST2' + InstanceName = 'INST2' PsDscRunAsCredential = $SqlAdministratorCredential } diff --git a/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 b/source/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 similarity index 77% rename from Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 rename to source/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 index 6679dbc56..89750531c 100644 --- a/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 +++ b/source/Examples/Resources/SqlServerEndpointPermission/1-AddConnectPermission.ps1 @@ -1,7 +1,7 @@ <# - .EXAMPLE - This example will add connect permission to the credentials provided in $SqlServiceCredential - to the endpoint named 'DefaultMirrorEndpoint'. + .DESCRIPTION + This example will add connect permission to the credentials provided in + $SqlServiceCredential to the endpoint named 'DefaultMirrorEndpoint'. #> Configuration Example { @@ -16,11 +16,11 @@ Configuration Example $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerEndpointPermission SQLConfigureEndpointPermission + SqlServerEndpointPermission 'SQLConfigureEndpointPermission' { Ensure = 'Present' ServerName = 'SQLTEST' diff --git a/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 b/source/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 similarity index 77% rename from Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 rename to source/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 index 59e2c4287..06c41f92f 100644 --- a/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 +++ b/source/Examples/Resources/SqlServerEndpointPermission/2-RemoveConnectPermission.ps1 @@ -1,7 +1,7 @@ <# - .EXAMPLE - This example will add connect permission to the credentials provided in $SqlServiceCredential - to the endpoint named 'DefaultMirrorEndpoint'. + .DESCRIPTION + This example will add connect permission to the credentials provided in + $SqlServiceCredential to the endpoint named 'DefaultMirrorEndpoint'. #> Configuration Example { @@ -16,11 +16,11 @@ Configuration Example $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerEndpointPermission SQLConfigureEndpointPermission + SqlServerEndpointPermission 'SQLConfigureEndpointPermission' { Ensure = 'Absent' ServerName = 'SQLTEST' diff --git a/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 b/source/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 similarity index 80% rename from Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 rename to source/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 index 387b5d6d8..334b457e8 100644 --- a/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 +++ b/source/Examples/Resources/SqlServerEndpointPermission/3-AddConnectPermissionToTwoReplicasEachWithDifferentServiceAccount.ps1 @@ -1,7 +1,8 @@ <# - .EXAMPLE - This example will 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. + .DESCRIPTION + This example will 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. #> $ConfigurationData = @{ @@ -9,6 +10,9 @@ $ConfigurationData = @{ @{ NodeName = '*' InstanceName = 'MSSQLSERVER' + + # Not recommended for production. Only set here to pass CI. + PsDscAllowPlainTextPassword = $true }, @{ @@ -40,11 +44,11 @@ Configuration Example $SqlServiceNode2Credential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node $AllNodes.Where{$_.Role -eq 'PrimaryReplica' }.NodeName { - SqlServerEndpointPermission SQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission 'SQLConfigureEndpointPermissionPrimary' { Ensure = 'Present' ServerName = $Node.NodeName @@ -56,7 +60,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerEndpointPermission SQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission 'SQLConfigureEndpointPermissionSecondary' { Ensure = 'Present' ServerName = $Node.NodeName @@ -71,7 +75,7 @@ Configuration Example Node $AllNodes.Where{ $_.Role -eq 'SecondaryReplica' }.NodeName { - SqlServerEndpointPermission SQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission 'SQLConfigureEndpointPermissionPrimary' { Ensure = 'Present' ServerName = $Node.NodeName @@ -83,7 +87,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerEndpointPermission SQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission 'SQLConfigureEndpointPermissionSecondary' { Ensure = 'Present' ServerName = $Node.NodeName diff --git a/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 b/source/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 similarity index 84% rename from Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 rename to source/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 index 818f9913f..a5101d89b 100644 --- a/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 +++ b/source/Examples/Resources/SqlServerEndpointPermission/4-RemoveConnectPermissionForTwoReplicasEachWithDifferentServiceAccount.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example will 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. #> @@ -9,6 +9,9 @@ $ConfigurationData = @{ @{ NodeName = '*' InstanceName = 'MSSQLSERVER' + + # Not recommended for production. Only set here to pass CI. + PsDscAllowPlainTextPassword = $true }, @{ @@ -40,11 +43,11 @@ Configuration Example $SqlServiceNode2Credential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node $AllNodes.Where{$_.Role -eq 'PrimaryReplica' }.NodeName { - SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission 'RemoveSQLConfigureEndpointPermissionPrimary' { Ensure = 'Absent' ServerName = $Node.NodeName @@ -56,7 +59,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission 'RemoveSQLConfigureEndpointPermissionSecondary' { Ensure = 'Absent' ServerName = $Node.NodeName @@ -71,7 +74,7 @@ Configuration Example Node $AllNodes.Where{ $_.Role -eq 'SecondaryReplica' }.NodeName { - SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionPrimary + SqlServerEndpointPermission 'RemoveSQLConfigureEndpointPermissionPrimary' { Ensure = 'Absent' ServerName = $Node.NodeName @@ -83,7 +86,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerEndpointPermission RemoveSQLConfigureEndpointPermissionSecondary + SqlServerEndpointPermission 'RemoveSQLConfigureEndpointPermissionSecondary' { Ensure = 'Absent' ServerName = $Node.NodeName diff --git a/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 b/source/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 similarity index 65% rename from Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 rename to source/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 index dee93c44c..220d7bf6e 100644 --- a/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 +++ b/source/Examples/Resources/SqlServerEndpointState/1-MakeSureEndpointIsStarted.ps1 @@ -1,15 +1,16 @@ <# - .EXAMPLE - This example will make sure that the endpoint DefaultMirrorEndpoint is in started state in the default instance, if not it will start the endpoint. - - .EXAMPLE - This example will make sure that the endpoint HADR is in started state in the default instance, if not it will start the endpoint. - - .EXAMPLE - This example will make sure that the endpoint DefaultMirrorEndpoint is in started state in the named instance INSTANCE1, if not it will start the endpoint. + .DESCRIPTION + This example will + - make sure that the endpoint DefaultMirrorEndpoint is in started state + in the default instance, if not it will start the endpoint. + - make sure that the endpoint HADR is in started state in the default + instance, if not it will start the endpoint. + - make sure that the endpoint DefaultMirrorEndpoint is in started state + in the named instance INSTANCE1, if not it will start the endpoint. .NOTES - There is three different scenarios in this example to validate the schema during unit testing. + There is three different scenarios in this example to validate the schema + during unit testing. #> Configuration Example { @@ -20,12 +21,12 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { # Start the DefaultMirrorEndpoint in the default instance - SqlServerEndpointState StartEndpoint1 + SqlServerEndpointState 'StartEndpoint1' { ServerName = 'SQLNODE01.company.local' InstanceName = 'MSSQLSERVER' @@ -36,7 +37,7 @@ Configuration Example } # Start the HADR in the default instance - SqlServerEndpointState StartEndpoint2 + SqlServerEndpointState 'StartEndpoint2' { ServerName = 'SQLNODE01.company.local' InstanceName = 'MSSQLSERVER' @@ -47,7 +48,7 @@ Configuration Example } # Start the DefaultMirrorEndpoint in the named instance INSTANCE1 - SqlServerEndpointState StartEndpoint3 + SqlServerEndpointState 'StartEndpoint3' { ServerName = 'SQLNODE01.company.local' InstanceName = 'INSTANCE1' diff --git a/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 b/source/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 similarity index 75% rename from Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 rename to source/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 index 1d49755aa..451482c54 100644 --- a/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 +++ b/source/Examples/Resources/SqlServerEndpointState/2-MakeSureEndpointIsStopped.ps1 @@ -1,6 +1,7 @@ <# - .EXAMPLE - This example will make sure that the endpoint DefaultMirrorEndpoint is in stopped state, if not it will stop the endpoint. + .DESCRIPTION + This example will make sure that the endpoint DefaultMirrorEndpoint is + in stopped state, if not it will stop the endpoint. #> Configuration Example { @@ -11,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerEndpointState StopEndpoint + SqlServerEndpointState 'StopEndpoint' { ServerName = 'SQLNODE01.company.local' InstanceName = 'MSSQLSERVER' diff --git a/Examples/Resources/SqlServerLogin/1-AddLogin.ps1 b/source/Examples/Resources/SqlServerLogin/1-AddLogin.ps1 similarity index 79% rename from Examples/Resources/SqlServerLogin/1-AddLogin.ps1 rename to source/Examples/Resources/SqlServerLogin/1-AddLogin.ps1 index c7c5f7dfe..422192277 100644 --- a/Examples/Resources/SqlServerLogin/1-AddLogin.ps1 +++ b/source/Examples/Resources/SqlServerLogin/1-AddLogin.ps1 @@ -1,17 +1,13 @@ <# -.EXAMPLE -This example shows how to ensure that the Windows user 'CONTOSO\WindowsUser' exists. - -.EXAMPLE -This example shows how to ensure that the Windows group 'CONTOSO\WindowsGroup' exists. - -.EXAMPLE -This example shows how to ensure that the SQL Login 'SqlLogin' exists. + .DESCRIPTION + This example shows how to ensure that the Windows user 'CONTOSO\WindowsUser', + Windows group 'CONTOSO\WindowsGroup', and the SQL Login 'SqlLogin' exists. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential, @@ -21,10 +17,11 @@ Configuration Example $LoginCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerLogin Add_WindowsUser + node localhost + { + SqlServerLogin 'Add_WindowsUser' { Ensure = 'Present' Name = 'CONTOSO\WindowsUser' @@ -34,7 +31,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerLogin Add_DisabledWindowsUser + SqlServerLogin 'Add_DisabledWindowsUser' { Ensure = 'Present' Name = 'CONTOSO\WindowsUser2' @@ -45,7 +42,7 @@ Configuration Example Disabled = $true } - SqlServerLogin Add_WindowsGroup + SqlServerLogin 'Add_WindowsGroup' { Ensure = 'Present' Name = 'CONTOSO\WindowsGroup' @@ -55,7 +52,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerLogin Add_SqlLogin + SqlServerLogin 'Add_SqlLogin' { Ensure = 'Present' Name = 'SqlLogin' diff --git a/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 b/source/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 similarity index 63% rename from Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 rename to source/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 index 489c1bb69..37d2c8a31 100644 --- a/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 +++ b/source/Examples/Resources/SqlServerLogin/2-RemoveLogin.ps1 @@ -1,20 +1,16 @@ <# -.EXAMPLE -This example shows how to remove the Windows user 'CONTOSO\WindowsUser'. - -.EXAMPLE -This example shows how to remove Windows group 'CONTOSO\WindowsGroup'. - -.EXAMPLE -This example shows how to remove the SQL Login 'SqlLogin'. + .DESCRIPTION + This example shows how to remove the Windows user 'CONTOSO\WindowsUser', + Windows group 'CONTOSO\WindowsGroup', and the SQL Login 'SqlLogin'. #> Configuration Example { - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerLogin Remove_WindowsUser + node localhost + { + SqlServerLogin 'Remove_WindowsUser' { Ensure = 'Absent' Name = 'CONTOSO\WindowsUser' @@ -23,7 +19,7 @@ Configuration Example InstanceName = 'DSC' } - SqlServerLogin Remove_WindowsGroup + SqlServerLogin 'Remove_WindowsGroup' { Ensure = 'Absent' Name = 'CONTOSO\WindowsGroup' @@ -32,7 +28,7 @@ Configuration Example InstanceName = 'DSC' } - SqlServerLogin Remove_SqlLogin + SqlServerLogin 'Remove_SqlLogin' { Ensure = 'Absent' Name = 'SqlLogin' diff --git a/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 b/source/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 similarity index 67% rename from Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 rename to source/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 index d4f7335ca..ec2018a7e 100644 --- a/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 +++ b/source/Examples/Resources/SqlServerMaxDop/1-SetMaxDopToOne.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to set max degree of parallelism server - configuration option with the value equal to 1. + .DESCRIPTION + This example shows how to set max degree of parallelism server + configuration option with the value equal to 1. #> Configuration Example { @@ -12,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerMaxDop Set_SQLServerMaxDop_ToOne + SqlServerMaxDop 'Set_SQLServerMaxDop_ToOne' { Ensure = 'Present' DynamicAlloc = $false diff --git a/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 b/source/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 similarity index 50% rename from Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 rename to source/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 index 01806cc43..92530dd99 100644 --- a/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 +++ b/source/Examples/Resources/SqlServerMaxDop/2-SetMaxDopToAuto.ps1 @@ -1,12 +1,12 @@ <# -.EXAMPLE - This example shows how to set max degree of parallelism server - configuration option with the automatic configuration. + .DESCRIPTION + This example shows how to set max degree of parallelism server + configuration option with the automatic configuration. - In the event this is applied to a Failover Cluster Instance (FCI), the - ProcessOnlyOnActiveNode property will tell the Test-TargetResource function - to evaluate if any changes are needed if the node is actively hosting the - SQL Server instance. + In the event this is applied to a Failover Cluster Instance (FCI), the + ProcessOnlyOnActiveNode property will tell the Test-TargetResource function + to evaluate if any changes are needed if the node is actively hosting the + SQL Server instance. #> Configuration Example { @@ -17,11 +17,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerMaxDop Set_SQLServerMaxDop_ToAuto + SqlServerMaxDop 'Set_SQLServerMaxDop_ToAuto' { Ensure = 'Present' DynamicAlloc = $true diff --git a/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 b/source/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 similarity index 63% rename from Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 rename to source/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 index caca57b29..b93308299 100644 --- a/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 +++ b/source/Examples/Resources/SqlServerMaxDop/3-SetMaxDopToDefault.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to set max degree of parallelism server - configuration option with the default configuration. + .DESCRIPTION + This example shows how to set max degree of parallelism server + configuration option with the default configuration. #> Configuration Example { @@ -12,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerMaxDop Set_SQLServerMaxDop_ToDefault + SqlServerMaxDop 'Set_SQLServerMaxDop_ToDefault' { Ensure = 'Absent' ServerName = 'sqltest.company.local' diff --git a/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 b/source/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 similarity index 68% rename from Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 rename to source/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 index 8db53fc66..09fa611d6 100644 --- a/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 +++ b/source/Examples/Resources/SqlServerMemory/1-SetMaxMemoryTo12GB.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to set the minimum and maximum memory - configuration option with the value equal to 1024 and 12288. + .DESCRIPTION + This example shows how to set the minimum and maximum memory + configuration option with the value equal to 1024 and 12288. #> Configuration Example { @@ -12,11 +12,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerMemory Set_SQLServerMaxMemory_To12GB + SqlServerMemory 'Set_SQLServerMaxMemory_To12GB' { Ensure = 'Present' DynamicAlloc = $false @@ -24,6 +24,7 @@ Configuration Example MaxMemory = 12288 ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 b/source/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 similarity index 51% rename from Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 rename to source/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 index 9fef55ba4..a51852f1f 100644 --- a/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 +++ b/source/Examples/Resources/SqlServerMemory/2-SetMaxMemoryToAuto.ps1 @@ -1,12 +1,12 @@ <# -.EXAMPLE - This example shows how to set the maximum memory - configuration option with the automatic configuration. + .DESCRIPTION + This example shows how to set the maximum memory + configuration option with the automatic configuration. - In the event this is applied to a Failover Cluster Instance (FCI), the - ProcessOnlyOnActiveNode property will tell the Test-TargetResource function - to evaluate if any changes are needed if the node is actively hosting the - SQL Server instance. + In the event this is applied to a Failover Cluster Instance (FCI), the + ProcessOnlyOnActiveNode property will tell the Test-TargetResource function + to evaluate if any changes are needed if the node is actively hosting the + SQL Server instance. #> Configuration Example { @@ -17,18 +17,19 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerMemory Set_SQLServerMaxMemory_ToAuto + SqlServerMemory 'Set_SQLServerMaxMemory_ToAuto' { Ensure = 'Present' DynamicAlloc = $true ServerName = 'sqltest.company.local' InstanceName = 'DSC' - PsDscRunAsCredential = $SqlAdministratorCredential ProcessOnlyOnActiveNode = $true + + PsDscRunAsCredential = $SqlAdministratorCredential } } } diff --git a/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 b/source/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 similarity index 65% rename from Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 rename to source/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 index e2fa5d5d7..150786261 100644 --- a/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 +++ b/source/Examples/Resources/SqlServerMemory/3-SetMinMemoryToFixedValueAndMaxMemoryToAuto.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to set the minimum memory to 2GB and the maximum memory - configuration option with the automatic configuration. + .DESCRIPTION + This example shows how to set the minimum memory to 2GB and the maximum memory + configuration option with the automatic configuration. #> Configuration Example { @@ -12,17 +12,18 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerMemory Set_SQLServerMinAndMaxMemory_ToAuto + SqlServerMemory 'Set_SQLServerMinAndMaxMemory_ToAuto' { Ensure = 'Present' DynamicAlloc = $true ServerName = 'sqltest.company.local' InstanceName = 'DSC' MinMemory = 2048 + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 b/source/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 similarity index 63% rename from Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 rename to source/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 index 0ac941c8d..4836367b7 100644 --- a/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 +++ b/source/Examples/Resources/SqlServerMemory/4-SetMaxMemoryToDefault.ps1 @@ -1,7 +1,7 @@ <# -.EXAMPLE - This example shows how to set the minimum and maximum memory - configuration option with the default configuration. + .DESCRIPTION + This example shows how to set the minimum and maximum memory + configuration option with the default configuration. #> Configuration Example { @@ -12,15 +12,16 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerMemory Set_SQLServerMaxMemory_ToDefault + SqlServerMemory 'Set_SQLServerMaxMemory_ToDefault' { Ensure = 'Absent' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 b/source/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 similarity index 64% rename from Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 rename to source/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 index 2722e5a1e..f2aef7e60 100644 --- a/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 +++ b/source/Examples/Resources/SqlServerNetwork/1-EnableTcpIpWithStaticPort.ps1 @@ -1,8 +1,8 @@ <# -.EXAMPLE - This example will enable TCP/IP protocol and set the custom static port to 4509. - When RestartService is set to $true the resource will also restart the SQL service. - The resource will be run as the account provided in $SystemAdministratorAccount. + .DESCRIPTION + This example will enable TCP/IP protocol and set the custom static port to 4509. + When RestartService is set to $true the resource will also restart the SQL service. + The resource will be run as the account provided in $SystemAdministratorAccount. #> Configuration Example { @@ -13,7 +13,7 @@ Configuration Example $SystemAdministratorAccount ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { @@ -25,6 +25,7 @@ Configuration Example TCPDynamicPort = $false TCPPort = 4509 RestartService = $true + PsDscRunAsCredential = $SystemAdministratorAccount } } diff --git a/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 b/source/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 similarity index 62% rename from Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 rename to source/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 index 6be3708eb..b9c14e829 100644 --- a/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 +++ b/source/Examples/Resources/SqlServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 @@ -1,8 +1,8 @@ <# -.EXAMPLE - This example will enable TCP/IP protocol and set the custom static port to 4509. - When RestartService is set to $true the resource will also restart the SQL service. - The resource will be run as the account provided in $SystemAdministratorAccount. + .DESCRIPTION + This example will enable TCP/IP protocol and set the custom static port to 4509. + When RestartService is set to $true the resource will also restart the SQL service. + The resource will be run as the account provided in $SystemAdministratorAccount. #> Configuration Example { @@ -13,7 +13,7 @@ Configuration Example $SystemAdministratorAccount ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { @@ -24,6 +24,7 @@ Configuration Example IsEnabled = $true TCPDynamicPort = $true RestartService = $true + PsDscRunAsCredential = $SystemAdministratorAccount } } diff --git a/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 b/source/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 similarity index 95% rename from Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 rename to source/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 index 460474b4a..fc0156106 100644 --- a/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 +++ b/source/Examples/Resources/SqlServerPermission/1-AddServerPermissionForLogin.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example will add the server permissions AlterAnyAvailabilityGroup and ViewServerState to the login 'NT AUTHORITY\SYSTEM' and 'NT SERVICE\ClusSvc' to the default instance. #> @@ -12,7 +12,7 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDSC + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 b/source/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 similarity index 85% rename from Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 rename to source/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 index 50ac429cd..08cb020b3 100644 --- a/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 +++ b/source/Examples/Resources/SqlServerPermission/2-RemoveServerPermissionForLogin.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example will remove the server permissions AlterAnyAvailabilityGroup and ViewServerState from the login 'NT AUTHORITY\SYSTEM'. #> @@ -12,12 +12,12 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDSC + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { # Add permission - SqlServerPermission SQLConfigureServerPermission + SqlServerPermission 'SQLConfigureServerPermission' { Ensure = 'Absent' ServerName = 'SQLNODE01.company.local' diff --git a/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 b/source/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 similarity index 73% rename from Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 rename to source/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 index 39575dd8a..37f1840e2 100644 --- a/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 +++ b/source/Examples/Resources/SqlServerReplication/1-ConfigureInstanceAsDistributor.ps1 @@ -1,6 +1,6 @@ <# -.EXAMPLE - This example shows how to configure a SQL Server instance as the distributor. + .DESCRIPTION + This example shows how to configure a SQL Server instance as the distributor. #> Configuration Example { @@ -11,11 +11,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerReplication distributor + SqlServerReplication 'distributor' { Ensure = 'Present' InstanceName = 'MSSQLSERVER' diff --git a/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 b/source/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 similarity index 75% rename from Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 rename to source/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 index f4c3c6378..780513992 100644 --- a/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 +++ b/source/Examples/Resources/SqlServerReplication/2-ConfigureInstanceAsPublisher.ps1 @@ -1,6 +1,6 @@ <# -.EXAMPLE - This example shows how to configure a SQL Server instance as the publisher. + .DESCRIPTION + This example shows how to configure a SQL Server instance as the publisher. #> Configuration Example { @@ -11,11 +11,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlServerReplication publisher + SqlServerReplication 'publisher' { Ensure = 'Present' InstanceName = 'PUBLISHER' diff --git a/Examples/Resources/SqlServerRole/1-AddServerRole.ps1 b/source/Examples/Resources/SqlServerRole/1-AddServerRole.ps1 similarity index 65% rename from Examples/Resources/SqlServerRole/1-AddServerRole.ps1 rename to source/Examples/Resources/SqlServerRole/1-AddServerRole.ps1 index 7344612d8..05d1266ed 100644 --- a/Examples/Resources/SqlServerRole/1-AddServerRole.ps1 +++ b/source/Examples/Resources/SqlServerRole/1-AddServerRole.ps1 @@ -1,36 +1,40 @@ <# -.EXAMPLE - This example shows how to ensure that both the server role named - MyServerRole1 and MyServerRole2 is present on instance - 'sqltest.company.local\DSC'. + .DESCRIPTION + This example shows how to ensure that both the server role named + MyServerRole1 and MyServerRole2 is present on instance + 'sqltest.company.local\DSC'. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerRole Add_ServerRole_MyServerRole1 + node localhost + { + SqlServerRole 'Add_ServerRole_MyServerRole1' { Ensure = 'Present' ServerRoleName = 'MyServerRole1' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } - SqlServerRole Add_ServerRole_MyServerRole2 + SqlServerRole 'Add_ServerRole_MyServerRole2' { Ensure = 'Present' ServerRoleName = 'MyServerRole2' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 b/source/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 similarity index 60% rename from Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 rename to source/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 index 889787633..714952ebb 100644 --- a/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 +++ b/source/Examples/Resources/SqlServerRole/2-RemoveServerRole.ps1 @@ -1,26 +1,29 @@ <# -.EXAMPLE - This example shows how to ensure that the server role named - serverRoleToDelete is not present on instance sqltest.company.local\DSC. + .DESCRIPTION + This example shows how to ensure that the server role named + serverRoleToDelete is not present on instance sqltest.company.local\DSC. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerRole Remove_ServerRole + node localhost + { + SqlServerRole 'Remove_ServerRole' { Ensure = 'Absent' ServerRoleName = 'serverRoleToDelete' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 b/source/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 similarity index 57% rename from Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 rename to source/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 index f9724238a..6943e3414 100644 --- a/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 +++ b/source/Examples/Resources/SqlServerRole/3-AddMembersToServerRole.ps1 @@ -1,28 +1,31 @@ <# -.EXAMPLE - This example shows how to ensure that the server role named - AdminSqlforBI is present on instance sqltest.company.local\DSC and only logins - CONTOSO\SQLAdmin and CONTOSO\SQLAdminBI are members of this role. + .DESCRIPTION + This example shows how to ensure that the server role named + AdminSqlforBI is present on instance sqltest.company.local\DSC and only logins + CONTOSO\SQLAdmin and CONTOSO\SQLAdminBI are members of this role. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerRole Add_ServerRole_AdminSqlforBI + node localhost + { + SqlServerRole 'Add_ServerRole_AdminSqlforBI' { Ensure = 'Present' ServerRoleName = 'AdminSqlforBI' Members = 'CONTOSO\SQLAdmin', 'CONTOSO\SQLAdminBI' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 b/source/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 similarity index 57% rename from Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 rename to source/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 index 68340166c..efca66dcc 100644 --- a/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 +++ b/source/Examples/Resources/SqlServerRole/4-MembersToIncludeInServerRole.ps1 @@ -1,28 +1,31 @@ <# -.EXAMPLE - This example shows how to ensure that the server role named - AdminSqlforBI is present on instance sqltest.company.local\DSC and logins - CONTOSO\John and CONTOSO\Kelly are added as members of this role. + .DESCRIPTION + This example shows how to ensure that the server role named + AdminSqlforBI is present on instance sqltest.company.local\DSC and logins + CONTOSO\John and CONTOSO\Kelly are added as members of this role. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerRole Add_ServerRole_AdminSqlforBI + node localhost + { + SqlServerRole 'Add_ServerRole_AdminSqlforBI' { Ensure = 'Present' ServerRoleName = 'AdminSqlforBI' MembersToInclude = 'CONTOSO\John', 'CONTOSO\Kelly' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 b/source/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 similarity index 57% rename from Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 rename to source/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 index de1a45517..7e1746ff8 100644 --- a/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 +++ b/source/Examples/Resources/SqlServerRole/5-MembersToExcludeInServerRole.ps1 @@ -1,28 +1,31 @@ <# -.EXAMPLE - This example shows how to ensure that the server role named - AdminSqlforBI is present on instance sqltest.company.local\DSC and logins - CONTOSO\Mark and CONTOSO\Lucy are not members of this role. + .DESCRIPTION + This example shows how to ensure that the server role named + AdminSqlforBI is present on instance sqltest.company.local\DSC and logins + CONTOSO\Mark and CONTOSO\Lucy are not members of this role. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerRole Drop_ServerRole_AdminSqlforBI + node localhost + { + SqlServerRole 'Drop_ServerRole_AdminSqlforBI' { Ensure = 'Present' ServerRoleName = 'AdminSqlforBI' MembersToExclude = 'CONTOSO\Mark', 'CONTOSO\Lucy' ServerName = 'sqltest.company.local' InstanceName = 'DSC' + PsDscRunAsCredential = $SqlAdministratorCredential } } diff --git a/Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1 b/source/Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1 similarity index 53% rename from Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1 rename to source/Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1 index f4c9048ca..e52b49a88 100644 --- a/Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1 +++ b/source/Examples/Resources/SqlServerSecureConnection/1-ForceSecureConnection.ps1 @@ -1,13 +1,14 @@ <# -.EXAMPLE - This example performs a standard Sql encryption setup. Forcing all connections to be encrypted. + .DESCRIPTION + This example performs a standard Sql encryption setup. Forcing all connections to be encrypted. #> Configuration Example { - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerSecureConnection ForceSecureConnection + node localhost + { + SqlServerSecureConnection 'ForceSecureConnection' { InstanceName = 'MSSQLSERVER' Thumbprint = 'fb0b82c94b80da26cf0b86f10ec0c50ae7864a2c' diff --git a/Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1 b/source/Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1 similarity index 52% rename from Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1 rename to source/Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1 index 7d8382f97..0dfb88b9e 100644 --- a/Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1 +++ b/source/Examples/Resources/SqlServerSecureConnection/2-SecureConnectionNotForced.ps1 @@ -1,13 +1,14 @@ <# -.EXAMPLE - This example performs a standard Sql encryption setup. All connections are not forced to be encrypted. + .DESCRIPTION + This example performs a standard Sql encryption setup. All connections are not forced to be encrypted. #> Configuration Example { - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - node localhost { - SqlServerSecureConnection SecureConnectionNotForced + node localhost + { + SqlServerSecureConnection 'SecureConnectionNotForced' { InstanceName = 'MSSQLSERVER' Thumbprint = 'fb0b82c94b80da26cf0b86f10ec0c50ae7864a2c' diff --git a/source/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 b/source/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 new file mode 100644 index 000000000..414197311 --- /dev/null +++ b/source/Examples/Resources/SqlServerSecureConnection/3-SecureConnectionAbsent.ps1 @@ -0,0 +1,19 @@ +<# + .DESCRIPTION + This example performs a standard Sql encryption setup. Forcing all connections to be encrypted. +#> +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlServerSecureConnection 'SecureConnectionAbsent' + { + InstanceName = 'MSSQLSERVER' + Thumbprint = '' + Ensure = 'Absent' + ServiceAccount = 'SqlSvc' + } + } +} diff --git a/source/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 b/source/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 new file mode 100644 index 000000000..bd1b650ea --- /dev/null +++ b/source/Examples/Resources/SqlServerSecureConnection/4-SecureConnectionUsingSYSTEMAccount.ps1 @@ -0,0 +1,22 @@ +<# + .DESCRIPTION + This example performs a standard Sql encryption setup using the "SYSTEM" account. + Note that the "LocalSystem" account should not be used because it returns a connection error, + even though it inherits the "SYSTEM" account's privileges. +#> +Configuration Example +{ + Import-DscResource -ModuleName 'SqlServerDsc' + + node localhost + { + SqlServerSecureConnection 'SecureConnectionUsingSYSTEMAccount' + { + InstanceName = 'MSSQLSERVER' + Thumbprint = 'fb0b82c94b80da26cf0b86f10ec0c50ae7864a2c' + ForceEncryption = $false + Ensure = 'Present' + ServiceAccount = 'SYSTEM' + } + } +} diff --git a/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 b/source/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 similarity index 59% rename from Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 rename to source/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 index f5eff93db..13b705791 100644 --- a/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 +++ b/source/Examples/Resources/SqlServiceAccount/1-ConfigureServiceAccount-UserAccount.ps1 @@ -1,21 +1,23 @@ <# -.EXAMPLE - This example shows how to ensure the SQL Server service - on TestServer is running under a user account. + .DESCRIPTION + This example shows how to ensure the SQL Server service + on TestServer is running under a user account. #> Configuration Example { - param( + param + ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $ServiceAccountCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' - Node localhost { - SqlServiceAccount SetServiceAccount_User + Node localhost + { + SqlServiceAccount 'SetServiceAccount_User' { ServerName = 'TestServer' InstanceName = 'MSSQLSERVER' diff --git a/source/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 b/source/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 new file mode 100644 index 000000000..deb98c7cf --- /dev/null +++ b/source/Examples/Resources/SqlServiceAccount/2-ConfigureServiceAccount-VirtualAccount.ps1 @@ -0,0 +1,33 @@ +<# + .DESCRIPTION + This example shows how to ensure the SQL Server service + on TestServer\DSC is running under a virtual account. + Force will cause this account to be set every time the + configuration is evaluated. Specifying RestartService will + cause the service to be restarted. +#> + +Configuration Example +{ + param + ( + [Parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $ServiceAccountCredential + ) + + Import-DscResource -ModuleName 'SqlServerDsc' + + Node localhost + { + SqlServiceAccount 'SetServiceAccount_User' + { + ServerName = 'TestServer' + InstanceName = 'DSC' + ServiceType = 'DatabaseEngine' + ServiceAccount = $ServiceAccountCredential + RestartService = $true + Force = $true + } + } +} diff --git a/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 b/source/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 similarity index 94% rename from Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 rename to source/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 index ce4b8c5a3..4f5706a3e 100644 --- a/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 +++ b/source/Examples/Resources/SqlSetup/1-InstallDefaultInstanceSingleServer.ps1 @@ -1,7 +1,8 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install a default instance of SQL Server, and Analysis Services in Tabular mode, on a single server. + .NOTES SQL Server setup is run using the SYSTEM account. Even if SetupCredential is provided it is not used to install SQL Server at this time (see issue #139). @@ -12,27 +13,27 @@ Configuration Example param ( [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 b/source/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 similarity index 94% rename from Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 rename to source/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 index 56fcfbb65..a78c8be19 100644 --- a/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 +++ b/source/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1 @@ -1,6 +1,7 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install a named instance of SQL Server on a single server. + .NOTES SQL Server setup is run using the SYSTEM account. Even if SetupCredential is provided it is not used to install SQL Server at this time (see issue #139). @@ -11,27 +12,27 @@ Configuration Example param ( [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDSC + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 b/source/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 similarity index 95% rename from Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 rename to source/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 index cfb991b60..5df4c0585 100644 --- a/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 +++ b/source/Examples/Resources/SqlSetup/3-InstallNamedInstanceSingleServerFromUncPathUsingSourceCredential.ps1 @@ -1,6 +1,7 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install a named instance of SQL Server on a single server, from an UNC path. + .NOTES Assumes the credentials assigned to SourceCredential have read permission on the share and on the UNC path. The media will be copied locally, using impersonation with the credentials provided in SourceCredential, so @@ -15,27 +16,27 @@ Configuration Example param ( [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 b/source/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 similarity index 92% rename from Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 rename to source/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 index 089acb95b..3d00b0a58 100644 --- a/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 +++ b/source/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1 @@ -1,12 +1,13 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install the first node in a SQL Server failover cluster. + .NOTES This example assumes that a Failover Cluster is already present with a Cluster Name Object (CNO), IP-address. This example also assumes that that all necessary shared disks is present, and formatted with the correct - drive letter, to accomdate the paths used during SQL Server setup. Minimum is one shared disk. + drive letter, to accommodate the paths used during SQL Server setup. Minimum is one shared disk. This example also assumes that the Cluster Name Object (CNO) has the permission to manage Computer Objects in - the Organizational Unit (OU) where the CNO Computer Object resides in Active Directory. This is neccessary + the Organizational Unit (OU) where the CNO Computer Object resides in Active Directory. This is necessary so that SQL Server setup can create a Virtual Computer Object (VCO) for the cluster group (Windows Server 2012 R2 and earlier) or cluster role (Windows Server 2016 and later). Also so that the Virtual Computer Object (VCO) can be removed when the Failover CLuster instance is uninstalled. @@ -25,7 +26,7 @@ also means that at this time PsDscRunAsCredential can not be used to access media on the UNC share. There is currently a bug that prevents the resource to logon to the instance if the current node is not the - active node. This is beacuse the resource tries to logon using the SYSTEM account instead of the credentials + active node. This is because the resource tries to logon using the SYSTEM account instead of the credentials in SetupCredential, and the resource does not currently support the built-in PsDscRunAsCredential either (see issue #444). #> @@ -35,27 +36,27 @@ Configuration Example param ( [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 b/source/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 similarity index 93% rename from Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 rename to source/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 index e114b7bd4..d88e92ceb 100644 --- a/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 +++ b/source/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1 @@ -1,6 +1,7 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to add a node to an existing SQL Server failover cluster. + .NOTES This example assumes that a Failover Cluster is already present with the first SQL Server Failover Cluster node already installed. @@ -21,7 +22,7 @@ also means that at this time PsDscRunAsCredential can not be used to access media on the UNC share. There is currently a bug that prevents the resource to logon to the instance if the current node is not the - active node. This is beacuse the resource tries to logon using the SYSTEM account instead of the credentials + active node. This is because the resource tries to logon using the SYSTEM account instead of the credentials in SetupCredential, and the resource does not currently support the built-in PsDscRunAsCredential either (see issue #444). #> @@ -31,27 +32,27 @@ Configuration Example param ( [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1 b/source/Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1 similarity index 94% rename from Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1 rename to source/Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1 index b412aa9e9..25ed0425b 100644 --- a/Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1 +++ b/source/Examples/Resources/SqlSetup/6-InstallNamedInstanceSingleServerWithAgtSvcStartupTypeDisabled.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install a named instance of SQL Server on a single server. .NOTES @@ -12,27 +12,27 @@ Configuration Example param ( [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDSC + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { @@ -79,7 +79,7 @@ Configuration Example SourcePath = 'C:\InstallMedia\SQL2016RTM' UpdateEnabled = 'False' ForceReboot = $false - + SqlSvcStartupType = 'Automatic' AgtSvcStartupType = 'Disabled' AsSvcStartupType = 'Automatic' diff --git a/Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1 b/source/Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1 similarity index 95% rename from Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1 rename to source/Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1 index 2a3801333..27a709aac 100644 --- a/Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1 +++ b/source/Examples/Resources/SqlSetup/7-InstallDefaultInstanceSingleServer2016OrLater.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example shows how to install a default instance of SQL Server, and Analysis Services in Tabular mode, on a single server. It contains configurations that apply to Sql Server 2016 or later only. @@ -15,27 +15,27 @@ Configuration Example param ( [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] - [ValidateNotNullorEmpty()] + [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { diff --git a/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 b/source/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 similarity index 80% rename from Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 rename to source/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 index b45834f80..479bfeaf3 100644 --- a/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 +++ b/source/Examples/Resources/SqlWaitForAG/1-WaitForASingleClusterGroup.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example will wait for the cluster role/group 'AGTest1'. #> Configuration Example @@ -11,11 +11,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlWaitForAG SQLConfigureAG-WaitAGTest1 + SqlWaitForAG 'SQLConfigureAG-WaitAGTest1' { Name = 'AGTest1' RetryIntervalSec = 20 diff --git a/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 b/source/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 similarity index 81% rename from Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 rename to source/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 index 2f264dbbb..727709dc2 100644 --- a/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 +++ b/source/Examples/Resources/SqlWaitForAG/2-WaitForMultipleClusterGroups.ps1 @@ -1,5 +1,5 @@ <# - .EXAMPLE + .DESCRIPTION This example will wait for both the cluster roles/groups 'AGTest1' and 'AGTest2'. #> Configuration Example @@ -11,11 +11,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlWaitForAG SQLConfigureAG-WaitAGTest1 + SqlWaitForAG 'SQLConfigureAG-WaitAGTest1' { Name = 'AGTest1' RetryIntervalSec = 20 @@ -24,7 +24,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlWaitForAG SQLConfigureAG-WaitAGTest2 + SqlWaitForAG 'SQLConfigureAG-WaitAGTest2' { Name = 'AGTest2' RetryIntervalSec = 20 diff --git a/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 b/source/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 similarity index 74% rename from Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 rename to source/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 index 1fad36414..d546b32d8 100644 --- a/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 +++ b/source/Examples/Resources/SqlWindowsFirewall/1-CreateInboundFirewallRules.ps1 @@ -1,6 +1,6 @@ <# -.EXAMPLE - This example shows how to create the default rules for the supported features. + .DESCRIPTION + This example shows how to create the default rules for the supported features. #> Configuration Example { @@ -11,11 +11,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlWindowsFirewall Create_FirewallRules_For_SQL2012 + SqlWindowsFirewall 'Create_FirewallRules_For_SQL2012' { Ensure = 'Present' Features = 'SQLENGINE,AS,RS,IS' @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlWindowsFirewall Create_FirewallRules_For_SQL2016 + SqlWindowsFirewall 'Create_FirewallRules_For_SQL2016' { Ensure = 'Present' Features = 'SQLENGINE' diff --git a/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 b/source/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 similarity index 74% rename from Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 rename to source/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 index 5d5d40d3b..e9c3f4f82 100644 --- a/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 +++ b/source/Examples/Resources/SqlWindowsFirewall/2-RemoveInboundFirewallRules.ps1 @@ -1,6 +1,6 @@ <# -.EXAMPLE - This example shows how to remove the default rules for the supported features. + .DESCRIPTION + This example shows how to remove the default rules for the supported features. #> Configuration Example { @@ -11,11 +11,11 @@ Configuration Example $SqlAdministratorCredential ) - Import-DscResource -ModuleName SqlServerDsc + Import-DscResource -ModuleName 'SqlServerDsc' node localhost { - SqlWindowsFirewall Remove_FirewallRules_For_SQL2012 + SqlWindowsFirewall 'Remove_FirewallRules_For_SQL2012' { Ensure = 'Absent' Features = 'SQLENGINE,AS,RS,IS' @@ -25,7 +25,7 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlWindowsFirewall Remove_FirewallRules_For_SQL2016 + SqlWindowsFirewall 'Remove_FirewallRules_For_SQL2016' { Ensure = 'Absent' Features = 'SQLENGINE' diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 new file mode 100644 index 000000000..0f759bc0c --- /dev/null +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psd1 @@ -0,0 +1,78 @@ +@{ + RootModule = 'SqlServerDsc.Common.psm1' + + # Version number of this module. + ModuleVersion = '1.0.0' + + # ID used to uniquely identify this module + GUID = 'b8e5084a-07a8-4135-8a26-00614e56ba71' + + # Author of this module + Author = 'DSC Community' + + # Company or vendor of this module + CompanyName = 'DSC Community' + + # Copyright statement for this module + Copyright = 'Copyright the DSC Community contributors. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'Functions used by the DSC resources in SqlServerDsc.' + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + 'New-InvalidArgumentException' + 'New-InvalidOperationException' + 'New-ObjectNotFoundException' + 'New-InvalidResultException' + 'New-NotImplementedException' + 'Get-LocalizedData' + 'Test-DscParameterState' + 'Get-RegistryPropertyValue' + 'Format-Path' + 'Copy-ItemWithRobocopy' + 'Get-TemporaryFolder' + 'Invoke-InstallationMediaCopy' + 'Connect-UncPath' + 'Disconnect-UncPath' + 'Test-PendingRestart' + 'Start-SqlSetupProcess' + 'Connect-SQL' + 'Connect-SQLAnalysis' + 'Get-SqlInstanceMajorVersion' + 'Import-SQLPSModule' + 'Restart-SqlService' + 'Restart-ReportingServicesService' + 'Invoke-Query' + 'Update-AvailabilityGroupReplica' + 'Test-LoginEffectivePermissions' + 'Test-AvailabilityReplicaSeedingModeAutomatic' + 'Get-PrimaryReplicaServerObject' + 'Test-ImpersonatePermissions' + 'Split-FullSqlInstanceName' + 'Test-ClusterPermissions' + 'Test-ActiveNode' + 'Invoke-SqlScript' + 'Get-ServiceAccount' + 'Find-ExceptionByNumber' + + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = @() + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @() + + # 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 = @{ + } # End of PSData hashtable + + } # End of PrivateData hashtable +} + diff --git a/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 similarity index 98% rename from Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 rename to source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 0a386b6d1..73fbf52de 100644 --- a/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -698,7 +698,7 @@ function Get-TemporaryFolder { [CmdletBinding()] [OutputType([System.String])] - param() + param () return [IO.Path]::GetTempPath() } @@ -2497,40 +2497,3 @@ function Find-ExceptionByNumber } $script:localizedData = Get-LocalizedData -ResourceName 'SqlServerDsc.Common' -ScriptRoot $PSScriptRoot - -Export-ModuleMember -Function @( - 'Test-DscParameterState' - 'Get-RegistryPropertyValue' - 'Format-Path' - 'Copy-ItemWithRobocopy' - 'Get-TemporaryFolder' - 'Invoke-InstallationMediaCopy' - 'Connect-UncPath' - 'Disconnect-UncPath' - 'Test-PendingRestart' - 'Start-SqlSetupProcess' - 'Connect-SQL' - 'Connect-SQLAnalysis' - 'Get-SqlInstanceMajorVersion' - 'Import-SQLPSModule' - 'Restart-SqlService' - 'Restart-ReportingServicesService' - 'Invoke-Query' - 'Update-AvailabilityGroupReplica' - 'Test-LoginEffectivePermissions' - 'Test-AvailabilityReplicaSeedingModeAutomatic' - 'Get-PrimaryReplicaServerObject' - 'Test-ImpersonatePermissions' - 'Split-FullSqlInstanceName' - 'Test-ClusterPermissions' - 'Test-ActiveNode' - 'Invoke-SqlScript' - 'Get-ServiceAccount' - 'Find-ExceptionByNumber' - 'New-InvalidArgumentException' - 'New-InvalidOperationException' - 'New-ObjectNotFoundException' - 'New-InvalidResultException' - 'New-NotImplementedException' - 'Get-LocalizedData' -) diff --git a/Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 b/source/Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 similarity index 100% rename from Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 rename to source/Modules/SqlServerDsc.Common/en-US/SqlServerDsc.Common.strings.psd1 diff --git a/Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 b/source/Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 similarity index 100% rename from Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 rename to source/Modules/SqlServerDsc.Common/sv-SE/SqlServerDsc.Common.strings.psd1 diff --git a/source/SqlServerDsc.psd1 b/source/SqlServerDsc.psd1 new file mode 100644 index 000000000..8a815198c --- /dev/null +++ b/source/SqlServerDsc.psd1 @@ -0,0 +1,105 @@ +@{ + # Version number of this module. + moduleVersion = '0.0.1' + + # ID used to uniquely identify this module + GUID = '693ee082-ed36-45a7-b490-88b07c86b42f' + + # Author of this module + Author = 'DSC Community' + + # Company or vendor of this module + CompanyName = 'DSC Community' + + # Copyright statement for this module + Copyright = 'Copyright the DSC Community contributors. 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 = @() + + # Variables to export from this module + VariablesToExport = @() + + # Aliases to export from this module + AliasesToExport = @() + + DscResourcesToExport = @( + 'SqlAG' + 'SqlAGDatabase' + 'SqlAgentAlert' + 'SqlAgentFailsafe' + 'SqlAgentOperator' + 'SqlAGListener' + 'SqlAGReplica' + 'SqlAlias' + 'SqlAlwaysOnService' + 'SqlDatabase' + 'SqlDatabaseDefaultLocation' + 'SqlDatabaseOwner' + 'SqlDatabasePermission' + 'SqlDatabaseRecoveryModel' + 'SqlDatabaseRole' + 'SqlDatabaseUser' + 'SqlRS' + 'SqlRSSetup' + 'SqlScript' + 'SqlScriptQuery' + 'SqlServerConfiguration' + 'SqlServerDatabaseMail' + 'SqlServerEndpoint' + 'SqlServerEndpointPermission' + 'SqlServerEndpointState' + 'SqlServerLogin' + 'SqlServerMaxDop' + 'SqlServerMemory' + 'SqlServerNetwork' + 'SqlServerPermission' + 'MSFT_SqlServerReplication' + 'SqlServerRole' + 'SqlServerSecureConnection' + 'SqlServiceAccount' + 'SqlSetup' + 'SqlWaitForAG' + 'SqlWindowsFirewall' + ) + + 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 = @{ + # Set to a prerelease string value if the release should be a prerelease. + Prerelease = '' + + # 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/dsccommunity/SqlServerDsc/blob/master/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/dsccommunity/SqlServerDsc' + + # A URL to an icon representing this module. + IconUri = 'https://dsccommunity.org/images/DSC_Logo_300p.png' + + # ReleaseNotes of this module + ReleaseNotes = '' + + } # End of PSData hashtable + + } # End of PrivateData hashtable +} diff --git a/source/en-US/about_SqlServerDsc.help.txt b/source/en-US/about_SqlServerDsc.help.txt new file mode 100644 index 000000000..6fad87eac --- /dev/null +++ b/source/en-US/about_SqlServerDsc.help.txt @@ -0,0 +1,25 @@ +TOPIC + about_SqlServerDsc + +SHORT DESCRIPTION + DSC resources for deployment and configuration of Microsoft SQL Server. + +LONG DESCRIPTION + This module contains DSC resources for deployment and configuration of Microsoft SQL Server. + +EXAMPLES + PS C:\> Get-DscResource -Module SqlServerDsc + +NOTE: + Thank you to the DSC Community contributors who contributed to this module by + writing code, sharing opinions, and provided feedback. + +TROUBLESHOOTING NOTE: + Go to the Github repository for read about issues, submit a new issue, and read + about new releases. https://github.com/dsccommunity/SqlServerDsc + +SEE ALSO + - https://github.com/dsccommunity/SqlServerDsc + +KEYWORDS + DSC, DscResource, SqlServer diff --git a/Tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1 similarity index 80% rename from Tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1 index d56375baf..7706f3787 100644 --- a/Tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlAgentAlert' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -##region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -139,9 +133,5 @@ try } finally { - #region FOOTER - - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlAgentAlert.config.ps1 b/tests/Integration/MSFT_SqlAgentAlert.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlAgentAlert.config.ps1 rename to tests/Integration/MSFT_SqlAgentAlert.config.ps1 diff --git a/Tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1 similarity index 80% rename from Tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1 index 0c9f2d79a..52264f468 100644 --- a/Tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlAgentFailsafe' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -##region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -139,9 +133,5 @@ try } finally { - #region FOOTER - - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlAgentFailsafe.config.ps1 b/tests/Integration/MSFT_SqlAgentFailsafe.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlAgentFailsafe.config.ps1 rename to tests/Integration/MSFT_SqlAgentFailsafe.config.ps1 diff --git a/Tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1 similarity index 80% rename from Tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1 index d417f72d5..cc343f498 100644 --- a/Tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlAgentOperator' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -##region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -139,9 +133,5 @@ try } finally { - #region FOOTER - - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlAgentOperator.config.ps1 b/tests/Integration/MSFT_SqlAgentOperator.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlAgentOperator.config.ps1 rename to tests/Integration/MSFT_SqlAgentOperator.config.ps1 diff --git a/Tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 similarity index 86% rename from Tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 index 53a727398..1d8b95049 100644 --- a/Tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Skipped'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlAlwaysOnService' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -201,7 +195,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 b/tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 similarity index 97% rename from Tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 rename to tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 index 1690ee7aa..5dee681cb 100644 --- a/Tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 +++ b/tests/Integration/MSFT_SqlAlwaysOnService.config.ps1 @@ -70,8 +70,8 @@ else #> Configuration MSFT_SqlAlwaysOnService_CreateDependencies_Config { - Import-DscResource -ModuleName 'PSDscResources' - Import-DscResource -ModuleName 'NetworkingDsc' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' + Import-DscResource -ModuleName 'NetworkingDsc' -ModuleVersion '7.4.0.0' node $AllNodes.NodeName { @@ -198,7 +198,7 @@ Configuration MSFT_SqlAlwaysOnService_CreateDependencies_Config #> Configuration MSFT_SqlAlwaysOnService_CleanupDependencies_Config { - Import-DscResource -ModuleName 'NetworkingDsc' + Import-DscResource -ModuleName 'NetworkingDsc' -ModuleVersion '7.4.0.0' node $AllNodes.NodeName { diff --git a/Tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1 similarity index 86% rename from Tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1 index 239a6a185..9678ee057 100644 --- a/Tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlDatabase' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -193,7 +187,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlDatabase.config.ps1 b/tests/Integration/MSFT_SqlDatabase.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlDatabase.config.ps1 rename to tests/Integration/MSFT_SqlDatabase.config.ps1 diff --git a/Tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 similarity index 85% rename from Tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 index 26a8d617f..1eaf39ab5 100644 --- a/Tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlDatabaseDefaultLocation' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -185,7 +179,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 b/tests/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 rename to tests/Integration/MSFT_SqlDatabaseDefaultLocation.config.ps1 diff --git a/Tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1 similarity index 95% rename from Tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1 index fdec2f20b..5ce793c91 100644 --- a/Tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 3)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlDatabaseUser' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -491,7 +485,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlDatabaseUser.config.ps1 b/tests/Integration/MSFT_SqlDatabaseUser.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlDatabaseUser.config.ps1 rename to tests/Integration/MSFT_SqlDatabaseUser.config.ps1 diff --git a/Tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 similarity index 92% rename from Tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 index fa94d1ef8..fbb6d183d 100644 --- a/Tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlRS.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 3)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,21 +9,20 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlRS' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' <# This is used in both the configuration file and in this script file @@ -45,7 +40,6 @@ else Write-Verbose -Message ('Running integration tests for SSRS version {0}' -f $script:sqlVersion) -Verbose -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -365,7 +359,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlRS.config.ps1 b/tests/Integration/MSFT_SqlRS.config.ps1 similarity index 97% rename from Tests/Integration/MSFT_SqlRS.config.ps1 rename to tests/Integration/MSFT_SqlRS.config.ps1 index 0c2b1f45e..09592b425 100644 --- a/Tests/Integration/MSFT_SqlRS.config.ps1 +++ b/tests/Integration/MSFT_SqlRS.config.ps1 @@ -68,8 +68,8 @@ else #> Configuration MSFT_SqlRS_CreateDependencies_Config { - Import-DscResource -ModuleName 'PSDscResources' - Import-DscResource -ModuleName 'StorageDsc' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' + Import-DscResource -ModuleName 'StorageDsc' -ModuleVersion '4.9.0.0' Import-DscResource -ModuleName 'SqlServerDsc' node $AllNodes.NodeName @@ -245,7 +245,7 @@ Configuration MSFT_SqlRS_InstallReportingServices_RestoreToNoSsl_Config #> Configuration MSFT_SqlRS_StopReportingServicesInstance_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { diff --git a/Tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1 similarity index 75% rename from Tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1 index 9e02134a0..ffde46a1d 100644 --- a/Tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1 @@ -1,11 +1,7 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') # Run only for SQL 2017 integration testing. -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2017'))) { return } @@ -14,23 +10,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlRSSetup' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -46,11 +40,11 @@ try $script:mockSourceMediaDisplayName = 'Microsoft SQL Server Reporting Services (October 2017)' $script:mockSourceMediaUrl = 'https://download.microsoft.com/download/E/6/4/E6477A2A-9B58-40F7-8AD6-62BB8491EA78/SQLServerReportingServices.exe' - Write-Info -Message ('Start downloading the {1} executable at {0}.' -f (Get-Date -Format 'yyyy-MM-dd hh:mm:ss'), $script:mockSourceMediaDisplayName) -Verbose + Write-Verbose -Message ('Start downloading the {1} executable at {0}.' -f (Get-Date -Format 'yyyy-MM-dd hh:mm:ss'), $script:mockSourceMediaDisplayName) -Verbose Invoke-WebRequest -Uri $script:mockSourceMediaUrl -OutFile $ConfigurationData.AllNodes.SourcePath - Write-Info -Message ('{1} executable file has SHA1 hash ''{0}''.' -f (Get-FileHash -Path $ConfigurationData.AllNodes.SourcePath -Algorithm 'SHA1').Hash, $script:mockSourceMediaDisplayName) -Verbose + Write-Verbose -Message ('{1} executable file has SHA1 hash ''{0}''.' -f (Get-FileHash -Path $ConfigurationData.AllNodes.SourcePath -Algorithm 'SHA1').Hash, $script:mockSourceMediaDisplayName) -Verbose $ProgressPreference = $previousProgressPreference @@ -62,12 +56,12 @@ try } else { - Write-Info -Message ('Finished downloading the {1} executable at {0}.' -f (Get-Date -Format 'yyyy-MM-dd hh:mm:ss'), $script:mockSourceMediaDisplayName) -Verbose + Write-Verbose -Message ('Finished downloading the {1} executable at {0}.' -f (Get-Date -Format 'yyyy-MM-dd hh:mm:ss'), $script:mockSourceMediaDisplayName) -Verbose } } else { - Write-Info -Message ('{0} executable is already downloaded' -f $script:mockSourceMediaDisplayName) -Verbose + Write-Verbose -Message ('{0} executable is already downloaded' -f $script:mockSourceMediaDisplayName) -Verbose } Describe "$($script:dscResourceName)_Integration" { @@ -155,7 +149,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlRSSetup.config.ps1 b/tests/Integration/MSFT_SqlRSSetup.config.ps1 similarity index 97% rename from Tests/Integration/MSFT_SqlRSSetup.config.ps1 rename to tests/Integration/MSFT_SqlRSSetup.config.ps1 index c9db6c923..ffc487dad 100644 --- a/Tests/Integration/MSFT_SqlRSSetup.config.ps1 +++ b/tests/Integration/MSFT_SqlRSSetup.config.ps1 @@ -77,7 +77,7 @@ Configuration MSFT_SqlRSSetup_InstallReportingServicesAsUser_Config #> Configuration MSFT_SqlRSSetup_StopReportingServicesInstance_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { diff --git a/Tests/Integration/MSFT_SqlScript.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlScript.Integration.Tests.ps1 similarity index 86% rename from Tests/Integration/MSFT_SqlScript.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlScript.Integration.Tests.ps1 index 253986735..93a2cd0b1 100644 --- a/Tests/Integration/MSFT_SqlScript.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlScript.Integration.Tests.ps1 @@ -1,15 +1,6 @@ -<# - This is used to make sure the integration test run in the correct order. - The integration test should run after the integration tests SqlServerLogin - and SqlServerRole, so any problems in those will be caught first, since - these integration tests are using those resources. -#> -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 4)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -18,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlScript' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -215,7 +204,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlScript.config.ps1 b/tests/Integration/MSFT_SqlScript.config.ps1 similarity index 99% rename from Tests/Integration/MSFT_SqlScript.config.ps1 rename to tests/Integration/MSFT_SqlScript.config.ps1 index 2f0bbb8de..9b21b7236 100644 --- a/Tests/Integration/MSFT_SqlScript.config.ps1 +++ b/tests/Integration/MSFT_SqlScript.config.ps1 @@ -66,7 +66,7 @@ CREATE DATABASE [$(DatabaseName)] #> Configuration MSFT_SqlScript_CreateDependencies_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -ModuleName 'SqlServerDsc' node $AllNodes.NodeName diff --git a/Tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1 similarity index 76% rename from Tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1 index 9e188b375..a3b20a549 100644 --- a/Tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1 @@ -1,15 +1,6 @@ -<# - This is used to make sure the integration test run in the correct order. - The integration test should run after the integration tests SqlServerLogin - and SqlServerRole, so any problems in those will be caught first, since - these integration tests are using those resources. -#> -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 5)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -18,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlScriptQuery' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -121,9 +110,9 @@ try } $resultObject.Name | Should -Be $ConfigurationData.AllNodes.Database1Name - $resourceCurrentState.GetQuery | Should -Be $ConfigurationData.AllNodes.GetQuery - $resourceCurrentState.TestQuery | Should -Be $ConfigurationData.AllNodes.TestQuery - $resourceCurrentState.SetQuery | Should -Be $ConfigurationData.AllNodes.SetQuery + $resourceCurrentState.GetQuery -replace '\r\n', "`n" | Should -Be ($ConfigurationData.AllNodes.GetQuery -replace '\r\n', "`n") + $resourceCurrentState.TestQuery -replace '\r\n', "`n" | Should -Be ($ConfigurationData.AllNodes.TestQuery -replace '\r\n', "`n") + $resourceCurrentState.SetQuery -replace '\r\n', "`n" | Should -Be ($ConfigurationData.AllNodes.SetQuery -replace '\r\n', "`n") } It 'Should return $true when Test-DscConfiguration is run' { @@ -170,9 +159,9 @@ try } $resourceCurrentState.GetResult | Should -Match $ConfigurationData.AllNodes.Database2Name - $resourceCurrentState.GetQuery | Should -Be $ConfigurationData.AllNodes.GetQuery - $resourceCurrentState.TestQuery | Should -Be $ConfigurationData.AllNodes.TestQuery - $resourceCurrentState.SetQuery | Should -Be $ConfigurationData.AllNodes.SetQuery + $resourceCurrentState.GetQuery -replace '\r\n', "`n" | Should -Be ($ConfigurationData.AllNodes.GetQuery -replace '\r\n', "`n") + $resourceCurrentState.TestQuery -replace '\r\n', "`n" | Should -Be ($ConfigurationData.AllNodes.TestQuery -replace '\r\n', "`n") + $resourceCurrentState.SetQuery -replace '\r\n', "`n" | Should -Be ($ConfigurationData.AllNodes.SetQuery -replace '\r\n', "`n") } It 'Should return $true when Test-DscConfiguration is run' { @@ -183,7 +172,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlScriptQuery.config.ps1 b/tests/Integration/MSFT_SqlScriptQuery.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlScriptQuery.config.ps1 rename to tests/Integration/MSFT_SqlScriptQuery.config.ps1 diff --git a/Tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1 similarity index 84% rename from Tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1 index 781aa30a5..8d4bf7b58 100644 --- a/Tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlServerDatabaseMail' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -153,7 +147,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlServerDatabaseMail.config.ps1 b/tests/Integration/MSFT_SqlServerDatabaseMail.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlServerDatabaseMail.config.ps1 rename to tests/Integration/MSFT_SqlServerDatabaseMail.config.ps1 diff --git a/Tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1 similarity index 81% rename from Tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1 index f6bfdc140..283020bc1 100644 --- a/Tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlServerEndpoint' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { #region Integration Tests @@ -140,7 +134,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlServerEndPoint.config.ps1 b/tests/Integration/MSFT_SqlServerEndPoint.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlServerEndPoint.config.ps1 rename to tests/Integration/MSFT_SqlServerEndPoint.config.ps1 diff --git a/Tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1 similarity index 92% rename from Tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1 index d77714b44..d6d156e16 100644 --- a/Tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlServerLogin' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -368,7 +362,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlServerLogin.config.ps1 b/tests/Integration/MSFT_SqlServerLogin.config.ps1 similarity index 99% rename from Tests/Integration/MSFT_SqlServerLogin.config.ps1 rename to tests/Integration/MSFT_SqlServerLogin.config.ps1 index 0c29798d5..a4d837b4d 100644 --- a/Tests/Integration/MSFT_SqlServerLogin.config.ps1 +++ b/tests/Integration/MSFT_SqlServerLogin.config.ps1 @@ -51,7 +51,7 @@ else #> Configuration MSFT_SqlServerLogin_CreateDependencies_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { diff --git a/Tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1 similarity index 82% rename from Tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1 index 5422de148..99f9b8d91 100644 --- a/Tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,27 +9,25 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlServerNetwork' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' $mockSqlInstallAccountPassword = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force $mockSqlInstallAccountUserName = "$env:COMPUTERNAME\SqlInstall" $mockSqlInstallCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $mockSqlInstallAccountUserName, $mockSqlInstallAccountPassword -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -145,7 +139,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlServerNetwork.config.ps1 b/tests/Integration/MSFT_SqlServerNetwork.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlServerNetwork.config.ps1 rename to tests/Integration/MSFT_SqlServerNetwork.config.ps1 diff --git a/Tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1 similarity index 93% rename from Tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1 index 724d3ae85..e667531da 100644 --- a/Tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 3)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlServerRole' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -417,7 +411,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlServerRole.config.ps1 b/tests/Integration/MSFT_SqlServerRole.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlServerRole.config.ps1 rename to tests/Integration/MSFT_SqlServerRole.config.ps1 diff --git a/Tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1 similarity index 79% rename from Tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1 index b2524c9be..61b48ac0d 100644 --- a/Tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1 @@ -1,15 +1,6 @@ -<# - This is used to make sure the integration test run in the correct order. - The integration test should run after the integration tests SqlServerLogin - and SqlServerRole, so any problems in those will be caught first, since - these integration tests are using those resources. -#> -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 5)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -18,21 +9,20 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlServerSecureConnection' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' $testRootFolderPath = Split-Path -Path $PSScriptRoot -Parent Import-Module -Name (Join-Path -Path $testRootFolderPath -ChildPath (Join-Path -Path 'TestHelpers' -ChildPath 'CommonTestHelper.psm1')) -Force @@ -42,12 +32,11 @@ Import-Module -Name (Join-Path -Path $testRootFolderPath -ChildPath (Join-Path - certificate in the environment variable 'SqlPrivateCertificatePath', and its thumbprint to the environment variable 'SqlCertificateThumbprint' #> -$null = New-SQLSelfSignedCertificate +$null = New-SQLSelfSignedCertificate -Verbose $mockSqlPrivateKeyPassword = ConvertTo-SecureString -String '1234' -AsPlainText -Force Import-PfxCertificate -FilePath $env:SqlPrivateCertificatePath -Password $mockSqlPrivateKeyPassword -Exportable -CertStoreLocation 'Cert:\LocalMachine\Root' Import-PfxCertificate -FilePath $env:SqlPrivateCertificatePath -Password $mockSqlPrivateKeyPassword -Exportable -CertStoreLocation 'Cert:\LocalMachine\My' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -154,7 +143,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlServerSecureConnection.config.ps1 b/tests/Integration/MSFT_SqlServerSecureConnection.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SqlServerSecureConnection.config.ps1 rename to tests/Integration/MSFT_SqlServerSecureConnection.config.ps1 diff --git a/Tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1 similarity index 94% rename from Tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1 index b04b5b952..265ebfe7a 100644 --- a/Tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 2)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,23 +9,21 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlServiceAccount' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -482,7 +476,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlServiceAccount.config.ps1 b/tests/Integration/MSFT_SqlServiceAccount.config.ps1 similarity index 98% rename from Tests/Integration/MSFT_SqlServiceAccount.config.ps1 rename to tests/Integration/MSFT_SqlServiceAccount.config.ps1 index e090f1dec..b55207fb9 100644 --- a/Tests/Integration/MSFT_SqlServiceAccount.config.ps1 +++ b/tests/Integration/MSFT_SqlServiceAccount.config.ps1 @@ -50,7 +50,7 @@ else #> Configuration MSFT_SqlServiceAccount_CreateDependencies_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { @@ -192,7 +192,7 @@ Configuration MSFT_SqlServiceAccount_SqlServerAgent_DefaultInstance_Restore_Conf #> Configuration MSFT_SqlServiceAccount_StopSqlServerDefaultInstance_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { diff --git a/Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 b/tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 similarity index 95% rename from Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 rename to tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 index 155fa718b..8686251fc 100644 --- a/Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 +++ b/tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 @@ -1,10 +1,6 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 1)] -param() - Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017')) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return } @@ -13,21 +9,20 @@ $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlSetup' $script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $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'))) ) +try { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' <# .SYNOPSIS @@ -64,7 +59,6 @@ function Show-SqlBootstrapLog Write-Verbose -Message $('-' * 80) -Verbose } - <# This is used in both the configuration file and in this script file to run the correct tests depending of what version of SQL Server is @@ -83,23 +77,6 @@ else Write-Verbose -Message ('Running integration tests for SQL Server version {0}' -f $script:sqlVersion) -Verbose -<# - Workaround for issue #774. In the appveyor.yml file the folder - C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules - was renamed to - C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules.old - here we rename back the folder to the correct name. Only the version need - for our tests are renamed. -#> -$sqlPsModulePath = 'C:\Program Files (x86)\Microsoft SQL Server\{0}\Tools\PowerShell\*.old' -f $script:sqlVersion -$sqlModulePath = Get-ChildItem -Path $sqlPsModulePath -$sqlModulePath | ForEach-Object -Process { - $newFolderName = (Split-Path -Path $_ -Leaf) -replace '\.old' - Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose - Rename-Item $_ -NewName $newFolderName -Force -} - -# Using try/finally to always cleanup. try { $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" @@ -617,7 +594,5 @@ try } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Integration/MSFT_SqlSetup.config.ps1 b/tests/Integration/MSFT_SqlSetup.config.ps1 similarity index 97% rename from Tests/Integration/MSFT_SqlSetup.config.ps1 rename to tests/Integration/MSFT_SqlSetup.config.ps1 index 061131bba..e98506c49 100644 --- a/Tests/Integration/MSFT_SqlSetup.config.ps1 +++ b/tests/Integration/MSFT_SqlSetup.config.ps1 @@ -160,8 +160,8 @@ $SqlAgentServiceSecondaryCredential = New-Object ` #> Configuration MSFT_SqlSetup_CreateDependencies_Config { - Import-DscResource -ModuleName 'PSDscResources' - Import-DscResource -ModuleName 'StorageDsc' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' + Import-DscResource -ModuleName 'StorageDsc' -ModuleVersion '4.9.0.0' node $AllNodes.NodeName { @@ -311,7 +311,7 @@ Configuration MSFT_SqlSetup_InstallDatabaseEngineNamedInstanceAsSystem_Config #> Configuration MSFT_SqlSetup_StopServicesInstance_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { @@ -383,7 +383,7 @@ Configuration MSFT_SqlSetup_InstallDatabaseEngineDefaultInstanceAsUser_Config #> Configuration MSFT_SqlSetup_StopSqlServerDefaultInstance_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { @@ -443,7 +443,7 @@ Configuration MSFT_SqlSetup_InstallTabularAnalysisServicesAsSystem_Config #> Configuration MSFT_SqlSetup_StopTabularAnalysisServices_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { @@ -465,7 +465,7 @@ Configuration MSFT_SqlSetup_StopTabularAnalysisServices_Config #> Configuration MSFT_SqlSetup_StartServicesInstance_Config { - Import-DscResource -ModuleName 'PSDscResources' + Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' node $AllNodes.NodeName { diff --git a/Tests/Integration/README.md b/tests/Integration/README.md similarity index 98% rename from Tests/Integration/README.md rename to tests/Integration/README.md index da139978d..d21cd5cbf 100644 --- a/Tests/Integration/README.md +++ b/tests/Integration/README.md @@ -109,6 +109,9 @@ User | Password | Description ## SqlAlwaysOnService +*This integration test has been temporarily disabled because when* +*the cluster feature is installed it requires a reboot.* + **Run order:** 2 **Depends on:** SqlSetup diff --git a/Tests/TestHelpers/CommonTestHelper.psm1 b/tests/TestHelpers/CommonTestHelper.psm1 similarity index 82% rename from Tests/TestHelpers/CommonTestHelper.psm1 rename to tests/TestHelpers/CommonTestHelper.psm1 index 41d532cf4..4272738aa 100644 --- a/Tests/TestHelpers/CommonTestHelper.psm1 +++ b/tests/TestHelpers/CommonTestHelper.psm1 @@ -61,7 +61,7 @@ function Import-SQLModuleStub # Build the path to the module stub $moduleStubPath = Join-Path -Path ( Join-Path -Path ( Join-Path -Path ( Split-Path -Path $PSScriptRoot -Parent ) -ChildPath Unit ) -ChildPath Stubs ) -ChildPath "$($stubModuleName).psm1" - Import-Module -Name $moduleStubPath -Force -Global + Import-Module -Name $moduleStubPath -Force -Global -WarningAction 'SilentlyContinue' } } @@ -83,21 +83,16 @@ function New-IntegrationLoopbackAdapter $AdapterName ) - # Ensure the loopback adapter module is downloaded - $LoopbackAdapterModuleName = 'LoopbackAdapter' - $LoopbackAdapterModulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\$LoopbackAdapterModuleName" - - # This is a helper function from DscResource.Tests\TestHelper.psm1. - Install-ModuleFromPowerShellGallery ` - -ModuleName $LoopbackAdapterModuleName ` - -DestinationPath $LoopbackAdapterModulePath + $loopbackAdapterModuleName = 'LoopbackAdapter' - $LoopbackAdapterModule = Join-Path ` - -Path $LoopbackAdapterModulePath ` - -ChildPath "$($LoopbackAdapterModuleName).psm1" + # Ensure the loopback adapter module is downloaded + if (-not (Get-Module -Name $loopbackAdapterModuleName -ListAvailable)) + { + throw ('Missing module ''{0}''' -f $loopbackAdapterModuleName) + } # Import the loopback adapter module - Import-Module -Name $LoopbackAdapterModule -Force + Import-Module -Name $loopbackAdapterModuleName -Force $loopbackAdapterParameters = @{ Name = $AdapterName @@ -244,6 +239,9 @@ function Get-NetIPAddressNetwork #> function New-SQLSelfSignedCertificate { + [CmdletBinding()] + param () + $sqlPublicCertificatePath = Join-Path -Path $env:temp -ChildPath 'SqlPublicKey.cer' $sqlPrivateCertificatePath = Join-Path -Path $env:temp -ChildPath 'SqlPrivateKey.cer' $sqlPrivateKeyPassword = ConvertTo-SecureString -String "1234" -Force -AsPlainText @@ -274,15 +272,21 @@ function New-SQLSelfSignedCertificate $certificate = New-SelfSignedCertificateEx @newSelfSignedCertificateExParameters - Write-Info -Message ('Created self-signed certificate ''{0}'' with thumbprint ''{1}''.' -f $certificate.Subject, $certificate.Thumbprint) + Write-Verbose -Message ('Created self-signed certificate ''{0}'' with thumbprint ''{1}''.' -f $certificate.Subject, $certificate.Thumbprint) # Update a machine and session environment variable with the path to the private certificate. - Set-EnvironmentVariable -Name 'SqlPrivateCertificatePath' -Value $sqlPrivateCertificatePath -Machine - Write-Info -Message ('Environment variable $env:SqlPrivateCertificatePath set to ''{0}''' -f $env:SqlPrivateCertificatePath) + [Environment]::SetEnvironmentVariable('SqlPrivateCertificatePath', $sqlPrivateCertificatePath, 'Machine') + Write-Verbose -Message ('Machine environment variable SqlPrivateCertificatePath set to ''{0}''' -f [System.Environment]::GetEnvironmentVariable('SqlPrivateCertificatePath','Machine')) + + $env:SqlPrivateCertificatePath = $sqlPrivateCertificatePath + Write-Verbose -Message ('Session environment variable $env:SqlPrivateCertificatePath set to ''{0}''' -f $env:SqlPrivateCertificatePath) # Update a machine and session environment variable with the thumbprint of the certificate. - Set-EnvironmentVariable -Name 'SqlCertificateThumbprint' -Value $certificate.Thumbprint -Machine - Write-Info -Message ('Environment variable $env:SqlCertificateThumbprint set to ''{0}''' -f $env:SqlCertificateThumbprint) + [Environment]::SetEnvironmentVariable('SqlCertificateThumbprint', $certificate.Thumbprint, 'Machine') + Write-Verbose -Message ('Machine environment variable $env:SqlCertificateThumbprint set to ''{0}''' -f [System.Environment]::GetEnvironmentVariable('SqlCertificateThumbprint','Machine')) + + $env:SqlCertificateThumbprint = $certificate.Thumbprint + Write-Verbose -Message ('Session environment variable $env:SqlCertificateThumbprint set to ''{0}''' -f $env:SqlCertificateThumbprint) return $certificate } @@ -305,7 +309,7 @@ function New-SQLSelfSignedCertificate $env:CONFIGURATION. If this are not set, the parameter Type is used as category. #> -function Test-SkipContinuousIntegrationTask +function Test-BuildCategory { [OutputType([System.Boolean])] [CmdletBinding()] @@ -332,18 +336,22 @@ function Test-SkipContinuousIntegrationTask $Category = @($Type) } - $result = $false + $result = $true - if ($Type -eq 'Integration' -and -not $env:APPVEYOR -eq $true) + if ($Type -eq 'Integration' -and -not $env:CI -eq $true) { - Write-Warning -Message ('{1} test for {0} will be skipped unless $env:APPVEYOR is set to $true' -f $Name, $Type) - $result = $true + Write-Warning -Message ('{1} test for {0} will be skipped unless $env:CI is set to $true' -f $Name, $Type) + $result = $false } - if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -notin $Category) + <# + If running in CI then check if it should run in the + current category set in $env:CONFIGURATION. + #> + if ($env:CI -eq $true -and -not (Test-ContinuousIntegrationTaskCategory -Category $Category)) { Write-Verbose -Message ('{1} tests in {0} will be skipped unless $env:CONFIGURATION is set to ''{1}''.' -f $Name, ($Category -join ''', or ''')) -Verbose - $result = $true + $result = $false } return $result @@ -371,7 +379,7 @@ function Test-ContinuousIntegrationTaskCategory $result = $false - if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -in $Category) + if ($env:CI -eq $true -and $env:CONFIGURATION -in $Category) { $result = $true } diff --git a/Tests/Tests.depend.psd1 b/tests/Tests.depend.psd1 similarity index 100% rename from Tests/Tests.depend.psd1 rename to tests/Tests.depend.psd1 diff --git a/Tests/Unit/MSFT_SqlAG.Tests.ps1 b/tests/Unit/MSFT_SqlAG.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlAG.Tests.ps1 rename to tests/Unit/MSFT_SqlAG.Tests.ps1 index 60ce897e9..346c7b0e7 100644 --- a/Tests/Unit/MSFT_SqlAG.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAG.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,27 +18,24 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAG' -#region HEADER - -# Unit Test Template Version: 1.2.1 $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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') @@ -48,10 +45,9 @@ function Invoke-TestSetup function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 b/tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 rename to tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 index 1fcc0873e..52357ca46 100644 --- a/Tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAGDatabase.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,42 +18,35 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAGDatabase' -#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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - # TODO: Other Optional Cleanup Code Goes Here... + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAGListener.Tests.ps1 b/tests/Unit/MSFT_SqlAGListener.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_SqlAGListener.Tests.ps1 rename to tests/Unit/MSFT_SqlAGListener.Tests.ps1 index 95a787f47..57d85e003 100644 --- a/Tests/Unit/MSFT_SqlAGListener.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAGListener.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAGListener' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 b/tests/Unit/MSFT_SqlAGReplica.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 rename to tests/Unit/MSFT_SqlAGReplica.Tests.ps1 index 2992896dd..f04bda7ed 100644 --- a/Tests/Unit/MSFT_SqlAGReplica.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAGReplica.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,40 +18,35 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAGReplica' -#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'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAgentAlert.Tests.ps1 b/tests/Unit/MSFT_SqlAgentAlert.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_SqlAgentAlert.Tests.ps1 rename to tests/Unit/MSFT_SqlAgentAlert.Tests.ps1 index 02382b35a..7c84913e8 100644 --- a/Tests/Unit/MSFT_SqlAgentAlert.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAgentAlert.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,36 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAgentAlert' -#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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAgentFailsafe.Tests.ps1 b/tests/Unit/MSFT_SqlAgentFailsafe.Tests.ps1 similarity index 94% rename from Tests/Unit/MSFT_SqlAgentFailsafe.Tests.ps1 rename to tests/Unit/MSFT_SqlAgentFailsafe.Tests.ps1 index 154d58385..0983b3a59 100644 --- a/Tests/Unit/MSFT_SqlAgentFailsafe.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAgentFailsafe.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,36 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAgentFailsafe' -#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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAgentOperator.Tests.ps1 b/tests/Unit/MSFT_SqlAgentOperator.Tests.ps1 similarity index 95% rename from Tests/Unit/MSFT_SqlAgentOperator.Tests.ps1 rename to tests/Unit/MSFT_SqlAgentOperator.Tests.ps1 index b42122acc..d1ec193e3 100644 --- a/Tests/Unit/MSFT_SqlAgentOperator.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAgentOperator.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,36 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAgentOperator' -#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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAlias.Tests.ps1 b/tests/Unit/MSFT_SqlAlias.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlAlias.Tests.ps1 rename to tests/Unit/MSFT_SqlAlias.Tests.ps1 index d7a17ebe1..8bc6ca264 100644 --- a/Tests/Unit/MSFT_SqlAlias.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAlias.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,33 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAlias' -#region HEADER - -# Unit Test Template Version: 1.2.1 -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit - -#endregion HEADER + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -function Invoke-TestSetup { + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 b/tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 similarity index 92% rename from Tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 rename to tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 index 373cdeba7..b28f78e0b 100644 --- a/Tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 +++ b/tests/Unit/MSFT_SqlAlwaysOnService.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,19 +18,20 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlAlwaysOnService' -# Unit Test Template Version: 1.1.0 -[System.String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Unit + -ResourceType 'Mof' ` + -TestType 'Unit' $disableHadr = @{ Ensure = 'Absent' @@ -56,7 +57,9 @@ $enableHadrNamedInstance = @{ InstanceName = 'NamedInstance' } -# Begin Testing +# Load the default SQL Module stub +Import-SQLModuleStub + try { Describe "$($script:dscResourceName)\Get-TargetResource" { @@ -129,9 +132,6 @@ try } Describe "$($script:dscResourceName)\Set-TargetResource" { - # Loading stub cmdlets - Import-Module -Name ( Join-Path -Path ( Join-Path -Path $PSScriptRoot -ChildPath Stubs ) -ChildPath SQLPSStub.psm1 ) -Force - Mock -CommandName Disable-SqlAlwaysOn -ModuleName $script:dscResourceName Mock -CommandName Enable-SqlAlwaysOn -ModuleName $script:dscResourceName Mock -CommandName Import-SQLPSModule -ModuleName $script:dscResourceName @@ -252,5 +252,5 @@ try } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Unit/MSFT_SqlDatabase.Tests.ps1 b/tests/Unit/MSFT_SqlDatabase.Tests.ps1 similarity index 95% rename from Tests/Unit/MSFT_SqlDatabase.Tests.ps1 rename to tests/Unit/MSFT_SqlDatabase.Tests.ps1 index 14adbfbd3..0312afd3e 100644 --- a/Tests/Unit/MSFT_SqlDatabase.Tests.ps1 +++ b/tests/Unit/MSFT_SqlDatabase.Tests.ps1 @@ -10,43 +10,37 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } -#region HEADER $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlDatabase' -# Unit Test Template Version: 1.2.4 -$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 -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit - -#endregion HEADER - function Invoke-TestSetup { + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + #Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 b/tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 similarity index 92% rename from Tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 rename to tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 index 4cd4c40a0..4bf359be7 100644 --- a/Tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 +++ b/tests/Unit/MSFT_SqlDatabaseDefaultLocation.Tests.ps1 @@ -9,7 +9,7 @@ #> Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -17,42 +17,35 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlDatabaseDefaultLocation' -#region Header - -# Unit Test Template Version: 1.2.1 -$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'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global - + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } - -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 b/tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 similarity index 93% rename from Tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 rename to tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 index ec9c36182..9b345c6e9 100644 --- a/Tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 +++ b/tests/Unit/MSFT_SqlDatabaseOwner.Tests.ps1 @@ -9,7 +9,7 @@ #> Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -17,35 +17,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $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 { + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 b/tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 rename to tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 index 8a0a4aac7..9451adef9 100644 --- a/Tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 +++ b/tests/Unit/MSFT_SqlDatabasePermission.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 b/tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 similarity index 92% rename from Tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 rename to tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 index e3946e463..a19163f70 100644 --- a/Tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 +++ b/tests/Unit/MSFT_SqlDatabaseRecoveryModel.Tests.ps1 @@ -9,7 +9,7 @@ #> Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -17,35 +17,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlDatabaseRecoveryModel' -#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 { + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 b/tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 rename to tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 index f8608995a..d07c29a37 100644 --- a/Tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 +++ b/tests/Unit/MSFT_SqlDatabaseRole.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlDatabaseRole' -#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')))) +function Invoke-TestSetup { - & git.exe @('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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlDatabaseUser.Tests.ps1 b/tests/Unit/MSFT_SqlDatabaseUser.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlDatabaseUser.Tests.ps1 rename to tests/Unit/MSFT_SqlDatabaseUser.Tests.ps1 index b4ffa0205..f55e8c89c 100644 --- a/Tests/Unit/MSFT_SqlDatabaseUser.Tests.ps1 +++ b/tests/Unit/MSFT_SqlDatabaseUser.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,36 +18,31 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlDatabaseUser' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlRS.Tests.ps1 b/tests/Unit/MSFT_SqlRS.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlRS.Tests.ps1 rename to tests/Unit/MSFT_SqlRS.Tests.ps1 index 87a4254a7..9ede9a202 100644 --- a/Tests/Unit/MSFT_SqlRS.Tests.ps1 +++ b/tests/Unit/MSFT_SqlRS.Tests.ps1 @@ -9,7 +9,7 @@ #> Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -17,37 +17,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlRS' -#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'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlRSSetup.Tests.ps1 b/tests/Unit/MSFT_SqlRSSetup.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_SqlRSSetup.Tests.ps1 rename to tests/Unit/MSFT_SqlRSSetup.Tests.ps1 index 4e2d3b002..2054e9bbc 100644 --- a/Tests/Unit/MSFT_SqlRSSetup.Tests.ps1 +++ b/tests/Unit/MSFT_SqlRSSetup.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,35 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlRSSetup' -#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 { + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlScript.Tests.ps1 b/tests/Unit/MSFT_SqlScript.Tests.ps1 similarity index 89% rename from Tests/Unit/MSFT_SqlScript.Tests.ps1 rename to tests/Unit/MSFT_SqlScript.Tests.ps1 index a961049ad..21720ab66 100644 --- a/Tests/Unit/MSFT_SqlScript.Tests.ps1 +++ b/tests/Unit/MSFT_SqlScript.Tests.ps1 @@ -14,7 +14,7 @@ param() Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -22,38 +22,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlScript' -#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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SqlPowerShellSqlExecutionException.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } - -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlScriptQuery.Tests.ps1 b/tests/Unit/MSFT_SqlScriptQuery.Tests.ps1 similarity index 87% rename from Tests/Unit/MSFT_SqlScriptQuery.Tests.ps1 rename to tests/Unit/MSFT_SqlScriptQuery.Tests.ps1 index dd7447589..353d1dbc4 100644 --- a/Tests/Unit/MSFT_SqlScriptQuery.Tests.ps1 +++ b/tests/Unit/MSFT_SqlScriptQuery.Tests.ps1 @@ -14,7 +14,7 @@ param () Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -22,41 +22,35 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlScriptQuery' -#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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SqlPowerShellSqlExecutionException.cs') - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } - -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 b/tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 similarity index 93% rename from Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 rename to tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 index 96a4904e8..149122c53 100644 --- a/Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,19 +18,20 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerConfiguration' -# Unit Test Template Version: 1.1.0 -[System.String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Unit + -ResourceType 'Mof' ` + -TestType 'Unit' $defaultState = @{ ServerName = 'CLU01' @@ -299,5 +300,5 @@ try } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/Tests/Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 b/tests/Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 rename to tests/Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 index 48ebb01b0..d6be51e9d 100644 --- a/Tests/Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerDatabaseMail.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,35 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerDatabaseMail' -#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 { + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 b/tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 rename to tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 index c40033c9e..e8b8cbe92 100644 --- a/Tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerEndpoint.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,35 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerEndpoint' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup { # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 b/tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 similarity index 93% rename from Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 rename to tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 index 192b9adc3..0acd2dc7c 100644 --- a/Tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerEndpointPermission.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerEndpointPermission' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 b/tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 similarity index 92% rename from Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 rename to tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 index 50c541df0..cf5ac9e0a 100644 --- a/Tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerEndpointState.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerEndpointState' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 b/tests/Unit/MSFT_SqlServerLogin.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 rename to tests/Unit/MSFT_SqlServerLogin.Tests.ps1 index 5012baaa1..8b4c72dc1 100644 --- a/Tests/Unit/MSFT_SqlServerLogin.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerLogin.Tests.ps1 @@ -14,7 +14,7 @@ param() Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -22,40 +22,35 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerLogin' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 b/tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 similarity index 95% rename from Tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 rename to tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 index 65a62ff41..b6f307128 100644 --- a/Tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerMaxDop.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerMaxDop' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerMemory.Tests.ps1 b/tests/Unit/MSFT_SqlServerMemory.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_SqlServerMemory.Tests.ps1 rename to tests/Unit/MSFT_SqlServerMemory.Tests.ps1 index 5bc4795e4..e6e99f51f 100644 --- a/Tests/Unit/MSFT_SqlServerMemory.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerMemory.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 b/tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 rename to tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 index 235240624..becb4559d 100644 --- a/Tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerNetwork.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,33 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerNetwork' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -function Invoke-TestSetup { + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerPermission.Tests.ps1 b/tests/Unit/MSFT_SqlServerPermission.Tests.ps1 similarity index 93% rename from Tests/Unit/MSFT_SqlServerPermission.Tests.ps1 rename to tests/Unit/MSFT_SqlServerPermission.Tests.ps1 index 087606534..1c6bab640 100644 --- a/Tests/Unit/MSFT_SqlServerPermission.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerPermission.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerPermission' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerReplication.Tests.ps1 b/tests/Unit/MSFT_SqlServerReplication.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlServerReplication.Tests.ps1 rename to tests/Unit/MSFT_SqlServerReplication.Tests.ps1 index 4e1534cc3..1ad9b172f 100644 --- a/Tests/Unit/MSFT_SqlServerReplication.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerReplication.Tests.ps1 @@ -14,7 +14,7 @@ param() Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -22,22 +22,20 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDSC' $script:dscResourceName = 'MSFT_SqlServerReplication' -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $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'))) ) +try +{ + Import-Module -Name DscResource.Test -Force +} +catch [System.IO.FileNotFoundException] { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Unit - -#endregion HEADER + -ResourceType 'Mof' ` + -TestType 'Unit' try { @@ -1018,7 +1016,7 @@ finally { #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment #endregion } diff --git a/Tests/Unit/MSFT_SqlServerRole.Tests.ps1 b/tests/Unit/MSFT_SqlServerRole.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlServerRole.Tests.ps1 rename to tests/Unit/MSFT_SqlServerRole.Tests.ps1 index 660924e14..cc2cef226 100644 --- a/Tests/Unit/MSFT_SqlServerRole.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerRole.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,35 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $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 { + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServerSecureConnection.Tests.ps1 b/tests/Unit/MSFT_SqlServerSecureConnection.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_SqlServerSecureConnection.Tests.ps1 rename to tests/Unit/MSFT_SqlServerSecureConnection.Tests.ps1 index b1461d234..820b47893 100644 --- a/Tests/Unit/MSFT_SqlServerSecureConnection.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServerSecureConnection.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServerSecureConnection' -#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'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ - # Importing SQLPS stubs - Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global + # Load the default SQL Module stub + Import-SQLModuleStub } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 b/tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 rename to tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 index a7d4eaf45..eae8b020f 100644 --- a/Tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 +++ b/tests/Unit/MSFT_SqlServiceAccount.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,37 +18,32 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlServiceAccount' -#region HEADER - -# Unit Test Template Version: 1.2.1 -$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'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlSetup.Tests.ps1 b/tests/Unit/MSFT_SqlSetup.Tests.ps1 similarity index 99% rename from Tests/Unit/MSFT_SqlSetup.Tests.ps1 rename to tests/Unit/MSFT_SqlSetup.Tests.ps1 index d824b620f..6dc10c02f 100644 --- a/Tests/Unit/MSFT_SqlSetup.Tests.ps1 +++ b/tests/Unit/MSFT_SqlSetup.Tests.ps1 @@ -14,7 +14,7 @@ param() Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -22,33 +22,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlSetup' -#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'))) ) +function Invoke-TestSetup { - & 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 + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -function Invoke-TestSetup { + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 b/tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 similarity index 90% rename from Tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 rename to tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 index 790aeecfe..f3330d756 100644 --- a/Tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 +++ b/tests/Unit/MSFT_SqlWaitForAG.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,33 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlWaitForAG' -#region HEADER - -# Unit Test Template Version: 1.2.1 -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Unit - -#endregion HEADER + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -function Invoke-TestSetup { + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } -function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 b/tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 similarity index 98% rename from Tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 rename to tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 index 5341397b1..09c1d33ce 100644 --- a/Tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 +++ b/tests/Unit/MSFT_SqlWindowsFirewall.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } @@ -18,33 +18,29 @@ if (Test-SkipContinuousIntegrationTask -Type 'Unit') $script:dscModuleName = 'SqlServerDsc' $script:dscResourceName = 'MSFT_SqlWindowsFirewall' -#region HEADER - -# Unit Test Template Version: 1.2.1 -$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'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath '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 +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -# Begin Testing try { Invoke-TestSetup diff --git a/Tests/Unit/SqlServerDsc.Common.Tests.ps1 b/tests/Unit/SqlServerDsc.Common.Tests.ps1 similarity index 99% rename from Tests/Unit/SqlServerDsc.Common.Tests.ps1 rename to tests/Unit/SqlServerDsc.Common.Tests.ps1 index 04a75aa51..65e8b140c 100644 --- a/Tests/Unit/SqlServerDsc.Common.Tests.ps1 +++ b/tests/Unit/SqlServerDsc.Common.Tests.ps1 @@ -10,25 +10,36 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (Test-SkipContinuousIntegrationTask -Type 'Unit') +if (-not (Test-BuildCategory -Type 'Unit')) { return } -# Import the SqlServerDsc.Common module to test -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules\SqlServerDsc.Common' +#region HEADER +$script:projectPath = "$PSScriptRoot\..\.." | Convert-Path +$script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript { + ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and + $(try { Test-ModuleManifest -Path $_.FullName -ErrorAction Stop } catch { $false }) + }).BaseName -Import-Module -Name (Join-Path -Path $script:modulesFolderPath -ChildPath 'SqlServerDsc.Common.psm1') -Force +$script:parentModule = Get-Module -Name $script:projectName -ListAvailable | Select-Object -First 1 +$script:subModulesFolder = Join-Path -Path $script:parentModule.ModuleBase -ChildPath 'Modules' +Remove-Module -Name $script:parentModule -Force -ErrorAction 'SilentlyContinue' + +$script:subModuleName = (Split-Path -Path $PSCommandPath -Leaf) -replace '\.Tests.ps1' +$script:subModuleFile = Join-Path -Path $script:subModulesFolder -ChildPath "$($script:subModuleName)" + +Import-Module $script:subModuleFile -Force -ErrorAction Stop +#endregion HEADER # Loading mocked classes Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SMO.cs') Add-Type -Path (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SqlPowerShellSqlExecutionException.cs') -# Importing SQLPS stubs -Import-Module -Name (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Force -Global +# Load the default SQL Module stub +Import-SQLModuleStub -InModuleScope 'SqlServerDsc.Common' { +InModuleScope $script:subModuleName { Describe 'SqlServerDsc.Common\Test-DscParameterState' -Tag 'TestDscParameterState' { Context -Name 'When passing values' -Fixture { It 'Should return true for two identical tables' { diff --git a/Tests/Unit/Stubs/SMO.cs b/tests/Unit/Stubs/SMO.cs similarity index 100% rename from Tests/Unit/Stubs/SMO.cs rename to tests/Unit/Stubs/SMO.cs diff --git a/Tests/Unit/Stubs/SQLPSStub.psm1 b/tests/Unit/Stubs/SQLPSStub.psm1 similarity index 99% rename from Tests/Unit/Stubs/SQLPSStub.psm1 rename to tests/Unit/Stubs/SQLPSStub.psm1 index 5b324e940..4ad2cba8a 100644 --- a/Tests/Unit/Stubs/SQLPSStub.psm1 +++ b/tests/Unit/Stubs/SQLPSStub.psm1 @@ -944,7 +944,7 @@ function Remove-SqlAvailabilityGroup { } function Remove-SqlAvailabilityReplica { - [CmdletBinding(DefaultParameterSetName='ByPath', ConfirmImpact='Medium')] + [CmdletBinding(SupportsShouldProcess=$true, DefaultParameterSetName='ByPath', ConfirmImpact='Medium')] param( [Parameter(ParameterSetName='ByPath', Mandatory=$true, Position=1)] [ValidateNotNullOrEmpty()] diff --git a/Tests/Unit/Stubs/SQLServerStub.psm1 b/tests/Unit/Stubs/SQLServerStub.psm1 similarity index 99% rename from Tests/Unit/Stubs/SQLServerStub.psm1 rename to tests/Unit/Stubs/SQLServerStub.psm1 index 5a78667ca..5cbd826a3 100644 --- a/Tests/Unit/Stubs/SQLServerStub.psm1 +++ b/tests/Unit/Stubs/SQLServerStub.psm1 @@ -1557,7 +1557,7 @@ function Remove-SqlAvailabilityGroup { } function Remove-SqlAvailabilityReplica { - [CmdletBinding(DefaultParameterSetName='ByPath', ConfirmImpact='Medium')] + [CmdletBinding(SupportsShouldProcess=$true, DefaultParameterSetName='ByPath', ConfirmImpact='Medium')] param( [Parameter(ParameterSetName='ByPath', Mandatory=$true, Position=1)] [ValidateNotNullOrEmpty()] diff --git a/Tests/Unit/Stubs/SqlPowerShellSqlExecutionException.cs b/tests/Unit/Stubs/SqlPowerShellSqlExecutionException.cs similarity index 100% rename from Tests/Unit/Stubs/SqlPowerShellSqlExecutionException.cs rename to tests/Unit/Stubs/SqlPowerShellSqlExecutionException.cs diff --git a/Tests/Unit/Stubs/Write-ModuleStubFile.ps1 b/tests/Unit/Stubs/Write-ModuleStubFile.ps1 similarity index 100% rename from Tests/Unit/Stubs/Write-ModuleStubFile.ps1 rename to tests/Unit/Stubs/Write-ModuleStubFile.ps1