diff --git a/CHANGELOG.md b/CHANGELOG.md index 76a88fe5a..4ee0f3f8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Change log for SharePointDsc +## v3.7 + +* SPConfigWizard + * Fixed issue with incorrect check for upgrade status of server +* SPDistributedCacheService + * Improved error message for inclusion of server name into ServerProvisionOrder + parameters when Present or change to Ensure Absent +* SPFarm + * Removed SingleServer as ServerRole, since this is an invalid role. + * Handle case where null or empty CentralAdministrationUrl is passed in + * Move CentralAdministrationPort validation into parameter definition + to work with ReverseDsc + * Add NotNullOrEmpty parameter validation to CentralAdministrationUrl + * Fixed error when changing developer dashboard display level. + * Add support for updating Central Admin Authentication Method +* SPFarmSolution + * Fix for Web Application scoped solutions. +* SPInstall + * Fixes a terminating error for sources in weird file shares + * Corrected issue with incorrectly detecting SharePoint after it + has been uninstalled + * Corrected issue with detecting a paused installation +* SPInstallLanguagePack + * Fixes a terminating error for sources in weird file shares +* SPInstallPrereqs + * Fixes a terminating error for sources in weird file shares +* SPProductUpdate + * Fixes a terminating error for sources in weird file shares + * Corrected incorrect farm detection, added in earlier bugfix +* SPSite + * Fixed issue with incorrectly updating site OwnerAlias and + SecondaryOwnerAlias +* SPWebAppAuthentication + * Fixes issue where Test method return false on NON-US OS. + ## v3.6 * SharePointDsc generic @@ -7,7 +42,7 @@ the current unit test file. * SPFarm * Moved check for CentralAdministrationUrl is HTTP to Set method, - to prevent issues with ReverseDsc. + to prevent issues with ReverseDsc * SPInstall * Updated error code checks to force reboot. * SPProductUpdate diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 index c106a3eb8..46ba66f3a 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 @@ -100,8 +100,9 @@ function Set-TargetResource Write-Verbose -Message "Checking if all servers in the farm have the binaries installed" $statusType = Get-SPDscServerPatchStatus - Write-Verbose -Message "Server status: $statusType (Has to be 'NoActionRequired' to continue)" - if ($statusType -ne "NoActionRequired") + Write-Verbose -Message ("Server status: $statusType (Has to be 'UpgradeAvailable' or " + ` + "'UpgradeRequired' to continue)") + if ($statusType -ne "UpgradeRequired" -and $statusType -ne "UpgradeAvailable") { Write-Verbose -Message "Upgrade not possible, not all servers have the same binaries installed" return diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 index a313f415f..b67368368 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 @@ -238,7 +238,8 @@ function Set-TargetResource if ($ServerCount -ge $params.ServerProvisionOrder.Length) { throw ("The server $($env:COMPUTERNAME) was not found in the " + ` - "array for distributed cache servers") + "ServerProvisionOrder array of Distributed Cache server(s). " + ` + "The server must be included in ServerProvisionOrder or Ensure equal to Absent.") } $currentServer = $params.ServerProvisionOrder[$serverCount] } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/Readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/Readme.md index 4825441ea..e768f6a95 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/Readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/Readme.md @@ -22,6 +22,8 @@ By doing this you can ensure that you do not create conflicts with two or more servers provisioning a cache at the same time. Note, this approach only makes a server check the others for distributed cache, it does not provision the cache automatically on all servers. If a previous server in the sequence does +not appear to be running distributed cache after 30 minutes, the local server +that was waiting will begin anyway. The default value for the Ensure parameter is Present. When not specifying this parameter, the distributed cache is provisioned. diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 index 5ccaa4683..6efd90351 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 @@ -27,7 +27,6 @@ $Script:ServiceAppObjectType = "Microsoft.Office.Excel.Server.MossHost.ExcelServ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( [Parameter(Mandatory = $true)] @@ -219,7 +218,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -475,7 +473,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 index e0d06610f..de4ed24b1 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 @@ -43,6 +43,7 @@ function Get-TargetResource $CentralAdministrationUrl, [Parameter()] + [ValidateRange(1, 65535)] [System.UInt32] $CentralAdministrationPort, @@ -58,7 +59,6 @@ function Get-TargetResource "Custom", "DistributedCache", "Search", - "SingleServer", "SingleServerFarm", "WebFrontEnd", "WebFrontEndWithDistributedCache")] @@ -69,7 +69,6 @@ function Get-TargetResource [System.String] $DeveloperDashboard, - [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount @@ -77,40 +76,9 @@ function Get-TargetResource Write-Verbose -Message "Getting the settings of the current local SharePoint Farm (if any)" - if ($PSBoundParameters.ContainsKey("CentralAdministrationPort")) - { - if ($CentralAdministrationPort -notin 1..65535) - { - throw ("An invalid value for CentralAdministrationPort is specified: " + ` - "$CentralAdministrationPort") - } - } - - if ($PSBoundParameters.ContainsKey("CentralAdministrationUrl")) - { - $uri = $CentralAdministrationUrl -as [System.Uri] - if ($null -eq $uri.AbsoluteUri) - { - Write-Verbose -Message ("CentralAdministrationUrl is not a valid URI. It should " + ` - "include the scheme (http/https) and address.") - } - if ($uri.scheme -ne 'https') - { - Write-Verbose -Message ("Currently, the CentralAdministrationUrl parameter can only " + ` - "be used with HTTPS. To provision CA on HTTP, omit the CentralAdministrationUrl " + ` - "parameter to provision CA on http://servername:port.") - } - if ($CentralAdministrationUrl -match ':\d+') - { - Write-Verbose -Message ("CentralAdministrationUrl should not specify port. Use " + ` - "CentralAdministrationPort instead.") - } - } - if ($Ensure -eq "Absent") { - throw ("SharePointDsc does not support removing a server from a farm, please set the " + ` - "ensure property to 'present'") + throw "SharePointDsc does not support removing a server from a farm, please set the ensure property to 'present'" } $installedVersion = Get-SPDscInstalledProductVersion @@ -124,15 +92,15 @@ function Get-TargetResource { if ($DeveloperDashboard -eq "OnDemand") { - throw ("The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint " + ` - "2016 and 2019") + throw "The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint 2016 and 2019" } if ($DeveloperDashboard -eq "On") { - Write-Verbose -Message ("Please make sure you also provision the Usage and Health " + ` - "service application to make sure the Developer Dashboard " + ` - "works properly") + $message = "Please make sure you also provision the Usage and Health " + + "service application to make sure the Developer Dashboard " + + "works properly" + Write-Verbose -Message $message } if ($installedVersion.ProductBuildPart.ToString().Length -eq 4) @@ -146,27 +114,27 @@ function Get-TargetResource } default { - throw ("Detected an unsupported major version of SharePoint. SharePointDsc only " + ` - "supports SharePoint 2013, 2016 or 2019.") + throw ("Detected an unsupported major version of SharePoint. SharePointDsc only " + + "supports SharePoint 2013, 2016 or 2019.") } } - if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) ` - -and $installedVersion.FileMajorPart -ne 16) + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and + $installedVersion.FileMajorPart -ne 16) { throw [Exception] "Server role is only supported in SharePoint 2016 and 2019." } - if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) ` - -and $installedVersion.FileMajorPart -eq 16 ` - -and $installedVersion.FileBuildPart -lt 4456 ` - -and ($ServerRole -eq "ApplicationWithSearch" ` - -or $ServerRole -eq "WebFrontEndWithDistributedCache")) + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and + $installedVersion.FileMajorPart -eq 16 -and + $installedVersion.FileBuildPart -lt 4456 -and + ($ServerRole -eq "ApplicationWithSearch" -or + $ServerRole -eq "WebFrontEndWithDistributedCache")) { - throw [Exception] ("ServerRole values of 'ApplicationWithSearch' or " + ` - "'WebFrontEndWithDistributedCache' require the SharePoint 2016 " + ` - "Feature Pack 1 to be installed. See " + ` - "https://support.microsoft.com/en-us/kb/3127940") + throw [Exception] ("ServerRole values of 'ApplicationWithSearch' or " + + "'WebFrontEndWithDistributedCache' require the SharePoint 2016 " + + "Feature Pack 1 to be installed. See " + + "https://support.microsoft.com/en-us/kb/3127940") } @@ -211,8 +179,8 @@ function Get-TargetResource $farmAccount = $spFarm.DefaultServiceAccount.Name } - $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration ` - | Where-Object -FilterScript { + $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration | + Where-Object -FilterScript { $_.IsAdministrationWebApplication -eq $true } @@ -221,9 +189,9 @@ function Get-TargetResource if ($null -ne $ca) { $ca = $ca | Where-Object -Filterscript { - $_.GetType().Name -eq "SPWebServiceInstance" -and ` - $_.Name -eq "WSS_Administration" -and ` - $_.Status -eq "Online" + $_.GetType().Name -eq "SPWebServiceInstance" -and + $_.Name -eq "WSS_Administration" -and + $_.Status -eq "Online" } } @@ -233,8 +201,8 @@ function Get-TargetResource } $centralAdminAuth = $null - if ($null -ne $centralAdminSite -and ` - $centralAdminSite.IisSettings[0].DisableKerberos -eq $false) + if ($null -ne $centralAdminSite -and + $centralAdminSite.IisSettings[0].DisableKerberos -eq $false) { $centralAdminAuth = "Kerberos" } @@ -287,11 +255,11 @@ function Get-TargetResource { # The node is currently connected to a farm but was unable to retrieve the values # of current farm settings, most likely due to connectivity issues with the SQL box - Write-Verbose -Message ("This server appears to be connected to a farm already, " + ` - "but the configuration database is currently unable to be " + ` - "accessed. Values returned from the get method will be " + ` - "incomplete, however the 'Ensure' property should be " + ` - "considered correct") + Write-Verbose -Message ("This server appears to be connected to a farm already, " + + "but the configuration database is currently unable to be " + + "accessed. Values returned from the get method will be " + + "incomplete, however the 'Ensure' property should be " + + "considered correct") return @{ IsSingleInstance = "Yes" FarmConfigDatabaseName = $null @@ -378,6 +346,7 @@ function Set-TargetResource $CentralAdministrationUrl, [Parameter()] + [ValidateRange(1, 65535)] [System.UInt32] $CentralAdministrationPort, @@ -393,7 +362,6 @@ function Set-TargetResource "Custom", "DistributedCache", "Search", - "SingleServer", "SingleServerFarm", "WebFrontEnd", "WebFrontEndWithDistributedCache")] @@ -414,25 +382,27 @@ function Set-TargetResource if ($Ensure -eq "Absent") { - throw ("SharePointDsc does not support removing a server from a farm, please set the " + ` - "ensure property to 'present'") + throw ("SharePointDsc does not support removing a server from a farm, please set the " + + "ensure property to 'present'") } if ($PSBoundParameters.ContainsKey("CentralAdministrationUrl")) { - $uri = $CentralAdministrationUrl -as [System.Uri] - if ($null -eq $uri.AbsoluteUri) + if ([string]::IsNullOrEmpty($CentralAdministrationUrl)) { - throw "CentralAdministrationUrl is not a valid URI. It should include the scheme (http/https) and address." + $PSBoundParameters.Remove('CentralAdministrationUrl') | Out-Null } - if ($uri.scheme -ne 'https') - { - throw "Currently, the CentralAdministrationUrl parameter can only be used with HTTPS. To provision CA on " + ` - "HTTP, omit the CentralAdministrationUrl parameter to provision CA on http://servername:port." - } - if ($CentralAdministrationUrl -match ':\d+') + else { - throw "CentralAdministrationUrl should not specify port. Use CentralAdministrationPort instead." + $uri = $CentralAdministrationUrl -as [System.Uri] + if ($null -eq $uri.AbsoluteUri -or $uri.scheme -notin ('http', 'https')) + { + throw "CentralAdministrationUrl is not a valid URI. It should include the scheme (http/https) and address." + } + if ($CentralAdministrationUrl -match ':\d+') + { + throw "CentralAdministrationUrl should not specify port. Use CentralAdministrationPort instead." + } } } @@ -441,21 +411,24 @@ function Set-TargetResource # Set default values to ensure they are passed to Invoke-SPDscCommand if (-not $PSBoundParameters.ContainsKey("CentralAdministrationPort")) { - # If CentralAdministrationUrl is specified and is SSL, let's infer the port from the Url - if ($PSBoundParameters.ContainsKey("CentralAdministrationUrl") -and ` - (New-Object -TypeName System.Uri $CentralAdministrationUrl).Scheme -eq 'https') + # If CentralAdministrationUrl is specified, let's infer the port from the Url + if ($PSBoundParameters.ContainsKey("CentralAdministrationUrl")) { - $PSBoundParameters.Add("CentralAdministrationPort", (New-Object -TypeName System.Uri $CentralAdministrationUrl).Port) + $CentralAdministrationPort = + $PSBoundParameters.CentralAdministrationPort = + (New-Object -TypeName System.Uri $CentralAdministrationUrl).Port } else { - $PSBoundParameters.Add("CentralAdministrationPort", 9999) + $CentralAdministrationPort = + $PSBoundParameters.CentralAdministrationPort = 9999 } } if (-not $PSBoundParameters.ContainsKey("CentralAdministrationAuth")) { - $PSBoundParameters.Add("CentralAdministrationAuth", "NTLM") + $CentralAdministrationAuth = + $PSBoundParameters.CentralAdministrationAuth = "NTLM" } if ($CurrentValues.Ensure -eq "Present") @@ -484,8 +457,8 @@ function Set-TargetResource if ($null -ne $serviceInstance) { $serviceInstance = $serviceInstance | Where-Object -FilterScript { - $_.GetType().Name -eq "SPWebServiceInstance" -and ` - $_.Name -eq "WSS_Administration" + $_.GetType().Name -eq "SPWebServiceInstance" -and + $_.Name -eq "WSS_Administration" } } @@ -509,8 +482,8 @@ function Set-TargetResource if ($null -ne $serviceInstance) { $serviceInstance = $serviceInstance | Where-Object -FilterScript { - $_.GetType().Name -eq "SPWebServiceInstance" -and ` - $_.Name -eq "WSS_Administration" + $_.GetType().Name -eq "SPWebServiceInstance" -and + $_.Name -eq "WSS_Administration" } } @@ -525,24 +498,29 @@ function Set-TargetResource if ($RunCentralAdmin) { - # For the following SSL scenarios, we should remove the CA web application and recreate it - # CentralAdministrationUrl is HTTPS - # AND Current CentralAdministrationUrl is not equal to new CentralAdministrationUrl - # OR Current SecureBindings does not exist or doesn't match desired url and port - if ($PSBoundParameters.ContainsKey("CentralAdministrationUrl") -and ` - ([System.Uri]$CentralAdministrationUrl).Scheme -eq 'https') + # track whether or not we end up reprovisioning CA + $reprovisionCentralAdmin = $false + + if ($PSBoundParameters.ContainsKey("CentralAdministrationUrl")) { - Write-Verbose -Message "Updating CentralAdmin port to HTTPS" + # For the following scenarios, we should remove the CA web application and recreate it + # CentralAdministrationUrl is passed in + # AND Current CentralAdministrationUrl is not equal to new CentralAdministrationUrl + # OR Current SecureBindings (HTTPS) or ServerBindings (HTTP) does not exist or doesn't + # match desired url and port + + Write-Verbose -Message "Updating Central Admin URL configuration" Invoke-SPDscCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] - $reprovisionCentralAdmin = $false $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration | Where-Object -FilterScript { $_.IsAdministrationWebApplication } + $isCentralAdminUrlHttps = (([System.Uri]$params.CentralAdministrationUrl).Scheme -eq 'https') + $desiredUri = [System.Uri]("{0}:{1}" -f $params.CentralAdministrationUrl.TrimEnd('/'), $params.CentralAdministrationPort) $currentUri = [System.Uri]$centralAdminSite.Url if ($desiredUri.AbsoluteUri -ne $currentUri.AbsoluteUri) @@ -552,24 +530,35 @@ function Set-TargetResource } else { - # check securebindings + # check securebindings (https) or serverbindings (http) # there should be an entry in the SecureBindings object of the # SPWebApplication's IisSettings for the default zone - $secureBindings = $centralAdminSite.GetIisSettingsWithFallback("Default").SecureBindings - if ($null -ne $secureBindings[0] -and (-not [string]::IsNullOrEmpty($secureBindings[0].HostHeader))) + $iisBindings = $null + if ($isCentralAdminUrlHttps) + { + Write-Verbose -Message "Getting current secure bindings..." + $iisBindings = $centralAdminSite.GetIisSettingsWithFallback("Default").SecureBindings + } + else { - # check to see if secureBindings host header and port match what we want them to be - if ($desiredUri.Host -ne $secureBindings[0].HostHeader -or ` - $desiredUri.Port -ne $secureBindings[0].Port) + Write-Verbose -Message "Getting current server bindings..." + $iisBindings = $centralAdminSite.GetIisSettingsWithFallback("Default").ServerBindings + } + + if ($null -ne $iisBindings[0] -and (-not [string]::IsNullOrEmpty($iisBindings[0].HostHeader))) + { + # check to see if iisBindings host header and port match what we want them to be + 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 $($secureBindings[0].HostHeader) or $($desiredUri.Port) does not equal $($secureBindings[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 { - # secureBindings did not exist or did not contain a valid hostheader - Write-Verbose -Message "Re-provisioning CA because secureBindings does not exist or does not contain a valid host header" + # 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" $reprovisionCentralAdmin = $true } } @@ -579,7 +568,7 @@ function Set-TargetResource # Write-Verbose -Message "Removing Central Admin web application in order to reprovision it" Remove-SPWebApplication -Identity $centralAdminSite.Url -Zone Default -DeleteIisSite - Write-Verbose -Message "Re-provisioning Central Admin web application with SSL" + Write-Verbose -Message "Re-provisioning Central Admin web application" $webAppParams = @{ Identity = $centralAdminSite.Url Name = "SharePoint Central Administration v4" @@ -587,7 +576,7 @@ function Set-TargetResource HostHeader = $desiredUri.Host Port = $desiredUri.Port AuthenticationMethod = $params.CentralAdministrationAuth - SecureSocketsLayer = $true + SecureSocketsLayer = $isCentralAdminUrlHttps } New-SPWebApplicationExtension @webAppParams } @@ -601,10 +590,27 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - Write-Verbose -Message "Updating Central Admin port" Set-SPCentralAdministration -Port $params.CentralAdministrationPort } } + + # if Authentication Method doesn't match and we haven't reprovisioned CA above, update auth method + if ($CurrentValues.CentralAdministrationAuth -ne $CentralAdministrationAuth -and + (-not $reprovisionCentralAdmin)) + { + Write-Verbose -Message "Updating CentralAdmin authentication method from $($CurrentValues.CentralAdministrationAuth) to $CentralAdministrationAuth" + Invoke-SPDscCommand -Credential $InstallAccount ` + -Arguments $PSBoundParameters ` + -ScriptBlock { + $params = $args[0] + + $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration | Where-Object -FilterScript { + $_.IsAdministrationWebApplication + } + + $centralAdminSite | Set-SPWebApplication -Zone "Default" -AuthenticationMethod $params.CentralAdministrationAuth + } + } } if ($CurrentValues.DeveloperDashboard -ne $DeveloperDashboard) @@ -618,7 +624,7 @@ function Set-TargetResource Write-Verbose -Message "Updating Developer Dashboard setting" $admService = Get-SPDscContentService $developerDashboardSettings = $admService.DeveloperDashboardSettings - $developerDashboardSettings.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::$params.DeveloperDashboard + $developerDashboardSettings.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::$($params.DeveloperDashboard) $developerDashboardSettings.Update() } } @@ -638,7 +644,7 @@ function Set-TargetResource $modulePath = "..\..\Modules\SharePointDsc.Farm\SPFarm.psm1" Import-Module -Name (Join-Path -Path $scriptRoot -ChildPath $modulePath -Resolve) - $sqlInstanceStatus = Get-SPDscSQLInstanceStatus -SQLServer $params.DatabaseServer ` + $sqlInstanceStatus = Get-SPDscSQLInstanceStatus -SQLServer $params.DatabaseServer if ($sqlInstanceStatus.MaxDOPCorrect -ne $true) { @@ -650,9 +656,9 @@ function Set-TargetResource while ($dbStatus.Locked -eq $true) { - Write-Verbose -Message ("[$([DateTime]::Now.ToShortTimeString())] The configuration " + ` - "database is currently being provisioned by a remote " + ` - "server, this server will wait for this to complete") + Write-Verbose -Message ("[$([DateTime]::Now.ToShortTimeString())] The configuration " + + "database is currently being provisioned by a remote " + + "server, this server will wait for this to complete") Start-Sleep -Seconds 30 $dbStatus = Get-SPDscConfigDBStatus -SQLServer $params.DatabaseServer ` -Database $params.FarmConfigDatabaseName @@ -683,13 +689,13 @@ function Set-TargetResource { if ($installedVersion.ProductBuildPart.ToString().Length -eq 4) { - Write-Verbose -Message ("Detected Version: SharePoint 2016 - " + ` - "configuring server as $($params.ServerRole)") + Write-Verbose -Message ("Detected Version: SharePoint 2016 - " + + "configuring server as $($params.ServerRole)") } else { - Write-Verbose -Message ("Detected Version: SharePoint 2019 - " + ` - "configuring server as $($params.ServerRole)") + Write-Verbose -Message ("Detected Version: SharePoint 2019 - " + + "configuring server as $($params.ServerRole)") } $executeArgs.Add("LocalServerRole", $params.ServerRole) } @@ -697,50 +703,50 @@ function Set-TargetResource { if ($installedVersion.ProductBuildPart.ToString().Length -eq 4) { - Write-Verbose -Message ("Detected Version: SharePoint 2016 - no server " + ` - "role provided, configuring server without a " + ` - "specific role") + Write-Verbose -Message ("Detected Version: SharePoint 2016 - no server " + + "role provided, configuring server without a " + + "specific role") } else { - Write-Verbose -Message ("Detected Version: SharePoint 2019 - no server " + ` - "role provided, configuring server without a " + ` - "specific role") + Write-Verbose -Message ("Detected Version: SharePoint 2019 - no server " + + "role provided, configuring server without a " + + "specific role") } $executeArgs.Add("ServerRoleOptional", $true) } } Default { - throw [Exception] ("An unknown version of SharePoint (Major version $_) " + ` - "was detected. Only versions 15 (SharePoint 2013) and" + ` - "16 (SharePoint 2016 or SharePoint 2019) are supported.") + throw [Exception] ("An unknown version of SharePoint (Major version $_) " + + "was detected. Only versions 15 (SharePoint 2013) and" + + "16 (SharePoint 2016 or SharePoint 2019) are supported.") } } if ($dbStatus.DatabaseExists -eq $true) { - Write-Verbose -Message ("The SharePoint config database " + ` - "'$($params.FarmConfigDatabaseName)' already exists, so " + ` - "this server will join the farm.") + Write-Verbose -Message ("The SharePoint config database " + + "'$($params.FarmConfigDatabaseName)' already exists, so " + + "this server will join the farm.") $createFarm = $false } elseif ($dbStatus.DatabaseExists -eq $false -and $params.RunCentralAdmin -eq $false) { # Only allow the farm to be created by a server that will run central admin # to avoid a ghost CA site appearing on this server and causing issues - Write-Verbose -Message ("The SharePoint config database " + ` - "'$($params.FarmConfigDatabaseName)' does not exist, but " + ` - "this server will not be running the central admin " + ` - "website, so it will wait to join the farm rather than " + ` - "create one.") + Write-Verbose -Message ("The SharePoint config database " + + "'$($params.FarmConfigDatabaseName)' does not exist, but " + + "this server will not be running the central admin " + + "website, so it will wait to join the farm rather than " + + "create one.") $createFarm = $false } else { - Write-Verbose -Message ("The SharePoint config database " + ` - "'$($params.FarmConfigDatabaseName)' does not exist, so " + ` - "this server will create the farm.") + Write-Verbose -Message ("The SharePoint config database " + + "'$($params.FarmConfigDatabaseName)' does not exist, so " + + "this server will create the farm.") $createFarm = $true } @@ -752,9 +758,9 @@ function Set-TargetResource $loopCount = 0 while ($dbStatus.DatabaseExists -eq $false -and $loopCount -lt 15) { - Write-Verbose -Message ("The configuration database is not yet provisioned " + ` - "by a remote server, this server will wait for up to " + ` - "15 minutes for this to complete") + Write-Verbose -Message ("The configuration database is not yet provisioned " + + "by a remote server, this server will wait for up to " + + "15 minutes for this to complete") Start-Sleep -Seconds 60 $loopCount++ $dbStatus = Get-SPDscConfigDBStatus -SQLServer $params.DatabaseServer ` @@ -770,8 +776,8 @@ function Set-TargetResource $executeArgs.Remove("ServerRoleOptional") } - Write-Verbose -Message ("The server will attempt to join the farm now once every " + ` - "60 seconds for the next 15 minutes.") + Write-Verbose -Message ("The server will attempt to join the farm now once every " + + "60 seconds for the next 15 minutes.") $loopCount = 0 $connectedToFarm = $false $lastException = $null @@ -785,12 +791,12 @@ function Set-TargetResource catch { $lastException = $_.Exception - Write-Verbose -Message ("$([DateTime]::Now.ToShortTimeString()) - An error " + ` - "occured joining config database " + ` - "'$($params.FarmConfigDatabaseName)' on " + ` - "'$($params.DatabaseServer)'. This resource will " + ` - "wait and retry automatically for up to 15 minutes. " + ` - "(waited $loopCount of 15 minutes)") + Write-Verbose -Message ("$([DateTime]::Now.ToShortTimeString()) - An error " + + "occured joining config database " + + "'$($params.FarmConfigDatabaseName)' on " + + "'$($params.DatabaseServer)'. This resource will " + + "wait and retry automatically for up to 15 minutes. " + + "(waited $loopCount of 15 minutes)") $loopCount++ Start-Sleep -Seconds 60 } @@ -807,8 +813,7 @@ function Set-TargetResource { Write-Verbose -Message "The database does not exist, so create a new farm" - Write-Verbose -Message ("Creating Lock database to prevent two servers creating " + ` - "the same farm") + Write-Verbose -Message "Creating Lock database to prevent two servers creating the same farm" Add-SPDscConfigDBLock -SQLServer $params.DatabaseServer ` -Database $params.FarmConfigDatabaseName @@ -849,8 +854,7 @@ function Set-TargetResource if ($params.RunCentralAdmin -eq $true) { Write-Verbose -Message "RunCentralAdmin is True, provisioning Central Admin" - $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration ` - | Where-Object -FilterScript { + $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration | Where-Object -FilterScript { $_.IsAdministrationWebApplication -eq $true } @@ -865,34 +869,55 @@ function Set-TargetResource New-SPCentralAdministration -Port $params.CentralAdministrationPort ` -WindowsAuthProvider $params.CentralAdministrationAuth - # if central admin is to be SSL, let's remove and re-provision - if (-not [string]::IsNullOrEmpty($params.CentralAdministrationUrl) -and ` - ([System.Uri]$params.CentralAdministrationUrl).Scheme -eq 'https') + if (-not [string]::IsNullOrEmpty($params.CentralAdministrationUrl)) { - Write-Verbose -Message "Removing Central Admin to properly provision as SSL" - - $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration ` - | Where-Object -FilterScript { + $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration | Where-Object -FilterScript { $_.IsAdministrationWebApplication -eq $true } - # Wondering if -DeleteIisSite is necessary. Does this add more risk of ending up in - # a state without CA or a way to recover it? - Remove-SPWebApplication -Identity $centralAdminSite.Url -Zone Default -DeleteIisSite + # cases where we need to reprovision CA: + # 1. desired Url is https + # 2. desired Url/port does not match current Url/port + # 3. IIS bindings don't match (shouldn't need this because case #2 should catch it in this case) + $reprovisionCentralAdmin = $false + $isCentralAdminUrlHttps = (([System.Uri]$params.CentralAdministrationUrl).Scheme -eq 'https') - Write-Verbose -Message "Reprovisioning Central Admin with SSL" + $desiredUri = [System.Uri]("{0}:{1}" -f $params.CentralAdministrationUrl.TrimEnd('/'), $params.CentralAdministrationPort) + $currentUri = [System.Uri]$centralAdminSite.Url - $webAppParams = @{ - Identity = $centralAdminSite.Url - Name = "SharePoint Central Administration v4" - Zone = "Default" - HostHeader = ([System.Uri]$params.CentralAdministrationUrl).Host - Port = $params.CentralAdministrationPort - AuthenticationMethod = $params.CentralAdministrationAuth - SecureSocketsLayer = $true + if ($isCentralAdminUrlHttps) + { + Write-Verbose -Message "Re-provisioning newly created CA because we want it to be HTTPS" + $reprovisionCentralAdmin = $true + } + elseif ($desiredUri.AbsoluteUri -ne $currentUri.AbsoluteUri) + { + Write-Verbose -Message "Re-provisioning CA because $($currentUri.AbsoluteUri) does not equal $($desiredUri.AbsoluteUri)" + $reprovisionCentralAdmin = $true } - New-SPWebApplicationExtension @webAppParams + if ($reprovisionCentralAdmin) + { + Write-Verbose -Message "Removing Central Admin web application" + + # Wondering if -DeleteIisSite is necessary. Does this add more risk of ending up in + # a state without CA or a way to recover it? + Remove-SPWebApplication -Identity $centralAdminSite.Url -Zone Default -DeleteIisSite + + Write-Verbose -Message "Reprovisioning Central Admin with SSL" + + $webAppParams = @{ + Identity = $centralAdminSite.Url + Name = "SharePoint Central Administration v4" + Zone = "Default" + HostHeader = $desiredUri.Host + Port = $desiredUri.Port + AuthenticationMethod = $params.CentralAdministrationAuth + SecureSocketsLayer = $isCentralAdminUrlHttps + } + + New-SPWebApplicationExtension @webAppParams + } } } else @@ -908,8 +933,8 @@ function Set-TargetResource if ($null -ne $serviceInstance) { $serviceInstance = $serviceInstance | Where-Object -FilterScript { - $_.GetType().Name -eq "SPWebServiceInstance" -and ` - $_.Name -eq "WSS_Administration" + $_.GetType().Name -eq "SPWebServiceInstance" -and + $_.Name -eq "WSS_Administration" } } @@ -941,11 +966,11 @@ function Set-TargetResource Write-Verbose -Message "Starting timer service" Start-Service -Name sptimerv4 - Write-Verbose -Message ("Pausing for 5 minutes to allow the timer service to " + ` - "fully provision the server") + Write-Verbose -Message ("Pausing for 5 minutes to allow the timer service to " + + "fully provision the server") Start-Sleep -Seconds 300 - Write-Verbose -Message ("Join farm complete. Restarting computer to allow " + ` - "configuration to continue") + Write-Verbose -Message ("Join farm complete. Restarting computer to allow " + + "configuration to continue") $global:DSCMachineStatus = 1 } @@ -997,6 +1022,7 @@ function Test-TargetResource $CentralAdministrationUrl, [Parameter()] + [ValidateRange(1, 65535)] [System.UInt32] $CentralAdministrationPort, @@ -1012,7 +1038,6 @@ function Test-TargetResource "Custom", "DistributedCache", "Search", - "SingleServer", "SingleServerFarm", "WebFrontEnd", "WebFrontEndWithDistributedCache")] @@ -1023,7 +1048,6 @@ function Test-TargetResource [System.String] $DeveloperDashboard, - [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount @@ -1033,6 +1057,30 @@ function Test-TargetResource $PSBoundParameters.Ensure = $Ensure + if ($PSBoundParameters.ContainsKey("CentralAdministrationUrl")) + { + if ([string]::IsNullOrEmpty($CentralAdministrationUrl)) + { + $PSBoundParameters.Remove('CentralAdministrationUrl') | Out-Null + } + else + { + $uri = $CentralAdministrationUrl -as [System.Uri] + if ($null -eq $uri.AbsoluteUri) + { + throw ("CentralAdministrationUrl is not a valid URI. It should " + + "include the scheme (http/https) and address.") + } + # TODO: should we allow port here as long as either the port matches CentralAdministrationPort + # or CentralAdministrationPort is not specified? + if ($CentralAdministrationUrl -match ':\d+') + { + throw ("CentralAdministrationUrl should not specify port. Use " + + "CentralAdministrationPort instead.") + } + } + } + $CurrentValues = Get-TargetResource @PSBoundParameters Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" @@ -1044,6 +1092,7 @@ function Test-TargetResource "RunCentralAdmin", "CentralAdministrationUrl", "CentralAdministrationPort", + "CentralAdministrationAuth", "DeveloperDashboard") } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof index bd5358d82..64ecbac24 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof @@ -9,10 +9,10 @@ class MSFT_SPFarm : OMI_BaseResource [Required, Description("The passphrase to use to allow servers to join this farm"), EmbeddedInstance("MSFT_Credential")] String Passphrase; [Required, Description("The name of the admin content database")] String AdminContentDatabaseName; [Required, Description("Should the central admin site run on this specific server?")] Boolean RunCentralAdmin; - [Write, Description("Vanity URL for Central Administration (currently HTTPS only). For HTTP vanity host, use SPAlternateHost.")] String CentralAdministrationUrl; + [Write, Description("Vanity URL for Central Administration")] String CentralAdministrationUrl; [Write, Description("What port will Central Admin be provisioned to - default is 9999")] Uint32 CentralAdministrationPort; [Write, Description("The authentication provider of the CentralAdministration web application"), ValueMap{"NTLM","Kerberos"}, Values{"NTLM","Kerberos"}] String CentralAdministrationAuth; - [Write, Description("SharePoint 2016 & 2019 only - the MinRole role to enroll this server as"), ValueMap{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}, Values{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}] String ServerRole; + [Write, Description("SharePoint 2016 & 2019 only - the MinRole role to enroll this server as"), ValueMap{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}, Values{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}] String ServerRole; [Write, Description("Specifies the state of the Developer Dashboard ('OnDemand' is SP2013 only)"), ValueMap{"Off","On","OnDemand"}, Values{"Off","On","OnDemand"}] String DeveloperDashboard; [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md index 4409aaf9a..a392ac4e7 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md @@ -36,11 +36,10 @@ CentralAdministrationAuth can be specified as "NTLM" or "KERBEROS". If not specified, it defaults to NTLM. If using Kerberos, make sure to have appropriate SPNs setup for Farm account and Central Administration URI. -To provision Central Admin as an SSL web application, specify a value for -the CentralAdministrationUrl property that begins with https:// followed -by the vanity host name or server name you wish to use to access CA. -(e.g. https://admin.sharepoint.contoso.com). This parameter does not -currently support HTTP. +To provision Central Admin on a vanity URL instead of the default +http(s)://servername:port, use the CentralAdministrationUrl parameter. +Central Admin will be provisioned as an SSL web application if this URL +begins with HTTPS, and will default to port 443. DeveloperDashboard can be specified as "On", "Off" and (only when using SharePoint 2013) to "OnDemand". diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 index 3a55fe65a..3512eeeff 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 @@ -57,26 +57,26 @@ function Get-TargetResource $version = $Solution.Properties["Version"] $deployedWebApplications = @($solution.DeployedWebApplications ` | Select-Object -ExpandProperty Url) - } - else - { - $currentState = "Absent" - $deployed = $false - $version = "0.0.0.0" - $deployedWebApplications = @() - } + } + else + { + $currentState = "Absent" + $deployed = $false + $version = "0.0.0.0" + $deployedWebApplications = @() + } - return @{ - Name = $params.Name - LiteralPath = $LiteralPath - Deployed = $deployed - Ensure = $currentState - Version = $version - WebAppUrls = $deployedWebApplications - SolutionLevel = $params.SolutionLevel - } + return @{ + Name = $params.Name + LiteralPath = $LiteralPath + Deployed = $deployed + Ensure = $currentState + Version = $version + WebAppUrls = $deployedWebApplications + SolutionLevel = $params.SolutionLevel } - return $result +} +return $result } function Set-TargetResource @@ -247,7 +247,7 @@ function Set-TargetResource if ($solution.ContainsWebApplicationResource) { - if ($null -eq $webApps -or $webApps.Length -eq 0) + if ($null -eq $params.WebAppUrls -or $params.WebAppUrls.Length -eq 0) { $runParams.Add("AllWebApplications", $true) @@ -255,7 +255,7 @@ function Set-TargetResource } else { - foreach ($webApp in $webApps) + foreach ($webApp in $params.WebAppUrls) { $runParams["WebApplication"] = $webApp @@ -296,7 +296,7 @@ function Set-TargetResource } else { - if ($null -eq $webApps -or $webApps.Length -eq 0) + if ($null -eq $params.WebAppUrls -or $params.WebAppUrls.Length -eq 0) { $runParams.Add("AllWebApplications", $true) @@ -304,11 +304,35 @@ function Set-TargetResource } else { - foreach ($webApp in $webApps) + foreach ($webApp in $params.WebAppUrls) { $runParams["WebApplication"] = $webApp - Install-SPSolution @runParams + try + { + Write-Verbose "Installing solution in Web Application $webApp" + Install-SPSolution @runParams -ErrorAction Stop + } + catch + { + # There may be an ongoing deployment to another web application location. + # Try the exponential backoff approach. + $backOff = 2 + while ($backOff -le 256) + { + try + { + Write-Verbose "There is an active deployment ongoing. Waiting $backOff seconds." + Start-Sleep -Seconds $backOff + Install-SPSolution @runParams -ErrorAction Stop + break + } + catch + { + $backOff = $backOff * 2 + } + } + } } } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 index 4b3cc6cce..576f94fb7 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 @@ -74,7 +74,14 @@ function Get-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { throw ("Setup file is blocked! Please use 'Unblock-File -Path $InstallerPath' " + ` @@ -90,9 +97,9 @@ function Get-TargetResource $installedItemsX64 = Get-ItemProperty -Path $x64Path | Select-Object -Property DisplayName $installedItems = $installedItemsX86 + $installedItemsX64 - $installedItems = $installedItems | Select-Object -Property DisplayName -Unique + $installedItems = $installedItems.DisplayName | Select-Object -Unique $spInstall = $installedItems | Where-Object -FilterScript { - $_ -match "Microsoft SharePoint Server (2013|2016|2019)" + $_ -match "^Microsoft SharePoint Server (2013|2016|2019)$" } if ($spInstall) @@ -245,7 +252,14 @@ function Set-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { throw ("Setup file is blocked! Please use 'Unblock-File -Path $InstallerPath' " + ` diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 index abe869c3a..c6f44785c 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 @@ -71,7 +71,14 @@ function Get-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $setupExe -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $setupExe -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { throw ("Setup file is blocked! Please use 'Unblock-File -Path $setupExe' " + ` @@ -311,7 +318,14 @@ function Set-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $setupExe -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $setupExe -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { throw ("Setup file is blocked! Please use 'Unblock-File -Path $setupExe' " + ` diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 index 85b083db8..ddb3e513c 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 @@ -231,7 +231,14 @@ function Get-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { throw ("PrerequisitesInstaller is blocked! Please use 'Unblock-File -Path " + ` @@ -639,7 +646,14 @@ function Set-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $InstallerPath -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { throw ("PrerequisitesInstaller is blocked! Please use 'Unblock-File -Path " + ` diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 index 16706a883..0077ee109 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -163,7 +162,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -264,7 +262,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 index b2eae99af..98046b822 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 @@ -78,7 +78,14 @@ function Get-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $SetupFile -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $SetupFile -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { @@ -306,7 +313,14 @@ function Set-TargetResource if ($checkBlockedFile -eq $true) { Write-Verbose -Message "Checking status now" - $zone = Get-Item -Path $SetupFile -Stream "Zone.Identifier" -EA SilentlyContinue + try + { + $zone = Get-Item -Path $SetupFile -Stream "Zone.Identifier" -EA SilentlyContinue + } + catch + { + Write-Verbose -Message 'Encountered error while reading file stream. Ignoring file stream.' + } if ($null -ne $zone) { @@ -395,12 +409,15 @@ function Set-TargetResource $farmIsAvailable = Invoke-SPDscCommand -Credential $InstallAccount ` -ScriptBlock { - $farm = Get-SPFarm -ErrorAction SilentlyContinue - if ($null -eq $farm) + try + { + $null = Get-SPFarm + return $true + } + catch { return $false } - return $true } if ($ShutdownServices -and $farmIsAvailable) diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 index ff8e0a054..e76a7dae0 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -225,7 +224,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -702,7 +700,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 index 59b11792d..1f4cda1e4 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -202,7 +201,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -489,7 +487,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 index b95ef6e07..250873526 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -162,7 +161,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -727,7 +725,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 index bcaf288de..ede770f71 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 @@ -312,19 +312,37 @@ function Set-TargetResource } } - if ($params.ContainsKey("OwnerAlias") -eq $true) + $centralAdminWebApp = [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local + $centralAdminSite = Get-SPSite -Identity $centralAdminWebApp.Url + $systemAccountSite = New-Object "Microsoft.SharePoint.SPSite" -ArgumentList @($site.Id, $centralAdminSite.SystemAccount.UserToken) + + if ($params.OwnerAlias -ne $CurrentValues.OwnerAlias) { - if ($params.OwnerAlias -ne $CurrentValues.OwnerAlias) + Write-Verbose -Message "Updating owner to $($params.OwnerAlias)" + try { - $newParams.OwnerAlias = $params.OwnerAlias + $confirmedUsername = $systemAccountSite.RootWeb.EnsureUser($params.OwnerAlias) + $systemAccountSite.Owner = $confirmedUsername + } + catch + { + Write-Output "Cannot resolve user $($params.OwnerAlias) as OwnerAlias" } } - if ($params.ContainsKey("SecondaryOwnerAlias") -eq $true) + if ($params.ContainsKey("SecondaryOwnerAlias") -eq $true -and ` + $params.SecondaryOwnerAlias -ne $CurrentValues.SecondaryOwnerAlias) { - if ($params.SecondaryOwnerAlias -ne $CurrentValues.SecondaryOwnerAlias) + Write-Verbose -Message "Updating secondary owner to $($params.SecondaryOwnerAlias)" + try + { + $confirmedUsername = $systemAccountSite.RootWeb.EnsureUser($params.SecondaryOwnerAlias) + $systemAccountSite.SecondaryContact = $confirmedUsername + } + catch { - $newParams.SecondaryOwnerAlias = $params.SecondaryOwnerAlias + Write-Verbose -Message ("Cannot resolve user $($params.SecondaryOwnerAlias) " + ` + "as SecondaryOwnerAlias") } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 index 5dcbff618..65f5d6b5e 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -123,7 +122,6 @@ function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -360,7 +358,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 index beaa2982b..8d2971eb2 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -125,7 +124,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -187,7 +185,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 index 77b3e6264..308b946ed 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -291,7 +290,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -679,7 +677,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 index 564c64b01..7f792ff5c 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -169,7 +168,7 @@ function Get-TargetResource $roleProvider = $null $membershipProvider = $null - if ($authProvider.DisplayName -eq "Windows Authentication") + if ($authProvider.ClaimProviderName -eq 'AD') { if ($authProvider.DisableKerberos -eq $true) { @@ -180,7 +179,7 @@ function Get-TargetResource $localAuthMode = "Kerberos" } } - elseif ($authProvider.DisplayName -eq "Forms Authentication") + elseif ($authProvider.ClaimProviderName -eq 'Forms') { $localAuthMode = "FBA" $roleProvider = $authProvider.RoleProvider @@ -235,7 +234,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -453,7 +451,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 index d09f79370..0a8a95b43 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -144,7 +143,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -403,7 +401,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 index 96085314a..524b3955d 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -82,7 +81,6 @@ function Set-TargetResource { [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "Ignoring this because the used AccessAccount does not use SecureString to handle the password")] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -233,7 +231,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 index 105459fd7..c9178a08a 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 @@ -1,7 +1,6 @@ function Get-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Collections.Hashtable])] param ( @@ -199,7 +198,6 @@ function Get-TargetResource function Set-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] param ( [Parameter(Mandatory = $true)] @@ -606,7 +604,6 @@ function Set-TargetResource function Test-TargetResource { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSDSCUseIdenticalMandatoryParametersForDSC", "", Justification = "Temporary workaround for issue introduced in PSSA v1.18")] [OutputType([System.Boolean])] param ( diff --git a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 index e1af11de4..54752411d 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 @@ -3,7 +3,9 @@ This example applies the distributed cache service to both "server1" and "server2". The ServerProvisionOrder will ensure that it applies it to server1 first and then server2, making sure they don't both attempt to - create the cache at the same time, resuling in errors. + create the cache at the same time, resuling in errors. A third server + "server3", which is not included within ServerProvisionOrder, is + configured as Absent. Note: Do not allow plain text passwords in production environments. #> @@ -17,6 +19,10 @@ @{ NodeName = 'Server2' PSDscAllowPlainTextPassword = $true + }, + @{ + NodeName = 'Server3' + PSDscAllowPlainTextPassword = $true } ) } @@ -55,4 +61,18 @@ PsDscRunAsCredential = $SetupAccount } } + + node "Server3" + { + SPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + CacheSizeInMB = 8192 + ServiceAccount = "DEMO\ServiceAccount" + ServerProvisionOrder = @("Server1","Server2") + CreateFirewallRules = $true + Ensure = 'Absent' + PsDscRunAsCredential = $SetupAccount + } + } } diff --git a/Modules/SharePointDsc/SharePointDsc.psd1 b/Modules/SharePointDsc/SharePointDsc.psd1 index ff86cd87a..a36cf9f39 100644 --- a/Modules/SharePointDsc/SharePointDsc.psd1 +++ b/Modules/SharePointDsc/SharePointDsc.psd1 @@ -8,144 +8,160 @@ @{ - # Script module or binary module file associated with this manifest. - # RootModule = '' + # Script module or binary module file associated with this manifest. + # RootModule = '' - # Version number of this module. - ModuleVersion = '3.6.0.0' + # Version number of this module. + ModuleVersion = '3.7.0.0' - # ID used to uniquely identify this module - GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90' + # ID used to uniquely identify this module + GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90' - # Author of this module - Author = 'Microsoft Corporation' + # Author of this module + Author = 'Microsoft Corporation' - # Company or vendor of this module - CompanyName = 'Microsoft Corporation' + # Company or vendor of this module + CompanyName = 'Microsoft Corporation' - # Copyright statement for this module - Copyright = '(c) 2015-2018 Microsoft Corporation. All rights reserved.' + # Copyright statement for this module + Copyright = '(c) 2015-2018 Microsoft Corporation. All rights reserved.' - # Description of the functionality provided by this module - Description = 'This DSC module is used to deploy and configure SharePoint Server 2013, 2016 and 2019, and covers a wide range of areas including web apps, service apps and farm configuration.' + # Description of the functionality provided by this module + Description = 'This DSC module is used to deploy and configure SharePoint Server 2013, 2016 and 2019, and covers a wide range of areas including web apps, service apps and farm configuration.' - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '4.0' + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '4.0' - # Name of the Windows PowerShell host required by this module - # PowerShellHostName = '' + # Name of the Windows PowerShell host required by this module + # PowerShellHostName = '' - # Minimum version of the Windows PowerShell host required by this module - # PowerShellHostVersion = '' + # Minimum version of the Windows PowerShell host required by this module + # PowerShellHostVersion = '' - # Minimum version of Microsoft .NET Framework required by this module - # DotNetFrameworkVersion = '' + # Minimum version of Microsoft .NET Framework required by this module + # DotNetFrameworkVersion = '' - # Minimum version of the common language runtime (CLR) required by this module - # CLRVersion = '' + # Minimum version of the common language runtime (CLR) required by this module + # CLRVersion = '' - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' - # Modules that must be imported into the global environment prior to importing this module - # RequiredModules = @() + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() - # Assemblies that must be loaded prior to importing this module - # RequiredAssemblies = @() + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() - # Type files (.ps1xml) to be loaded when importing this module - # TypesToProcess = @() + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() - # Format files (.ps1xml) to be loaded when importing this module - # FormatsToProcess = @() + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - NestedModules = @("modules\SharePointDsc.Util\SharePointDsc.Util.psm1") + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + NestedModules = @("modules\SharePointDsc.Util\SharePointDsc.Util.psm1") - # Functions to export from this module - #FunctionsToExport = '*' + # Functions to export from this module + #FunctionsToExport = '*' - # Cmdlets to export from this module - CmdletsToExport = @("Invoke-SPDscCommand", - "Get-SPDscInstalledProductVersion", - "Get-SPDscContentService", - "Rename-SPDscParamValue", - "Add-SPDscUserToLocalAdmin", - "Remove-SPDscUserToLocalAdmin", - "Test-SPDscObjectHasProperty", - "Test-SPDscRunAsCredential", - "Test-SPDscUserIsLocalAdmin", - "Test-SPDscParameterState", - "Test-SPDscIsADUser", - "Test-SPDscRunningAsFarmAccount", - "Set-SPDscObjectPropertyIfValuePresent", - "Get-SPDscUserProfileSubTypeManager", - "Get-SPDscOSVersion", - "Get-SPDscRegistryKey", - "Resolve-SPDscSecurityIdentifier", - "Get-SPDscFarmProductsInfo", - "Get-SPDscFarmVersionInfo", - "Convert-SPDscADGroupIDToName", - "Convert-SPDscADGroupNameToID") + # Cmdlets to export from this module + CmdletsToExport = @("Invoke-SPDscCommand", + "Get-SPDscInstalledProductVersion", + "Get-SPDscContentService", + "Rename-SPDscParamValue", + "Add-SPDscUserToLocalAdmin", + "Remove-SPDscUserToLocalAdmin", + "Test-SPDscObjectHasProperty", + "Test-SPDscRunAsCredential", + "Test-SPDscUserIsLocalAdmin", + "Test-SPDscParameterState", + "Test-SPDscIsADUser", + "Test-SPDscRunningAsFarmAccount", + "Set-SPDscObjectPropertyIfValuePresent", + "Get-SPDscUserProfileSubTypeManager", + "Get-SPDscOSVersion", + "Get-SPDscRegistryKey", + "Resolve-SPDscSecurityIdentifier", + "Get-SPDscFarmProductsInfo", + "Get-SPDscFarmVersionInfo", + "Convert-SPDscADGroupIDToName", + "Convert-SPDscADGroupNameToID") - # Variables to export from this module - #VariablesToExport = '*' + # Variables to export from this module + #VariablesToExport = '*' - # Aliases to export from this module - #AliasesToExport = '*' + # Aliases to export from this module + #AliasesToExport = '*' - # List of all modules packaged with this module - # ModuleList = @() + # List of all modules packaged with this module + # ModuleList = @() - # List of all files packaged with this module - # FileList = @() + # List of all files packaged with this module + # FileList = @() - # HelpInfo URI of this module - # HelpInfoURI = '' + # HelpInfo URI of this module + # HelpInfoURI = '' - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -prefix. - # DefaultCommandPrefix = '' + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -prefix. + # DefaultCommandPrefix = '' - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ - PSData = @{ + PSData = @{ + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') - # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') + # A URL to the license for this module. + LicenseUri = 'https://github.com/PowerShell/SharePointDsc/blob/master/LICENSE' - # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/SharePointDsc/blob/master/LICENSE' + # A URL to the main website for this project. + ProjectUri = 'https://github.com/PowerShell/SharePointDsc' - # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShell/SharePointDsc' + # A URL to an icon representing this module. + # IconUri = '' - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - ReleaseNotes = " - * SharePointDsc generic - * Added new launch actions to vscode to allow code coverage reports for - the current unit test file. + # ReleaseNotes of this module + ReleaseNotes = " + * SPConfigWizard + * Fixed issue with incorrect check for upgrade status of server + * SPDistributedCacheService + * Improved error message for inclusion of server name into ServerProvisionOrder + parameters when Present or change to Ensure Absent * SPFarm - * Moved check for CentralAdministrationUrl is HTTP to Set method, - to prevent issues with ReverseDsc. + * Removed SingleServer as ServerRole, since this is an invalid role. + * Handle case where null or empty CentralAdministrationUrl is passed in + * Move CentralAdministrationPort validation into parameter definition + to work with ReverseDsc + * Add NotNullOrEmpty parameter validation to CentralAdministrationUrl + * Fixed error when changing developer dashboard display level. + * Add support for updating Central Admin Authentication Method + * SPFarmSolution + * Fix for Web Application scoped solutions. * SPInstall - * Updated error code checks to force reboot. + * Fixes a terminating error for sources in weird file shares + * Corrected issue with incorrectly detecting SharePoint after it + has been uninstalled + * Corrected issue with detecting a paused installation + * SPInstallLanguagePack + * Fixes a terminating error for sources in weird file shares + * SPInstallPrereqs + * Fixes a terminating error for sources in weird file shares * SPProductUpdate - * Fixes an issue using ShutdownServices when no Farm is available. - * SPTrustedRootAuthority - * Fixes issue where Set method throws an error because the - parameter CertificateFilePath is not read correctly. - * SPTrustedSecurityTokenIssuer - * New resource for configuring OAuth trusts + * Fixes a terminating error for sources in weird file shares + * Corrected incorrect farm detection, added in earlier bugfix + * SPSite + * Fixed issue with incorrectly updating site OwnerAlias and + SecondaryOwnerAlias + * SPWebAppAuthentication + * Fixes issue where Test method return false on NON-US OS. " - } # End of PSData hashtable + } # End of PSData hashtable - } # End of PrivateData hashtable + } # End of PrivateData hashtable } diff --git a/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt b/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt index 905d6315e..5033f14fd 100644 --- a/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt @@ -25,6 +25,8 @@ servers provisioning a cache at the same time. Note, this approach only makes a server check the others for distributed cache, it does not provision the cache automatically on all servers. If a previous server in the sequence does + not appear to be running distributed cache after 30 minutes, the local server + that was waiting will begin anyway. The default value for the Ensure parameter is Present. When not specifying this parameter, the distributed cache is provisioned. @@ -118,7 +120,9 @@ firewall solution. This example applies the distributed cache service to both "server1" and "server2". The ServerProvisionOrder will ensure that it applies it to server1 first and then server2, making sure they don't both attempt to -create the cache at the same time, resuling in errors. +create the cache at the same time, resuling in errors. A third server +"server3", which is not included within ServerProvisionOrder, is +configured as Absent. Note: Do not allow plain text passwords in production environments. @@ -131,6 +135,10 @@ Note: Do not allow plain text passwords in production environments. @{ NodeName = 'Server2' PSDscAllowPlainTextPassword = $true + }, + @{ + NodeName = 'Server3' + PSDscAllowPlainTextPassword = $true } ) } @@ -169,6 +177,20 @@ Note: Do not allow plain text passwords in production environments. PsDscRunAsCredential = $SetupAccount } } + + node "Server3" + { + SPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + CacheSizeInMB = 8192 + ServiceAccount = "DEMO\ServiceAccount" + ServerProvisionOrder = @("Server1","Server2") + CreateFirewallRules = $true + Ensure = 'Absent' + PsDscRunAsCredential = $SetupAccount + } + } } diff --git a/Modules/SharePointDsc/en-US/about_SPFarm.help.txt b/Modules/SharePointDsc/en-US/about_SPFarm.help.txt index 97c7cc460..fa7c859e4 100644 --- a/Modules/SharePointDsc/en-US/about_SPFarm.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPFarm.help.txt @@ -39,11 +39,10 @@ specified, it defaults to NTLM. If using Kerberos, make sure to have appropriate SPNs setup for Farm account and Central Administration URI. - To provision Central Admin as an SSL web application, specify a value for - the CentralAdministrationUrl property that begins with https:// followed - by the vanity host name or server name you wish to use to access CA. - (e.g. https://admin.sharepoint.contoso.com). This parameter does not - currently support HTTP. + To provision Central Admin on a vanity URL instead of the default + http(s)://servername:port, use the CentralAdministrationUrl parameter. + Central Admin will be provisioned as an SSL web application if this URL + begins with HTTPS, and will default to port 443. DeveloperDashboard can be specified as "On", "Off" and (only when using SharePoint 2013) to "OnDemand". @@ -89,7 +88,7 @@ .PARAMETER CentralAdministrationUrl Write - String - Vanity URL for Central Administration (currently HTTPS only). For HTTP vanity host, use SPAlternateHost. + Vanity URL for Central Administration .PARAMETER CentralAdministrationPort Write - Uint32 @@ -102,7 +101,7 @@ .PARAMETER ServerRole Write - String - Allowed values: Application, ApplicationWithSearch, Custom, DistributedCache, Search, SingleServer, SingleServerFarm, WebFrontEnd, WebFrontEndWithDistributedCache + Allowed values: Application, ApplicationWithSearch, Custom, DistributedCache, Search, SingleServerFarm, WebFrontEnd, WebFrontEndWithDistributedCache SharePoint 2016 & 2019 only - the MinRole role to enroll this server as .PARAMETER DeveloperDashboard diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 index 8af41f208..24ae91340 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPConfigWizard.Tests.ps1 @@ -21,7 +21,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { # Mocks for all contexts Mock -CommandName Remove-Item -MockWith { } Mock -CommandName Get-Content -MockWith { return "log info" } - Mock -CommandName Get-SPDscServerPatchStatus -MockWith { return "NoActionRequired" } + Mock -CommandName Get-SPDscServerPatchStatus -MockWith { return "UpgradeRequired" } # Test contexts Context -Name "Upgrade required for Language Pack" -Fixture { diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPDistributedCacheService.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPDistributedCacheService.Tests.ps1 index 5785822fc..2a64b1040 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPDistributedCacheService.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPDistributedCacheService.Tests.ps1 @@ -343,7 +343,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } -ParameterFilter { $Server -eq "Server1" -or $Server -eq "Server2" } It "Should set up the cache correctly" { - { Set-TargetResource @testParams } | Should Throw "The server $($env:COMPUTERNAME) was not found in the array for distributed cache servers" + { Set-TargetResource @testParams } | Should Throw "The server $($env:COMPUTERNAME) was not found in the ServerProvisionOrder array of Distributed Cache server(s). The server must be included in ServerProvisionOrder or Ensure equal to Absent." } } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 index 2395f3221..83ad3dee2 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 @@ -3,12 +3,12 @@ param( [Parameter()] [string] $SharePointCmdletModule = (Join-Path -Path $PSScriptRoot ` - -ChildPath "..\Stubs\SharePoint\15.0.4805.1000\Microsoft.SharePoint.PowerShell.psm1" ` + -ChildPath '..\Stubs\SharePoint\15.0.4805.1000\Microsoft.SharePoint.PowerShell.psm1' ` -Resolve) ) Import-Module -Name (Join-Path -Path $PSScriptRoot ` - -ChildPath "..\UnitTestHelper.psm1" ` + -ChildPath '..\UnitTestHelper.psm1' ` -Resolve) $Global:SPDscHelper = New-SPDscUnitTestHelper -SharePointStubModule $SharePointCmdletModule ` @@ -19,13 +19,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope # Initialize tests - $mockPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force - $mockFarmAccount = New-Object -TypeName "System.Management.Automation.PSCredential" ` - -ArgumentList @("username", $mockPassword) + $mockPassword = ConvertTo-SecureString -String 'password' -AsPlainText -Force + $mockFarmAccount = New-Object -TypeName 'System.Management.Automation.PSCredential' ` + -ArgumentList @('username', $mockPassword) $mockPassphrase = New-Object -TypeName "System.Management.Automation.PSCredential" ` - -ArgumentList @("PASSPHRASEUSER", $mockPassword) + -ArgumentList @('PASSPHRASEUSER', $mockPassword) - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.Farm\SPFarm.psm1" + $modulePath = 'Modules\SharePointDsc\Modules\SharePointDsc.Farm\SPFarm.psm1' Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) try @@ -66,7 +66,7 @@ namespace Microsoft.SharePoint.Administration { } Mock -CommandName Get-SPDscContentService -MockWith { $developerDashboardSettings = @{ - DisplayLevel = "Off" + DisplayLevel = 'Off' } $developerDashboardSettings = $developerDashboardSettings | Add-Member -MemberType ScriptMethod -Name Update -Value { @@ -82,27 +82,31 @@ namespace Microsoft.SharePoint.Administration { # Test Contexts Context -Name "No config databases exists, and this server should be connected to one" -Fixture { $testParams = @{ - IsSingleInstance = "Yes" - Ensure = "Present" - FarmConfigDatabaseName = "SP_Config" + IsSingleInstance = 'Yes' + Ensure = 'Present' + FarmConfigDatabaseName = 'SP_Config' CentralAdministrationPort = 80000 - DatabaseServer = "sql.contoso.com" + DatabaseServer = 'sql.contoso.com' FarmAccount = $mockFarmAccount Passphrase = $mockPassphrase - AdminContentDatabaseName = "SP_AdminContent" + AdminContentDatabaseName = 'SP_AdminContent' RunCentralAdmin = $true } - It "Should throw exception in the get method" { - { Get-TargetResource @testParams } | Should Throw "An invalid value for CentralAdministrationPort is specified:" + $expectedException = "Cannot validate argument on parameter 'CentralAdministrationPort'. " + + "The 80000 argument is greater than the maximum allowed range of 65535. " + + "Supply an argument that is less than or equal to 65535 and then try the command again." + + It 'Should throw parameter validation exception in the get method' { + { Get-TargetResource @testParams } | Should Throw $expectedException } - It "Should throw exception in the test method" { - { Test-TargetResource @testParams } | Should Throw "An invalid value for CentralAdministrationPort is specified:" + It 'Should throw parameter validation exception in the test method' { + { Test-TargetResource @testParams } | Should Throw $expectedException } - It "Should throw exception in the set method" { - { Set-TargetResource @testParams } | Should Throw "An invalid value for CentralAdministrationPort is specified:" + It 'Should throw parameter validation exception in the Set method' { + { Set-TargetResource @testParams } | Should Throw $expectedException } } @@ -120,6 +124,10 @@ namespace Microsoft.SharePoint.Administration { RunCentralAdmin = $true } + It "Should throw exception in the test method" { + { Test-TargetResource @testParams } | Should Throw "CentralAdministrationUrl is not a valid URI. It should include the scheme (http/https) and address." + } + It "Should throw exception in the set method" { { Set-TargetResource @testParams } | Should Throw "CentralAdministrationUrl is not a valid URI. It should include the scheme (http/https) and address." } @@ -139,31 +147,16 @@ namespace Microsoft.SharePoint.Administration { RunCentralAdmin = $true } - It "Should throw exception in the set method" { - { Set-TargetResource @testParams } | Should Throw "CentralAdministrationUrl should not specify port. Use CentralAdministrationPort instead." - } - } - - Context -Name "Invalid CA URL has been passed in (HTTP currently not supported)" -Fixture { - $testParams = @{ - IsSingleInstance = "Yes" - Ensure = "Present" - FarmConfigDatabaseName = "SP_Config" - CentralAdministrationPort = 443 - CentralAdministrationUrl = "http://admin.contoso.com" - DatabaseServer = "sql.contoso.com" - FarmAccount = $mockFarmAccount - Passphrase = $mockPassphrase - AdminContentDatabaseName = "SP_AdminContent" - RunCentralAdmin = $true + It "Should throw exception in the test method" { + { Test-TargetResource @testParams } | Should Throw "CentralAdministrationUrl should not specify port. Use CentralAdministrationPort instead." } It "Should throw exception in the set method" { - { Set-TargetResource @testParams } | Should Throw "CentralAdministrationUrl parameter can only be used with HTTPS" + { Set-TargetResource @testParams } | Should Throw "CentralAdministrationUrl should not specify port. Use CentralAdministrationPort instead." } } - Context -Name "No config databaes exists, and this server should be connected to one" -Fixture { + Context -Name "No config databases exists, and this server should be connected to one" -Fixture { $testParams = @{ IsSingleInstance = "Yes" Ensure = "Present" @@ -609,6 +602,7 @@ namespace Microsoft.SharePoint.Administration { Passphrase = $mockPassphrase AdminContentDatabaseName = "SP_AdminContent" RunCentralAdmin = $true + CentralAdministrationUrl = "" CentralAdministrationPort = 8080 } @@ -688,6 +682,419 @@ namespace Microsoft.SharePoint.Administration { } } + Context -Name "This server is running CA as NTLM, but authentication method should be Kerberos" -Fixture { + $testParams = @{ + IsSingleInstance = "Yes" + Ensure = "Present" + FarmConfigDatabaseName = "SP_Config" + DatabaseServer = "sql.contoso.com" + FarmAccount = $mockFarmAccount + Passphrase = $mockPassphrase + AdminContentDatabaseName = "SP_AdminContent" + RunCentralAdmin = $true + CentralAdministrationUrl = "http://admin.contoso.com" + CentralAdministrationPort = 80 + CentralAdministrationAuth = "Kerberos" + } + + Mock -CommandName Get-SPDscRegistryKey -MockWith { + return "Connection string example" + } + + Mock -CommandName Get-SPFarm -MockWith { + return @{ + Name = $testParams.FarmConfigDatabaseName + DatabaseServer = @{ + Name = $testParams.DatabaseServer + } + AdminContentDatabaseName = $testParams.AdminContentDatabaseName + } + } + Mock -CommandName Get-SPDscConfigDBStatus -MockWith { + return @{ + Locked = $false + ValidPermissions = $true + DatabaseExists = $true + } + } + Mock -CommandName "Get-SPDscSQLInstanceStatus" -MockWith { + return @{ + MaxDOPCorrect = $true + } + } + Mock -CommandName Get-SPDatabase -MockWith { + return @(@{ + Name = $testParams.FarmConfigDatabaseName + Type = "Configuration Database" + NormalizedDataSource = $testParams.DatabaseServer + }) + } + Mock -CommandName Get-SPWebApplication -MockWith { + $webapp = @{ + ContentDatabases = @( + @{ + Name = $testParams.AdminContentDatabaseName + } + ) + Url = $testParams.CentralAdministrationUrl + IsAdministrationWebApplication = $true + IisSettings = [ordered]@{ + Default = @{ + DisableKerberos = $true + ServerBindings = @( + @{ + HostHeader = "admin.contoso.com" + Port = "80" + } + ) + } + } + } + + $webapp | Add-Member -MemberType ScriptMethod -Name GetIisSettingsWithFallback -Value { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] + $Zone + ) + + return $this.IisSettings[$Zone] + } + + return $webapp + } + + Mock -CommandName Get-CimInstance -MockWith { + return @{ + Domain = "domain.com" + } + } + + Mock -CommandName Get-SPServiceInstance -MockWith { + switch ($global:SPDscSIRunCount) + { + { 2 -contains $_ } + { + $global:SPDscSIRunCount++ + return @( + @{ + Name = "WSS_Administration" + Status = "Online" + } | Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + return @{ + Name = "SPWebServiceInstance" + } + } -PassThru -Force + ) + } + { 0, 1 -contains $_ } + { + $global:SPDscSIRunCount++ + return $null + } + } + } + + Mock -CommandName Set-SPWebApplication -MockWith { } + + $global:SPDscSIRunCount = 2 + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.RunCentralAdmin | Should Be $true + $result.CentralAdministrationUrl | Should Be $testParams.CentralAdministrationUrl + $result.CentralAdministrationPort | Should Be $testParams.CentralAdministrationPort + $result.CentralAdministrationAuth | Should Be "NTLM" + } + + $global:SPDscSIRunCount = 2 + It "Should change Authentication Mode of CA from NTLM to Kerberos" { + Set-TargetResource @testParams + Assert-MockCalled -CommandName "Set-SPWebApplication" + } + + $global:SPDscSIRunCount = 2 + It "Should return false from the test method" { + Test-TargetResource @testParams | Should be $false + } + } + + Context -Name "This server is running CA as Kerberos, but authentication method should be NTLM" -Fixture { + $testParams = @{ + IsSingleInstance = "Yes" + Ensure = "Present" + FarmConfigDatabaseName = "SP_Config" + DatabaseServer = "sql.contoso.com" + FarmAccount = $mockFarmAccount + Passphrase = $mockPassphrase + AdminContentDatabaseName = "SP_AdminContent" + RunCentralAdmin = $true + CentralAdministrationUrl = "http://admin.contoso.com" + CentralAdministrationPort = 80 + CentralAdministrationAuth = "NTLM" + } + + Mock -CommandName Get-SPDscRegistryKey -MockWith { + return "Connection string example" + } + + Mock -CommandName Get-SPFarm -MockWith { + return @{ + Name = $testParams.FarmConfigDatabaseName + DatabaseServer = @{ + Name = $testParams.DatabaseServer + } + AdminContentDatabaseName = $testParams.AdminContentDatabaseName + } + } + Mock -CommandName Get-SPDscConfigDBStatus -MockWith { + return @{ + Locked = $false + ValidPermissions = $true + DatabaseExists = $true + } + } + Mock -CommandName "Get-SPDscSQLInstanceStatus" -MockWith { + return @{ + MaxDOPCorrect = $true + } + } + Mock -CommandName Get-SPDatabase -MockWith { + return @(@{ + Name = $testParams.FarmConfigDatabaseName + Type = "Configuration Database" + NormalizedDataSource = $testParams.DatabaseServer + }) + } + Mock -CommandName Get-SPWebApplication -MockWith { + $webapp = @{ + ContentDatabases = @( + @{ + Name = $testParams.AdminContentDatabaseName + } + ) + Url = $testParams.CentralAdministrationUrl + IsAdministrationWebApplication = $true + IisSettings = [ordered]@{ + Default = @{ + DisableKerberos = $false + ServerBindings = @( + @{ + HostHeader = "admin.contoso.com" + Port = "80" + } + ) + } + } + } + + $webapp | Add-Member -MemberType ScriptMethod -Name GetIisSettingsWithFallback -Value { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] + $Zone + ) + + return $this.IisSettings[$Zone] + } + + return $webapp + } + + Mock -CommandName Get-CimInstance -MockWith { + return @{ + Domain = "domain.com" + } + } + + Mock -CommandName Get-SPServiceInstance -MockWith { + switch ($global:SPDscSIRunCount) + { + { 2 -contains $_ } + { + $global:SPDscSIRunCount++ + return @( + @{ + Name = "WSS_Administration" + Status = "Online" + } | Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + return @{ + Name = "SPWebServiceInstance" + } + } -PassThru -Force + ) + } + { 0, 1 -contains $_ } + { + $global:SPDscSIRunCount++ + return $null + } + } + } + + Mock -CommandName Set-SPWebApplication -MockWith { } + + $global:SPDscSIRunCount = 2 + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.RunCentralAdmin | Should Be $true + $result.CentralAdministrationUrl | Should Be $testParams.CentralAdministrationUrl + $result.CentralAdministrationPort | Should Be $testParams.CentralAdministrationPort + $result.CentralAdministrationAuth | Should Be "Kerberos" + } + + $global:SPDscSIRunCount = 2 + It "Should change Authentication Mode of CA from Kerberos to NTLM" { + Set-TargetResource @testParams + Assert-MockCalled -CommandName "Set-SPWebApplication" + } + + $global:SPDscSIRunCount = 2 + It "Should return false from the test method" { + Test-TargetResource @testParams | Should be $false + } + } + + Context -Name "This server is running CA on HTTP, but secure bindings do not match CA URL" -Fixture { + $testParams = @{ + IsSingleInstance = "Yes" + Ensure = "Present" + FarmConfigDatabaseName = "SP_Config" + DatabaseServer = "sql.contoso.com" + FarmAccount = $mockFarmAccount + Passphrase = $mockPassphrase + AdminContentDatabaseName = "SP_AdminContent" + RunCentralAdmin = $true + CentralAdministrationUrl = "http://admin.contoso.com" + CentralAdministrationPort = 80 + } + + Mock -CommandName Get-SPDscRegistryKey -MockWith { + return "Connection string example" + } + + Mock -CommandName Get-SPFarm -MockWith { + return @{ + Name = $testParams.FarmConfigDatabaseName + DatabaseServer = @{ + Name = $testParams.DatabaseServer + } + AdminContentDatabaseName = $testParams.AdminContentDatabaseName + } + } + Mock -CommandName Get-SPDscConfigDBStatus -MockWith { + return @{ + Locked = $false + ValidPermissions = $true + DatabaseExists = $true + } + } + Mock -CommandName "Get-SPDscSQLInstanceStatus" -MockWith { + return @{ + MaxDOPCorrect = $true + } + } + Mock -CommandName Get-SPDatabase -MockWith { + return @(@{ + Name = $testParams.FarmConfigDatabaseName + Type = "Configuration Database" + NormalizedDataSource = $testParams.DatabaseServer + }) + } + Mock -CommandName Get-SPWebApplication -MockWith { + $webapp = @{ + ContentDatabases = @( + @{ + Name = $testParams.AdminContentDatabaseName + } + ) + Url = $testParams.CentralAdministrationUrl + IsAdministrationWebApplication = $true + IisSettings = [ordered]@{ + Default = @{ + DisableKerberos = $true + ServerBindings = @( + @{ + HostHeader = "different.contoso.com" + Port = "80" + } + ) + } + } + } + + $webapp | Add-Member -MemberType ScriptMethod -Name GetIisSettingsWithFallback -Value { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] + $Zone + ) + + return $this.IisSettings[$Zone] + } + + return $webapp + } + + Mock -CommandName Get-CimInstance -MockWith { + return @{ + Domain = "domain.com" + } + } + + Mock -CommandName Get-SPServiceInstance -MockWith { + switch ($global:SPDscSIRunCount) + { + { 2 -contains $_ } + { + $global:SPDscSIRunCount++ + return @( + @{ + Name = "WSS_Administration" + Status = "Online" + } | Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + return @{ + Name = "SPWebServiceInstance" + } + } -PassThru -Force + ) + } + { 0, 1 -contains $_ } + { + $global:SPDscSIRunCount++ + return $null + } + } + } + + $global:SPDscSIRunCount = 0 + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.RunCentralAdmin | Should Be $false + $result.CentralAdministrationUrl | Should Be $testParams.CentralAdministrationUrl + $result.CentralAdministrationPort | Should Be $testParams.CentralAdministrationPort + } + + $global:SPDscSIRunCount = 0 + It "Should start the central administration instance" { + Set-TargetResource @testParams + Assert-MockCalled -CommandName "Start-SPServiceInstance" + } + + $global:SPDscCentralAdminCheckDone = $false + It "Should return false from the test method" { + Test-TargetResource @testParams | Should be $false + } + } + Context -Name "This server is running CA on HTTPS, but secure bindings do not match CA URL" -Fixture { $testParams = @{ IsSingleInstance = "Yes" @@ -823,6 +1230,82 @@ namespace Microsoft.SharePoint.Administration { } } + Context -Name "Server not yet part of the farm, and will run Central Admin on HTTP with vanity host name" -Fixture { + $testParams = @{ + IsSingleInstance = "Yes" + Ensure = "Present" + FarmConfigDatabaseName = "SP_Config" + DatabaseServer = "sql.contoso.com" + FarmAccount = $mockFarmAccount + Passphrase = $mockPassphrase + AdminContentDatabaseName = "SP_AdminContent" + CentralAdministrationUrl = "http://admin.contoso.com" + RunCentralAdmin = $true + } + + Mock -CommandName "Get-SPDscRegistryKey" -MockWith { return $null } + Mock -CommandName "Get-SPFarm" -MockWith { return $null } + Mock -CommandName "Get-SPDscConfigDBStatus" -MockWith { + return @{ + Locked = $false + ValidPermissions = $true + DatabaseExists = $true + } + } + Mock -CommandName "Get-SPDscSQLInstanceStatus" -MockWith { + return @{ + MaxDOPCorrect = $true + } + } + + Mock -CommandName "Get-SPWebApplication" -MockWith { + return @{ + IsAdministrationWebApplication = $true + ContentDatabases = @(@{ + Name = $testParams.AdminContentDatabaseName + }) + Url = "http://localhost:9999" + } + } + Mock -CommandName "Get-SPServiceInstance" -MockWith { + if ($global:SPDscCentralAdminCheckDone -eq $true) + { + return @( + @{ + Name = "WSS_Administration" + } | Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + return @{ + Name = "SPWebServiceInstance" + } + } -PassThru -Force + ) + } + else + { + $global:SPDscCentralAdminCheckDone = $true + return $null + } + } + + It "Should return absent from the get method" { + (Get-TargetResource @testParams).Ensure | Should Be "Absent" + } + + It "Should return false from the test method" { + Test-TargetResource @testParams | Should be $false + } + + $global:SPDscCentralAdminCheckDone = $false + It "Should provision, remove, and re-extend CA web application in the set method" { + Set-TargetResource @testParams + Assert-MockCalled -CommandName "New-SPCentralAdministration" + Assert-MockCalled -CommandName "Remove-SPWebApplication" + Assert-MockCalled -CommandName "New-SPWebApplicationExtension" + } + } + Context -Name "Server not yet part of the farm, and will run Central Admin on HTTPS" -Fixture { $testParams = @{ IsSingleInstance = "Yes" @@ -1613,15 +2096,15 @@ namespace Microsoft.SharePoint.Administration { } } - It "Should throw and exception in the get method" { + It "Should throw an exception in the get method" { { Get-TargetResource @testParams } | Should Throw "The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint 2016 and 2019" } - It "Should throw and exception in the set method" { + It "Should throw an exception in the set method" { { Set-TargetResource @testParams } | Should Throw "The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint 2016 and 2019" } - It "Should throw and exception in the test method" { + It "Should throw an exception in the test method" { { Test-TargetResource @testParams } | Should Throw "The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint 2016 and 2019" } } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPFarmSolution.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPFarmSolution.Tests.ps1 index f9c5555d1..27e4e1c96 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPFarmSolution.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPFarmSolution.Tests.ps1 @@ -351,6 +351,71 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Assert-MockCalled Install-SPSolution -ParameterFilter { $CompatibilityLevel -eq $testParams.SolutionLevel } } } + + Context -Name "Solution is scoped at the Web Application Level" -Fixture { + $testParams = @{ + Name = "SomeSolution" + LiteralPath = "\\server\share\file.wsp" + Deployed = $true + Ensure = "Present" + Version = "1.1.0.0" + WebAppUrls = @("https://contoso.com") + SolutionLevel = "All" + } + + $solution = [pscustomobject]@{ + Deployed = $false + Properties = @{ Version = "1.0.0.0" } + ContainsWebApplicationResource = $true + DeployedWebApplications = @() + ContainsGlobalAssembly = $true + } + $solution | Add-Member -Name Update -MemberType ScriptMethod -Value { } + + Mock -CommandName Get-SPSolution -MockWith { $solution } + Mock -CommandName Add-SPSolution -MockWith { $solution } + + It "Deploys the solution to the specified Web Application" { + Set-TargetResource @testParams + } + } + + Context -Name "Solution is scoped at multiple Web Application Levels" -Fixture { + $testParams = @{ + Name = "SomeSolution" + LiteralPath = "\\server\share\file.wsp" + Deployed = $true + Ensure = "Present" + Version = "1.1.0.0" + WebAppUrls = @("https://contoso.com", "https://tailspintoys.com") + SolutionLevel = "All" + } + + $numberOfCalls = 1 + Mock -CommandName Install-SPSolution -MockWith { + if ($numberOfCalls -le 1) + { + $numberOfCalls++ + throw "A deployment is already underway" + } + } + + $solution = [pscustomobject]@{ + Deployed = $false + Properties = @{ Version = "1.0.0.0" } + ContainsWebApplicationResource = $true + DeployedWebApplications = @() + ContainsGlobalAssembly = $true + } + $solution | Add-Member -Name Update -MemberType ScriptMethod -Value { } + + Mock -CommandName Get-SPSolution -MockWith { $solution } + Mock -CommandName Add-SPSolution -MockWith { $solution } + + It "Deploys the solution to the specified Web Application" { + Set-TargetResource @testParams + } + } } } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPProductUpdate.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPProductUpdate.Tests.ps1 index 1bb1ac2d4..9785abb98 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPProductUpdate.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPProductUpdate.Tests.ps1 @@ -253,7 +253,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Add-TestRegistryData -PatchLevel "RTM" Mock -CommandName Get-SPFarm { - return $null + throw } Mock -CommandName Get-ItemProperty -MockWith { diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPSite.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPSite.Tests.ps1 index 96f3e776e..817a886f0 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPSite.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPSite.Tests.ps1 @@ -51,6 +51,9 @@ namespace Microsoft.SharePoint.Administration { -Value { $this.CreateDefaultAssociatedGroupsCalled = $true } + $rootWeb = $rootWeb | Add-Member -MemberType ScriptMethod ` + -Name EnsureUser ` + -Value { return "user" } -PassThru $site = @{ HostHeaderIsSiteName = $false @@ -200,8 +203,6 @@ namespace Microsoft.SharePoint.Administration { } Mock -CommandName Set-SPSite -MockWith { } -ParameterFilter { - $OwnerAlias = "DEMO\User" - $SecondaryOwnerAlias = "DEMO\SecondUser" $QuotaTemplate = "Test" $AdministrationSiteType -eq "TenantAdministration" } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 index ff58dafc5..2e9542bb2 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 @@ -375,11 +375,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" }, @@ -425,8 +427,9 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true } ) } @@ -468,11 +471,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" } @@ -528,11 +533,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" }, @@ -583,11 +590,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" } @@ -643,11 +652,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" }, @@ -698,11 +709,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" } @@ -758,11 +771,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" }, @@ -808,11 +823,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" }, @@ -871,11 +888,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" - DisableKerberos = $true + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' + DisableKerberos = $true }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" }, @@ -926,11 +945,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName Get-SPAuthenticationProvider -MockWith { return @( @{ - DisplayName = "Windows Authentication" + DisplayName = "Windows Authentication" + ClaimProviderName = 'AD' DisableKerberos = $false }, @{ DisplayName = "Forms Authentication" + ClaimProviderName = 'Forms' RoleProvider = "RoleProvider" MembershipProvider = "MemberProvider" }