microsoft / SharePointDSC.Reverse

Extracts a Desired State Configuration Script from an existing SharePoint Farm
MIT License
40 stars 27 forks source link

Extraction of SPFARM fails due to Cenadmin on HTTPS #88

Open xenophobentx opened 5 years ago

xenophobentx commented 5 years ago

[ SP2019APP1 ] Generating the SharePoint Prerequisites Installation... [ SP2019APP1 ] Generating the SharePoint Binary Installation... [ SP2019APP1 ] Scanning the SharePoint Farm... Exception calling "PerformClick" with "0" argument(s): "An invalid value for CentralAdministrationPort is specified: 0" At C:\Program Files\WindowsPowerShell\Scripts\SharePointDSC.Reverse.ps1:6256 char:13

My farm resource look like this:

SPFarm CreateSharePointFarm { IsSingleInstance = "Yes" Ensure = 'Present' FarmConfigDatabaseName = $configdata.farm.ConfigDB DatabaseServer = $configdata.farm.ConfigDbServer FarmAccount = $credsLocalAdmin Passphrase = New-Object System.Management.Automation.PSCredential ('Passphrase', (ConvertTo-SecureString $Passphrase -AsPlainText -Force)); AdminContentDatabaseName = $configdata.farm.CentralAdminContentDB RunCentralAdmin = $Node.roles.Contains("CA-PRIMARY") CentralAdministrationPort = 22641 CentralAdministrationUrl = "https://sp2019app1.sky.net" CentralAdministrationAuth = 'NTLM' ServerRole = "CUSTOM" PSDSCRunAsCredential = $credsLocalAdmin

            DependsOn                 = @('[WaitForAll]Waitforallbinaries', '[xPendingReboot]BeforeWizard')
        }

Same environment with http and same port work flawlessly. Tested multiple times on multiple servers. (Windows 2016 + SP2019 May CU)

kayodebristol commented 4 years ago

This seems to happen because $SPCentralAdmin.iisettings[0].ServerBindings.Port returns null on your farm... meaning you are only using https with 443 (SecureBindings.Port)

Find

$params.CentralAdministrationPort = $Script:spCentralAdmin.IisSettings[0].ServerBindings.Port

And change to

$params.CentralAdministrationPort = $Script:spCentralAdmin.IisSettings[0].ServerBindings.Port
    if($null -eq $params.CentralAdministrationPort -or $parms.CentralAdministrationPort -eq 0){
        $params.CentralAdministrationPort = $Script:spCentralAdmin.IisSettings[0].SecureBindings.Port
    }

In SharePointDSC.Reverse.ps1 script file.

I'll submit a pull request after more testing.