Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to handle Farms with multiple SQL Server instances #92

Open
kayodebristol opened this issue Nov 12, 2019 · 0 comments
Open

Fails to handle Farms with multiple SQL Server instances #92

kayodebristol opened this issue Nov 12, 2019 · 0 comments

Comments

@kayodebristol
Copy link

Details of the scenario you try and problem that is occurring:
When running on Farms with multiple SQL Server instances, script only captures first database server name.

The DSC configuration that is using the resource: MSFT_SPContentDatabase

Version of the DSC module you're using: 3.6.0.0

Suggested fix:

function Read-SPContentDatabase()
{
    $module = Resolve-Path ($Script:SPDSCPath + "\DSCResources\MSFT_SPContentDatabase\MSFT_SPContentDatabase.psm1")
    Import-Module $module
    $params = Get-DSCFakeParameters -ModulePath $module
    $spContentDBs = Get-SPContentDatabase

    $i = 1
    $total = $spContentDBs.Length
    foreach($spContentDB in $spContentDBs)
    {
        try
        {
            $dbName = $spContentDB.Name
            Write-Host "Scanning Content Database [$i/$total] {$dbName}"
            $Script:dscConfigContent += "        SPContentDatabase " + $spContentDB.Name.Replace(" ", "") + "`r`n"
            $Script:dscConfigContent += "        {`r`n"
            $params.Name = $dbName
            $params.WebAppUrl = $spContentDB.WebApplication.Url
            $results = Get-TargetResource @params
            $results = Repair-Credentials -results $results

            <# Incorrectly assumes single SQL Server 
                Add-ConfigurationDataEntry -Node "NonNodeData" -Key "$($dbName)_DatabaseServer" -Value $spContentDB.Server -Description "Name of the Database Server associated with the destination SharePoint Farm;"
                $dbServerName = "`$ConfigurationData.NonNodeData.$($dbName)_DatabaseServer"
            #>

            #Capture the actual SQL Database Server associated with the Content Database
            $results.DatabaseServer = $spContentDB.Server

            $currentBlock = Get-DSCBlock -UseGetTargetResource -Params $results -ModulePath $module
            $currentBlock = Convert-DSCStringParamToVariable -DSCBlock $currentBlock -ParameterName "DatabaseServer"
            $Script:dscConfigContent += $currentBlock
            $Script:dscConfigContent += "        }`r`n"
            $i++
        }
        catch
        {
            $Script:ErrorLog += "[Content Database]" + $spContentDB.Name + "`r`n"
            $Script:ErrorLog += "$_`r`n`r`n"
        }
    }
}
kayodebristol pushed a commit to kayodebristol/SharePointDSC.Reverse that referenced this issue Nov 12, 2019
kayodebristol pushed a commit to kayodebristol/SharePointDSC.Reverse that referenced this issue Nov 13, 2019
kayodebristol pushed a commit to kayodebristol/SharePointDSC.Reverse that referenced this issue Nov 14, 2019
kayodebristol added a commit to kayodebristol/SharePointDSC.Reverse that referenced this issue Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant