Skip to content

Commit

Permalink
Merge pull request #1226 from ykuijs/bugfixes
Browse files Browse the repository at this point in the history
Bugfix PR
  • Loading branch information
ykuijs authored Jul 30, 2020
2 parents 533c619 + 8235b4e commit 630f8c7
Show file tree
Hide file tree
Showing 11 changed files with 440 additions and 359 deletions.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- SPProductUpdate
- Added extra logging when the setup file was not found
- SPSecureStoreServiceApp
- Added possibility to set the Master Key during creation of the service
application

### Fixed

- SharePointDsc
- Fixed issue where Invoke-SPDscCommand wasn't available anymore for the script
resource
- SPContentDatabase
- Fixed issue where the set method didn't do anything when the Ensure parameter
wasn't specified
- SPFarmSolution
- Fixed issue where web applications weren't compared properly when the desired
value didn't contain any slashes
- SPInstallLanguagePack
- Fixed issue with detection of Chinese language pack in SharePoint 2019
- SPStateServiceApp
- Fixed issue where code failed because the State database already existed
- SPTrustedIdentityTokenIssuer
- Run Get-SPClaimProvider only if property ClaimProviderName is omitted/null/empty.
- Run Get-SPClaimProvider only if property ClaimProviderName is omitted/null/empty

## [4.2.0] - 2020-06-12

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting content database configuration settings"

$PSBoundParameters.Ensure = $Ensure

Invoke-SPDscCommand -Credential $InstallAccount `
-Arguments $PSBoundParameters `
-ScriptBlock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,15 @@ function Test-TargetResource
$PSBoundParameters.Ensure = $Ensure

$CurrentValues = Get-TargetResource @PSBoundParameters
if ($CurrentValues.ContainsKey("WebAppUrls") -and $CurrentValues.WebAppUrls.Count -ne 0)
{
$CurrentValues.WebAppUrls = $CurrentValues.WebAppUrls.TrimEnd("/")
}

if ($PSBoundParameters.ContainsKey("WebAppUrls") -and $PSBoundParameters.WebAppUrls.Count -ne 0)
{
$PSBoundParameters.WebAppUrls = $PSBoundParameters.WebAppUrls.TrimEnd("/")
}

Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)"
Expand Down Expand Up @@ -458,7 +467,7 @@ function Wait-SPDscSolutionJob
Name = $SolutionName
}

$result = Invoke-SPDscCommand -Credential $InstallAccount `
$null = Invoke-SPDscCommand -Credential $InstallAccount `
-Arguments $args `
-ScriptBlock {
$params = $args[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ function Get-TargetResource
{
$parsedENProduct = $parsedProduct[1] -split "/"
$languageEN = $parsedENProduct[0]

if ($languageEN -eq "Chinese (Simplified)")
{
$languageEN = "Chinese (PRC)"
}

if ($languageEN -eq "Chinese (Traditional)")
{
$languageEN = "Chinese (Taiwan)"
}
}
"Portuguese"
{
Expand Down Expand Up @@ -183,35 +193,11 @@ function Get-TargetResource
}
"Chinese (Simplified, China)"
{
# Language name of Chinese SP2013/2016 and SP2019 install package are different
$installedVersion = Get-SPDscInstalledProductVersion
if ($installedVersion.FileMajorPart -eq 16 -and `
$installedVersion.ProductBuildPart.ToString().Length -gt 4)
{
# SP2019
$languageEnglish = "Chinese (Simplified)"
}
else
{
# SP2013/2016
$languageEnglish = "Chinese (PRC)"
}
$languageEnglish = "Chinese (PRC)"
}
"Chinese (Traditional, Taiwan)"
{
# Language name of Chinese SP2013/2016 and SP2019 install package are different
$installedVersion = Get-SPDscInstalledProductVersion
if ($installedVersion.FileMajorPart -eq 16 -and `
$installedVersion.ProductBuildPart.ToString().Length -gt 4)
{
# SP2019
$languageEnglish = "Chinese (Traditional)"
}
else
{
# SP2013/2016
$languageEnglish = "Chinese (Taiwan)"
}
$languageEnglish = "Chinese (Taiwan)"
}
"Portuguese (Brazil)"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ function Get-TargetResource

Write-Verbose -Message "Getting install status of SP binaries"

$languagepack = $false
$servicepack = $false
$language = ""

Write-Verbose -Message "Check if the setup file exists"
if (-not(Test-Path -Path $SetupFile))
{
Write-Verbose -Message "ERROR: Setup files could not be found: $SetupFile"
return @{
SetupFile = $SetupFile
ShutdownServices = $ShutdownServices
Expand Down Expand Up @@ -134,7 +133,6 @@ function Get-TargetResource
{
Write-Verbose -Message "Update is a Language Pack Service Pack."
# Retrieve language from file and check version for that language pack.
$languagepack = $true

# Extract language from filename
if ($setupFileInfo.Name -match "\w*-(\w{2}-\w{2}).exe")
Expand Down Expand Up @@ -202,7 +200,6 @@ function Get-TargetResource
{
Write-Verbose -Message "Update is a Service Pack for SharePoint."
# Check SharePoint version information.
$servicepack = $true
$versionInfo = Get-SPDscLocalVersionInfo -ProductVersion $sharePointVersion
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function Get-TargetResource
[System.Boolean]
$Sharing,

[Parameter()]
[System.Management.Automation.PSCredential]
$MasterKey,

[Parameter()]
[ValidateSet("Present", "Absent")]
[System.String]
Expand Down Expand Up @@ -189,6 +193,10 @@ function Set-TargetResource
[System.Boolean]
$Sharing,

[Parameter()]
[System.Management.Automation.PSCredential]
$MasterKey,

[Parameter()]
[ValidateSet("Present", "Absent")]
[System.String]
Expand Down Expand Up @@ -216,33 +224,34 @@ function Set-TargetResource
-ScriptBlock {
$params = $args[0]

if ($params.ContainsKey("Ensure"))
{
$params.Remove("Ensure") | Out-Null
}
if ($params.ContainsKey("InstallAccount"))
{
$params.Remove("InstallAccount") | Out-Null
$newParams = @{
Name = $params.Name
ApplicationPool = $params.ApplicationPool
AuditingEnabled = $params.AuditingEnabled
}

if ($params.UseSQLAuthentication -eq $true)
{
Write-Verbose -Message "Using SQL authentication to create service application as `$useSQLAuthentication is set to $($params.useSQLAuthentication)."
$params.Add("DatabaseUsername", $params.DatabaseCredentials.Username)
$params.Add("DatabasePassword", $params.DatabaseCredentials.Password)
$newParams.Add("DatabaseUsername", $params.DatabaseCredentials.Username)
$newParams.Add("DatabasePassword", $params.DatabaseCredentials.Password)
}
$params.Remove("UseSQLAuthentication") | Out-Null
$params.Remove("DatabaseCredentials") | Out-Null

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

if ($params.ContainsKey("ProxyName") -and $null -ne $params.ProxyName)
{
$pName = $params.ProxyName
$params.Remove("ProxyName") | Out-Null
}

New-SPSecureStoreServiceApplication @params | New-SPSecureStoreServiceApplicationProxy -Name $pName
New-SPSecureStoreServiceApplication @newParams | New-SPSecureStoreServiceApplicationProxy -Name $pName

if ($params.ContainsKey("MasterKey"))
{
$newPassPhrase = $params.MasterKey.GetNetworkCredential().Password
$proxy = Get-SPServiceApplicationProxy | Where-Object -FilterScript { $_.Name -eq $pName }
Update-SPSecureStoreMasterKey -ServiceApplicationProxy $proxy -Passphrase $newPassPhrase
}
}
}

