Yvand/EntraCP

Initializing settings without opening Central Admin

Closed this issue · 7 comments

Hello.

When setting up EntraCP in a new farm, we are running powershell code to automate the installation process. However, we are unable to completely automate the process atm, because the global settings are not being initialized without manually navigating into the EntraCP "Global configuration" page in Central Admin.

Reproduce:

This results in [Yvand.EntraClaimsProvider.EntraCP]::GetConfiguration() returning null.

If you navigate to "Global configuration" page, the settings gets initialized and the configuration code works fine. This can maybe be fixed by GetConfiguration() also running the initialize code, or by modifying the configuration documentation to call an initialize method before calling GetConfiguration().

Hi @Vice93, you can test if GetConfiguration() returns null, and if so, you can create it by running $config = [Yvand.EntraClaimsProvider.EntraCP]::CreateConfiguration()

Seems this worked for most of the settings, however, it did not initialize EntraIDTenants list. Calling .Add on this throws an exception:

InvalidOperation: You cannot call a method on a null-valued expression.
At Script.ps1:34 char:4
+ $settings.EntraIDTenants.Add($tenant)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It does get initialized if I open the .aspx page though, and works in powershell afterwards.

@Vice93 I would like to understand the root cause of this issue. Do you have repro steps I can use to repro this myself?

On a fresh sharepoint farm, deploy EntraCP and run the following script:

Add-Type -AssemblyName "Yvand.EntraCP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=65dc6b5903b51636"

$config = [Yvand.EntraClaimsProvider.EntraCP]::GetConfiguration()
if ($null -eq $config)
{
    $config = [Yvand.EntraClaimsProvider.EntraCP]::CreateConfiguration()
    if ($null -eq $config.Settings.EntraIDTentants)
    {
    	Write-Error "Could not create configuration for EntraCP"
        return
    }
}

Just make sure you do not do anything manual like navigating to central admin EntraCP configuration page before running the script (the point is trying to automate the entire process).

@Vice93 I basically do the same, and $config.Settings.EntraIDTentants should indeed not be null.
When running [Yvand.EntraClaimsProvider.EntraCP]::CreateConfiguration() you should see this message in the log:

04/16/2024 09:50:06.78	powershell.exe (0x1660)	0x0864	EntraCP	Core	1337	High	Created configuration 'EntraCPConfig' with Id 1db24d85-b10e-4d06-b378-8cfd05a129f3	5d832b90-b879-0003-e638-0e32ce8fda01

Is it recorded in your environment?

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

This issue was closed because it has been stalled for 5 days with no activity.