diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b41a94f2..74497ecfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,18 +5,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- SPWebAppPolicy + - Fixed a blocking issue introduced in version 4.4.0 when extracting cache + accounts + +## [4.4.0] - 2020-11-14 + ### Added - SharePointDsc - Added logging to the event log when the code throws an exception + - Added support for trusted domains to Test-SPDscIsADUser helper function +- SPInstall + - Added documentation about a SharePoint 2019 installer issue ### Changed - SPAlternateUrl - Fixed issue where trailing '/' cause Url not to be recognized. +- SharePointDsc + - Updated Convert-SPDscHashtableToString to output the username when + parameter is a PSCredential - SPFarm - Switched from creating a Lock database to a Lock table in the TempDB. This to allow the use of precreated databases. + - Updated code to properly output used credential parameters to verbose + logging - SPSite - Added more explanation to documentation on which parameters are checked - SPWeb @@ -39,7 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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. + - Fixed issue configuring workflow service when no workflow service is + currently configured ## [4.3.0] - 2020-09-30 diff --git a/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 b/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 index 384cf0150..8757cf1b9 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 @@ -982,6 +982,20 @@ function Set-TargetResource { try { + Write-Verbose -Message "Connecting to existing Config database" + Write-Verbose -Message "executeArgs is:" + foreach ($arg in $executeArgs.Keys) + { + if ($executeArgs.$arg -is [System.Management.Automation.PSCredential]) + { + Write-Verbose -Message "$arg : $($executeArgs.$arg.UserName)" + } + else + { + Write-Verbose -Message "$arg : $($executeArgs.$arg)" + } + } + Connect-SPConfigurationDatabase @executeArgs | Out-Null $connectedToFarm = $true } @@ -1031,7 +1045,14 @@ function Set-TargetResource Write-Verbose -Message "executeArgs is:" foreach ($arg in $executeArgs.Keys) { - Write-Verbose -Message "$arg $($executeArgs[$arg])" + if ($executeArgs.$arg -is [System.Management.Automation.PSCredential]) + { + Write-Verbose -Message "$arg : $($executeArgs.$arg.UserName)" + } + else + { + Write-Verbose -Message "$arg : $($executeArgs.$arg)" + } } New-SPConfigurationDatabase @executeArgs diff --git a/SharePointDsc/DSCResources/MSFT_SPInstall/Readme.md b/SharePointDsc/DSCResources/MSFT_SPInstall/Readme.md index f77a487ac..8a8e10e56 100644 --- a/SharePointDsc/DSCResources/MSFT_SPInstall/Readme.md +++ b/SharePointDsc/DSCResources/MSFT_SPInstall/Readme.md @@ -20,6 +20,28 @@ stream is added to indicate that the file is potentially from an unsafe source. To use these files, make sure you first unblock them using Unblock-File. SPInstall will throw an error when it detects the file is blocked. +NOTE 3: +The SharePoint 2019 installer has an issue with the Visual C++ Redistributable. +The Prerequisites Installer accepts a lower version than the SharePoint Setup +requires, resulting in the setup throwing an error message. The solution is to +download the most recent version of the Redistributable and using the Package +resource to install it through DSC: + +```PowerShell +Package 'Install_VC2017ReDistx64' +{ + Name = 'Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.24.28127' + Path = 'C:\Install\SharePoint\prerequisiteinstallerfiles\vc_redist.x64.exe' + Arguments = '/quiet /norestart' + ProductId = '282975d8-55fe-4991-bbbb-06a72581ce58' + Ensure = 'Present' + Credential = $InstallAccount +} +``` + +More information: +https://docs.microsoft.com/en-us/sharepoint/troubleshoot/installation-and-setup/sharepoint-server-setup-fails + ## Multilingual support Where possible, resources in SharePointDsc have been written in a way that diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 index 977801b2d..4d9d1d838 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 @@ -294,7 +294,7 @@ function Set-TargetResource throw $message } - $cacheAccounts = Get-SPDscCacheAccountConfiguration -InputParameters $WebAppUrl + $cacheAccounts = Get-SPDscCacheAccountConfiguration -WebApplicationUrl $WebAppUrl if ($SetCacheAccountsPolicy) { @@ -692,7 +692,7 @@ function Test-TargetResource return $false } - $cacheAccounts = Get-SPDscCacheAccountConfiguration -InputParameters $WebAppUrl + $cacheAccounts = Get-SPDscCacheAccountConfiguration -WebApplicationUrl $WebAppUrl if ($SetCacheAccountsPolicy) { if (($cacheAccounts.SuperUserAccount -eq "") -or ` @@ -944,18 +944,18 @@ function Get-SPDscCacheAccountConfiguration() [OutputType([System.Collections.Hashtable])] param ( [Parameter()] - [Object[]] - $InputParameters + [string] + $WebApplicationUrl ) $cacheAccounts = Invoke-SPDscCommand -Credential $InstallAccount ` - -Arguments @($InputParameters, $MyInvocation.MyCommand.Source) ` + -Arguments @($WebApplicationUrl, $MyInvocation.MyCommand.Source) ` -ScriptBlock { Write-Verbose -Message "Retrieving CacheAccounts" - $params = $args[0] + $webApplicationUrl = $args[0] $eventSource = $args[1] - $wa = Get-SPWebApplication -Identity $params -ErrorAction SilentlyContinue + $wa = Get-SPWebApplication -Identity $webApplicationUrl -ErrorAction SilentlyContinue if ($null -eq $wa) { diff --git a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 index c43b80b0a..f8f634ace 100644 --- a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 @@ -245,6 +245,10 @@ function Convert-SPDscHashtableToString { $str = "$($pair.Key)=$(Convert-SPDscCIMInstanceToString -CIMInstance $pair.Value)" } + elseif ($pair.Value -is [System.Management.Automation.PSCredential]) + { + $str = "$($pair.Key)=$($pair.Value.UserName)" + } else { $str = "$($pair.Key)=$($pair.Value)" @@ -1345,33 +1349,46 @@ function Test-SPDscIsADUser { [OutputType([System.Boolean])] [CmdletBinding()] - param ( - [Parameter()] + param + ( + [Parameter(Mandatory = $true)] [System.String] $IdentityName ) + $DomainNetbiosName = "" + if ($IdentityName -like "*\*") { + $DomainNetbiosName = $IdentityName.Split('\')[0] $IdentityName = $IdentityName.Substring($IdentityName.IndexOf('\') + 1) } - $searcher = New-Object -TypeName System.DirectoryServices.DirectorySearcher - $searcher.filter = "((samAccountName=$IdentityName))" - $searcher.SearchScope = "subtree" - $searcher.PropertiesToLoad.Add("objectClass") | Out-Null - $searcher.PropertiesToLoad.Add("objectCategory") | Out-Null - $searcher.PropertiesToLoad.Add("name") | Out-Null - $result = $searcher.FindOne() + $domainContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain", $DomainNetbiosName) + try + { + $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($domainContext) + $root = $domain.GetDirectoryEntry() + + $searcher = [System.DirectoryServices.DirectorySearcher]::new() + $searcher.filter = "((samAccountName=$IdentityName))" + $searcher.SearchScope = "subtree" + $searcher.SearchRoot = $root + + $searcher.PropertiesToLoad.Add("objectClass") | Out-Null + $searcher.PropertiesToLoad.Add("objectCategory") | Out-Null + $searcher.PropertiesToLoad.Add("name") | Out-Null + $result = $searcher.FindOne() + } + catch + { + return $false + } if ($null -eq $result) { - $message = "Unable to locate identity '$IdentityName' in the current domain." - Add-SPDscEvent -Message $message ` - -EntryType 'Error' ` - -EventID 100 ` - -Source $MyInvocation.MyCommand.Source - throw $message + Write-Host "Unable to locate identity '$IdentityName' in the current domain." + return $false } if ($result[0].Properties.objectclass -contains "user")