Skip to content

Commit

Permalink
Fixed issue twith hardcoded database name and space
Browse files Browse the repository at this point in the history
  • Loading branch information
jensotto committed Jul 2, 2021
1 parent 2fc3d9d commit e29ed1e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- SPFarm
- Added parameter SkipRegisterAsDistributedCacheHost
- SPSearchServiceApp
- Fixed an issue if the analytics database where not provisioned with a
hardcoded name
- Fixed an issue if search databases had names containing one or more spaces

### Fixed

Expand Down
1 change: 1 addition & 0 deletions Modules/SharePointDsc/DscResource.Tests
Submodule DscResource.Tests added at bc9a07
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,15 @@ function Get-TargetResource
-User $farmAccount) -eq $false

Write-Verbose -Message "Checking Analytics reporting Database"
$analyticsDB = "$($adminDB)_AnalyticsReportingStore"
if ($farmAccountPermissionsNeedCorrecting -eq $false)
foreach ($database in $serviceApp.AnalyticsReportingDatabases)
{
$farmAccountPermissionsNeedCorrecting = (Confirm-UserIsDBOwner -SQLServer $dbServer `
-Database $analyticsDB `
-User $farmAccount) -eq $false
$analyticsDB = $database.Name
if ($farmAccountPermissionsNeedCorrecting -eq $false)
{
$farmAccountPermissionsNeedCorrecting = (Confirm-UserIsDBOwner -SQLServer $dbServer `
-Database $analyticsDB `
-User $farmAccount) -eq $false
}
}

Write-Verbose -Message "Checking Crawl Database(s)"
Expand Down Expand Up @@ -539,14 +542,17 @@ function Set-TargetResource
}

Write-Verbose -Message "Checking and correcting Analytics reporting Database"
$analyticsDB = "$($adminDB)_AnalyticsReportingStore"
if ((Confirm-UserIsDBOwner -SQLServer $dbServer `
-Database $analyticsDB `
-User $farmAccount) -eq $false)
foreach ($database in $serviceApp.AnalyticsReportingDatabases)
{
Set-UserAsDBOwner -SQLServer $dbServer `
-Database $analyticsDB `
-User $farmAccount
$analyticsDB = $database.Name
if ((Confirm-UserIsDBOwner -SQLServer $dbServer `
-Database $analyticsDB `
-User $farmAccount) -eq $false)
{
Set-UserAsDBOwner -SQLServer $dbServer `
-Database $analyticsDB `
-User $farmAccount
}
}

Write-Verbose -Message "Checking and correcting Crawl Database(s)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Confirm-UserIsDBOwner
$command.Connection = $connection

$command.CommandText = @"
USE $Database
USE [$Database]
SELECT DP1.name AS DatabaseRoleName,
isnull (DP2.name, 'No members') AS DatabaseUserName
Expand Down Expand Up @@ -116,7 +116,7 @@ function Set-UserAsDBOwner
$command.Connection = $connection

$command.CommandText = @"
USE $Database
USE [$Database]
DECLARE @NewUserName sysname;
Expand Down

0 comments on commit e29ed1e

Please sign in to comment.