Skip to content

Commit

Permalink
Merge branch 'master' into fix-error-when-no-workflow-is-configured
Browse files Browse the repository at this point in the history
  • Loading branch information
ykuijs authored Nov 10, 2020
2 parents 3db0481 + 59229a7 commit 6d5199c
Show file tree
Hide file tree
Showing 15 changed files with 639 additions and 41 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SharePointDsc
- Added logging to the event log when the code throws an exception

### Changed

- SPFarm
- Switched from creating a Lock database to a Lock table in the TempDB.
This to allow the use of precreated databases.
- SPSite
- Added more explanation to documentation on which parameters are checked
- SPWeb
- Added more explanation to documentation on using this resource

### Fixed

- SPConfigWizard
- Fixes issue where a CU installation wasn't registered properly in the
config database. Added logic to run the Product Version timer job
- SPSearchTopology
- Fixes issue where applying a topology failed when the search service
instance was disabled instead of offline
- SPSecureStoreServiceApp
- Fixes issue where custom database name was no longer used since v4.3
- SPShellAdmins
- Fixed issue with Get-DscConfiguration which threw an error when only one
item was returned by the Get method
- SPWordAutomationServiceApp
- Fixed issue where provisioning the service app requires a second run to
update all specified parameters
- SPWorkflowService
- Fixed issue configuring workflow service when no workflow service is currently configured.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,26 @@ function Set-TargetResource
-ScriptBlock {
$psconfigExe = $args[0]

Write-Verbose -Message "Starting 'Product Version Job' timer job"
$pvTimerJob = Get-SPTimerJob -Identity 'job-admin-product-version'
$lastRunTime = $pvTimerJob.LastRunTime

Start-SPTimerJob -Identity $pvTimerJob

$jobRunning = $true
$maxCount = 30
$count = 0
Write-Verbose -Message "Waiting for 'Product Version Job' timer job to complete"
while ($jobRunning -and $count -le $maxCount)
{
Start-Sleep -Seconds 10

$pvTimerJob = Get-SPTimerJob -Identity 'job-admin-product-version'
$jobRunning = $lastRunTime -eq $pvTimerJob.LastRunTime

$count++
}

$stdOutTempFile = "$env:TEMP\$((New-Guid).Guid)"
$psconfig = Start-Process -FilePath $psconfigExe `
-ArgumentList "-cmd upgrade -inplace b2b -wait -cmd applicationcontent -install -cmd installfeatures -cmd secureresources -cmd services -install" `
Expand Down
49 changes: 35 additions & 14 deletions SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ function Set-TargetResource
$currentUri = [System.Uri]$centralAdminSite.Url
if ($desiredUri.AbsoluteUri -ne $currentUri.AbsoluteUri)
{
Write-Verbose -Message "Re-provisioning CA because $($currentUri.AbsoluteUri) does not equal $($desiredUri.AbsoluteUri)"
Write-Verbose -Message ("Re-provisioning CA because $($currentUri.AbsoluteUri) " + `
"does not equal $($desiredUri.AbsoluteUri)")
$reprovisionCentralAdmin = $true
}
else
Expand All @@ -657,14 +658,17 @@ function Set-TargetResource
if ($desiredUri.Host -ne $iisBindings[0].HostHeader -or
$desiredUri.Port -ne $iisBindings[0].Port)
{
Write-Verbose -Message "Re-provisioning CA because $($desiredUri.Host) does not equal $($iisBindings[0].HostHeader) or $($desiredUri.Port) does not equal $($iisBindings[0].Port)"
Write-Verbose -Message ("Re-provisioning CA because $($desiredUri.Host) does not " + `
"equal $($iisBindings[0].HostHeader) or $($desiredUri.Port) does not " + `
"equal $($iisBindings[0].Port)")
$reprovisionCentralAdmin = $true
}
}
else
{
# iisBindings did not exist or did not contain a valid hostheader
Write-Verbose -Message "Re-provisioning CA because IIS Bindings does not exist or does not contain a valid host header"
Write-Verbose -Message ("Re-provisioning CA because IIS Bindings does not " + `
"exist or does not contain a valid host header")
$reprovisionCentralAdmin = $true
}
}
Expand Down Expand Up @@ -707,7 +711,8 @@ function Set-TargetResource
if ($CurrentValues.CentralAdministrationAuth -ne $CentralAdministrationAuth -and
(-not $reprovisionCentralAdmin))
{
Write-Verbose -Message "Updating CentralAdmin authentication method from $($CurrentValues.CentralAdministrationAuth) to $CentralAdministrationAuth"
Write-Verbose -Message ("Updating CentralAdmin authentication method from " + `
"$($CurrentValues.CentralAdministrationAuth) to $CentralAdministrationAuth")
Invoke-SPDscCommand -Credential $InstallAccount `
-Arguments $PSBoundParameters `
-ScriptBlock {
Expand Down Expand Up @@ -756,7 +761,8 @@ function Set-TargetResource

if ($params.UseSQLAuthentication -eq $true)
{
Write-Verbose -Message "Using SQL authentication to create service application as `$useSQLAuthentication is set to $($params.useSQLAuthentication)."
Write-Verbose -Message ("Using SQL authentication to create service application as " + `
"`$useSQLAuthentication is set to $($params.useSQLAuthentication).")
$databaseCredentialsParam = @{
DatabaseCredentials = $params.DatabaseCredentials
}
Expand Down Expand Up @@ -795,12 +801,24 @@ function Set-TargetResource

if ($dbStatus.ValidPermissions -eq $false)
{
$message = "The current user does not have sufficient permissions to SQL Server"
Add-SPDscEvent -Message $message `
-EntryType 'Error' `
-EventID 100 `
-Source $eventSource
throw $message
if ($dbStatus.DatabaseEmpty -eq $true)
{
# If DatabaseEmpty is True most probably precreated databases are being used
Write-Verbose -Message ("IMPORTANT: Permissions check failed, but an empty " + `
"configDB '$($params.FarmConfigDatabaseName)' was found. Assuming that " + `
"precreated databases are being used.")
}
else
{
# If DatabaseEmpty is False, then either the specified ConfigDB doesn't exist or
# is already provisioned
$message = "The current user does not have sufficient permissions to SQL Server"
Add-SPDscEvent -Message $message `
-EntryType 'Error' `
-EventID 100 `
-Source $eventSource
throw $message
}
}

$executeArgs = @{
Expand All @@ -814,12 +832,14 @@ function Set-TargetResource

if ($params.useSQLAuthentication -eq $true)
{
Write-Verbose -Message "Using SQL authentication to connect to / create farm as `$useSQLAuthentication is set to $($params.useSQLAuthentication)."
Write-Verbose -Message ("Using SQL authentication to connect to / create farm as " + `
"`$useSQLAuthentication is set to $($params.useSQLAuthentication).")
$executeArgs.Add("DatabaseCredentials", $params.DatabaseCredentials)
}
else
{
Write-Verbose -Message "`$useSQLAuthentication is false or not specified; using default Windows authentication."
Write-Verbose -Message ("`$useSQLAuthentication is false or not specified; using " + `
"default Windows authentication.")
}

$installedVersion = Get-SPDscInstalledProductVersion
Expand Down Expand Up @@ -1087,7 +1107,8 @@ function Set-TargetResource
}
elseif ($desiredUri.AbsoluteUri -ne $currentUri.AbsoluteUri)
{
Write-Verbose -Message "Re-provisioning CA because $($currentUri.AbsoluteUri) does not equal $($desiredUri.AbsoluteUri)"
Write-Verbose -Message ("Re-provisioning CA because $($currentUri.AbsoluteUri) " + `
"does not equal $($desiredUri.AbsoluteUri)")
$reprovisionCentralAdmin = $true
}

Expand Down
3 changes: 3 additions & 0 deletions SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ NOTE:
When using SharePoint 2016 and later and enabling the Developer Dashboard,
please make sure you also provision the Usage and Health service application
to make sure the Developer Dashboard works properly.

NOTE2:
Since v4.4 the resource supports the use of precreated databases.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function Set-TargetResource
$searchService = Get-SPEnterpriseSearchServiceInstance -Identity $searchServer
}

if ($searchService.Status -eq "Offline")
if (($searchService.Status -eq "Offline") -or ($searchService.Status -eq "Disabled"))
{
Write-Verbose -Message "Start Search Service Instance"
Start-SPEnterpriseSearchServiceInstance -Identity $searchServer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ function Set-TargetResource
$newParams.Add("DatabasePassword", $params.DatabaseCredentials.Password)
}

$paramList = @('AuditlogMaxSize', 'DatabaseName', 'DatabaseServer', 'FailoverDatabaseServer', 'PartitionMode', 'Sharing')

foreach ($item in ($params.GetEnumerator() | Where-Object -FilterScript { $_.Key -in $paramList }))
{
$newParams.Add($item.Key, $item.Value)
}

$pName = "$($params.Name) Proxy"

if ($params.ContainsKey("ProxyName") -and $null -ne $params.ProxyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function Get-TargetResource

return @{
IsSingleInstance = "Yes"
Members = $shellAdmins.UserName
Members = [System.Array]$shellAdmins.UserName
MembersToInclude = $params.MembersToInclude
MembersToExclude = $params.MembersToExclude
Databases = $cdbPermissions
Expand Down
10 changes: 7 additions & 3 deletions SharePointDsc/DSCResources/MSFT_SPSite/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ This resource will provision a site collection to the current farm, based on
the settings that are passed through. These settings map to the New-SPSite
cmdlet and accept the same values and types.

The current version of SharePointDsc is only able to check for the existence
of a site collection, the additional parameters are not checked for yet, but
will be in a later release
When the site collection exists, not all parameters are checked for being
in the desired state. The following parameters are checked:
QuotaTemplate, OwnerAlias, SecondaryOwnerAlias, AdministrationSiteType

Since the title of the site collection can be changed by the site collection
owner and can result in a conflict between the owner and DSC. Therefore the
resource is only using the Name parameter during site creation.

NOTE:
When creating Host Header Site Collections, do not use the HostHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ implications. More information about these risks can be found at:
http://www.powershellmagazine.com/2014/03/06/accidental-sabotage-beware-of-credssp/

NOTE2:
You should always specify the MySiteHostLocation parameter. Currently this is not
a required parameter, but will be as of SharePointDsc v4.0.

NOTE3:
The UpdateProxyGroup parameter fixes the following issue:
The User Profile service is looking up the proxy groups to find the correct MMS.
Unfortunately it doesn't follow what you configured in Central Administration.
Expand Down
5 changes: 5 additions & 0 deletions SharePointDsc/DSCResources/MSFT_SPWeb/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ through. These settings map to the New-SPWeb cmdlet and accept the same values

The default value for the Ensure parameter is Present. When not specifying this
parameter, the web is created.

NOTE:
Since subsites/webs can be created/deleted by site collection owners it is
possible that using this resource results in a conflict between the owner
and DSC. Therefore be careful using this resource.
Original file line number Diff line number Diff line change
Expand Up @@ -371,20 +371,18 @@ function Set-TargetResource
$appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool
if ($appPool)
{
$cmdletparams = @{ }
$cmdletparams.Name = $params.Name
if ($params.Name)
$cmdletparams = @{
Name = $params.Name
ApplicationPool = $params.ApplicationPool
}
if ($params.ContainsKey("DatabaseName"))
{
$cmdletparams.DatabaseName = $params.DatabaseName
}
if ($params.Name)
if ($params.ContainsKey("DatabaseServer"))
{
$cmdletparams.DatabaseServer = $params.DatabaseServer
}
if ($params.Name)
{
$cmdletparams.ApplicationPool = $params.ApplicationPool
}

if ($params.useSQLAuthentication -eq $true)
{
Expand All @@ -408,6 +406,10 @@ function Set-TargetResource
throw $message
}
}

# Retrieving updated current state, so additionally
# specified parameters are also updated.
$result = Get-TargetResource @PSBoundParameters
}

if ($result.Ensure -eq "Present" -and $Ensure -eq "Present")
Expand Down
20 changes: 10 additions & 10 deletions SharePointDsc/Modules/SharePointDsc.Farm/SPFarm.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ function Get-SPDscConfigDBStatus
$command.CommandText = "SELECT COUNT(*) FROM sys.databases WHERE name = '$Database'"
$configDBexists = ($command.ExecuteScalar() -eq 1)

$command.CommandText = "SELECT COUNT(*) FROM sys.databases WHERE name = '$($Database)_Lock'"
$lockExists = ($command.ExecuteScalar() -eq 1)

$serverRolesToCheck = @("dbcreator", "securityadmin")
$hasPermissions = $true
foreach ($serverRole in $serverRolesToCheck)
Expand All @@ -88,6 +85,10 @@ function Get-SPDscConfigDBStatus
$configDBempty = ($command.ExecuteScalar() -eq 0)
}

$connection.ChangeDatabase('TempDB')
$command.CommandText = "SELECT COUNT([name]) FROM sys.tables WHERE [name] = 'SPDscLock'"
$lockExists = ($command.ExecuteScalar() -eq 1)

return @{
DatabaseExists = $configDBexists
DatabaseEmpty = $configDBempty
Expand Down Expand Up @@ -232,7 +233,7 @@ function Add-SPDscConfigDBLock
}
else # Just use Windows integrated auth
{
$connection.ConnectionString = "Server=$SQLServer;Integrated Security=SSPI;Database=Master"
$connection.ConnectionString = "Server=$SQLServer;Integrated Security=SSPI;Database=TempDB"
}
$command = New-Object -TypeName "System.Data.SqlClient.SqlCommand"

Expand All @@ -241,8 +242,8 @@ function Add-SPDscConfigDBLock
$connection.Open()
$command.Connection = $connection

$command.CommandText = "CREATE DATABASE [$($Database)_Lock]"
$command.ExecuteNonQuery()
$command.CommandText = "CREATE TABLE SPDscLock (Locked BIT)"
$null = $command.ExecuteNonQuery()
}
finally
{
Expand Down Expand Up @@ -308,7 +309,7 @@ function Remove-SPDscConfigDBLock
}
else # Just use Windows integrated auth
{
$connection.ConnectionString = "Server=$SQLServer;Integrated Security=SSPI;Database=Master"
$connection.ConnectionString = "Server=$SQLServer;Integrated Security=SSPI;Database=TempDB"
}
$command = New-Object -TypeName "System.Data.SqlClient.SqlCommand"

Expand All @@ -317,8 +318,8 @@ function Remove-SPDscConfigDBLock
$connection.Open()
$command.Connection = $connection

$command.CommandText = "DROP DATABASE [$($Database)_Lock]"
$command.ExecuteNonQuery()
$command.CommandText = "DROP TABLE [SPDscLock]"
$null = $command.ExecuteNonQuery()
}
finally
{
Expand All @@ -329,4 +330,3 @@ function Remove-SPDscConfigDBLock
}
}
}

Loading

0 comments on commit 6d5199c

Please sign in to comment.