dsccommunity / SharePointDsc

The SharePointDsc PowerShell module provides DSC resources that can be used to deploy and manage a SharePoint farm
MIT License
245 stars 107 forks source link

[SPWebApplication] Calls Set-SPWebApplication with non existing Parameter SecureSocketsLayer #1394

Closed ChristophHannappel closed 2 years ago

ChristophHannappel commented 2 years ago

Problem description

The Set Function for SPWebApplication adds the SecureSocketsLayer Parameter to the Set-SPWebApplication function, if the WebApplication URL has an https scheme.

In SharePoint Server 2019 the Set-SPWebApplication Function does not have a parameter SecureSocketsLayer

Add-PSSnapin -Name Microsoft.SharePoint.PowerShell
Get-Command -Name Set-SPWebApplication -Syntax

Set-SPWebApplication [-Identity] <SPWebApplicationPipeBind> [-DefaultTimeZone <int>] [-DefaultQuotaTemplate <string>] [-ServiceApplicationProxyGroup <SPServiceApplicationProxyGroupPipeBi
nd>] [-Force] [-NotProvisionGlobally] [-AssignmentCollection <SPAssignmentCollection>] [-WhatIf] [-Confirm] [<CommonParameters>]

Set-SPWebApplication [-Identity] <SPWebApplicationPipeBind> -Zone <SPUrlZone> [-AuthenticationProvider <SPAuthenticationProviderPipeBind[]>] [-AdditionalClaimProvider <SPClaimProviderPip
eBind[]>] [-SignInRedirectURL <string>] [-SignInRedirectProvider <SPTrustedIdentityTokenIssuerPipeBind>] [-AuthenticationMethod <string>] [-Force] [-NotProvisionGlobally] [-AssignmentCol
lection <SPAssignmentCollection>] [-WhatIf] [-Confirm] [<CommonParameters>]

Set-SPWebApplication [-Identity] <SPWebApplicationPipeBind> -SMTPServer <string> [-DisableSMTPEncryption] [-SMTPCredentials <pscredential>] [-SMTPServerPort <int>] [-OutgoingEmailAddress
 <string>] [-ReplyToEmailAddress <string>] [-Force] [-NotProvisionGlobally] [-AssignmentCollection <SPAssignmentCollection>] [-WhatIf] [-Confirm] [<CommonParameters>]

Verbose logs

VERBOSE: [Servername]: LCM:  [ End    Set      ]  [[SPWebApplication]Portal::[SharePointWebApplications]SharePointWebApplications]  in 1.
8040 seconds.
PowerShell DSC resource MSFT_SPWebApplication  failed to execute Set-TargetResource functionality with error message: A parameter 
cannot be found that matches parameter name 'SecureSocketsLayer'. 
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

DSC configuration

SPWebApplication HostNameSiteCollectionWebApp
{
    Name                   = "SharePoint Sites"
    ApplicationPool        = "SharePoint Sites"
    ApplicationPoolAccount = "CONTOSO\svcSPWebApp"
    WebAppUrl              = "https://example.contoso.local"
    Port                   = 443
    AllowAnonymous         = $false
    PsDscRunAsCredential   = $SetupAccount
}

# Enable the Anonymous Authentication and run the DSC Configuration to recreate the bug.

Suggested solution

Put the Code Block into the SharePoint Server Subscription Edition IF block https://github.com/dsccommunity/SharePointDsc/blob/fe2111d3c911e2b5ddd7f14855f1a17c32ff0047/SharePointDsc/DSCResources/MSFT_SPWebApplication/MSFT_SPWebApplication.psm1#L627

SharePoint version and build

SharePoint Server 2019 16.0.10382.20004

Operating system the target node is running

OsName               : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value                                                                                                                                                     
----                           -----                                                                                                                                                     
PSVersion                      5.1.17763.2268                                                                                                                                            
PSEdition                      Desktop                                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                   
BuildVersion                   10.0.17763.2268                                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                                           
WSManStackVersion              3.0                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                       
SerializationVersion           1.1.0.1

SharePointDsc version

Name          Version Path                                                                             
----          ------- ----                                                                             
SharePointDSC 5.1.0   C:\Program Files\WindowsPowerShell\Modules\SharePointDSC\5.1.0\SharePointDSC.psd1
ykuijs commented 2 years ago

I know the SecureSocketsLayer parameter also existed pre-Subscription Edition, but then didn't configure IIS like Subscription Edition is now able to. But it did configure the HTTPS host header names, etc.

Just checked the v4.x code and saw that there the update part didn't exist yet. That was added with the update for SPSE. So I think you are 100% right and this was a copy/paste issue. The New-SPWebApplication did have a SecureSocketLayer parameter, but the Set-SPWebApplication cmdlet didn't 😄. Will review the PR!