diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b7fad18..9105ba554 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ 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 + - Added support for trusted domains to Test-SPDscIsADUser helper function +- SPInstall + - Added documentation about a SharePoint 2019 installer issue ### Changed 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/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 index c43b80b0a..3931a37e5 100644 --- a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 @@ -1345,33 +1345,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")