Expand Down Expand Up @@ -361,6 +370,10 @@ function Test-TargetResource
[System.Boolean]
$Sharing,

[Parameter()]
[System.Management.Automation.PSCredential]
$MasterKey,

[Parameter()]
[ValidateSet("Present", "Absent")]
[System.String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MSFT_SPSecureStoreServiceApp : OMI_BaseResource
[Write, Description("The name of the database server hosting a failover instance of the database")] string FailoverDatabaseServer;
[Write, Description("Is partition mode enabled for this service app")] boolean PartitionMode;
[Write, Description("Is sharing enabled for this service app")] boolean Sharing;
[Write, Description("Specify the Master Key to be used to encrypt the secrets. Only used during creation of the Service Application"), EmbeddedInstance("MSFT_Credential")] String MasterKey;
[Write, Description("Present if the service app should exist, absent if it should not"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
[Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount;
[Write, Description("Should SQL Server authentication be used to connect to the database?")] Boolean UseSQLAuthentication;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,6 @@ function Set-TargetResource

$params = $args[0]

$dbParams = @{ }

if ($params.ContainsKey("DatabaseName"))
{
$dbParams.Add("Name", $params.DatabaseName)
}
if ($params.ContainsKey("DatabaseServer"))
{
$dbParams.Add("DatabaseServer", $params.DatabaseServer)
}
if ($params.ContainsKey("DatabaseCredentials"))
{
$dbParams.Add("DatabaseCredentials", $params.DatabaseCredentials)
}

if ($params.ContainsKey("ProxyName"))
{
$pName = $params.ProxyName
Expand All @@ -161,11 +146,31 @@ function Set-TargetResource
$pName = "$($params.Name) Proxy"
}

$database = New-SPStateServiceDatabase @dbParams
$database = Get-SPStateServiceDatabase -Identity $params.DatabaseName
if ($null -eq $database)
{
$dbParams = @{ }

if ($params.ContainsKey("DatabaseName"))
{
$dbParams.Add("Name", $params.DatabaseName)
}
if ($params.ContainsKey("DatabaseServer"))
{
$dbParams.Add("DatabaseServer", $params.DatabaseServer)
}
if ($params.ContainsKey("DatabaseCredentials"))
{
$dbParams.Add("DatabaseCredentials", $params.DatabaseCredentials)
}

$database = New-SPStateServiceDatabase @dbParams
}

$app = New-SPStateServiceApplication -Name $params.Name -Database $database
New-SPStateServiceApplicationProxy -Name $pName `
$null = New-SPStateServiceApplicationProxy -Name $pName `
-ServiceApplication $app `
-DefaultProxyGroup | Out-Null
-DefaultProxyGroup
}
}
if ($Ensure -eq "Absent")
Expand Down
Loading

0 comments on commit 630f8c7

Please sign in to comment.