From cea1154fa1ba7acca75924bd642a34e753f8c714 Mon Sep 17 00:00:00 2001 From: Apichaya Sakchaichanchol Date: Sun, 26 Aug 2018 01:56:07 +0700 Subject: [PATCH] Add example for multi-instance --- CHANGELOG.md | 2 +- .../MSFT_SqlDatabaseOwner.psm1 | 6 ++--- .../SqlDatabaseOwner/1-SetDatabaseOwner.ps1 | 23 +++++++++++++++++-- README.md | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92f1e8c5c..ab0ba754b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ([issue #1199](https://github.com/PowerShell/SqlServerDsc/issues/1199)). [Nick Reilingh (@NReilingh)](https://github.com/NReilingh) - Changes to SqlDatabaseOwner - - Support multi-instances which is the instance cannot be omitted + - BREAKING CHANGE: Support multi-instances which is the instance cannot be omitted ([issue #1197](https://github.com/PowerShell/SqlServerDsc/issues/1197)). ## 11.4.0.0 diff --git a/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 index b553b9809..428f7e5d5 100644 --- a/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 +++ b/DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1 @@ -41,7 +41,7 @@ function Get-TargetResource [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] - $InstanceName = 'MSSQLSERVER' + $InstanceName ) Write-Verbose -Message "Getting owner of database $Database" @@ -119,7 +119,7 @@ function Set-TargetResource [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] - $InstanceName = 'MSSQLSERVER' + $InstanceName ) Write-Verbose -Message "Setting owner $Name of database $Database" @@ -194,7 +194,7 @@ function Test-TargetResource [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] - $InstanceName = 'MSSQLSERVER' + $InstanceName ) Write-Verbose -Message "Testing owner $Name of database $Database" diff --git a/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 b/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 index ff3450ac3..ed823b5ba 100644 --- a/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 +++ b/Examples/Resources/SqlDatabaseOwner/1-SetDatabaseOwner.ps1 @@ -16,7 +16,7 @@ Configuration Example node localhost { - SqlServerLogin Add_SqlServerLogin_SQLAdmin + SqlServerLogin Add_SqlServerLogin_SQLAdmin_DSC { Ensure = 'Present' Name = 'CONTOSO\SQLAdmin' @@ -26,7 +26,17 @@ Configuration Example PsDscRunAsCredential = $SqlAdministratorCredential } - SqlDatabaseOwner Set_SqlDatabaseOwner_SQLAdmin + 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 { Name = 'CONTOSO\SQLAdmin' Database = 'AdventureWorks' @@ -34,5 +44,14 @@ Configuration Example InstanceName = 'DSC' PsDscRunAsCredential = $SqlAdministratorCredential } + + SqlDatabaseOwner Set_SqlDatabaseOwner_SQLAdmin_DSC2 + { + Name = 'CONTOSO\SQLAdmin' + Database = 'AdventureWorks' + ServerName = 'sqltest.company.local' + InstanceName = 'DSC2' + PsDscRunAsCredential = $SqlAdministratorCredential + } } } diff --git a/README.md b/README.md index 6e01b9a0f..23b77c936 100644 --- a/README.md +++ b/README.md @@ -587,7 +587,7 @@ For more information about database owner, please read the article * **`[String]` Name** _(Required)_: The name of the login that will become a owner of the desired sql database. * **`[String]` ServerName** _(Write)_: The host name of the SQL Server to be configured. -* **`[String]` InstanceName** _(Write)_: The name of the SQL instance to be configured. +* **`[String]` InstanceName** _(Key)_: The name of the SQL instance to be configured. #### Examples