microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.59k stars 499 forks source link

Export: Create a datafile instead of a repeating configuration #3206

Closed andikrueger closed 1 year ago

andikrueger commented 1 year ago

The current export will deliver a configuration file that holds all information and nothing is parameterized. More advanced configurations use configuration data files to provide values to the configuration.

It would be great to have an advanced export mode to create configuration data.

The following is an example of one of my recent exports:

        SPOPropertyBag "SPOPropertyBag"
        {
            Ensure               = "Present";
            Key                  = "ID_TENANTADMIN_USERSTORAGE";
            Managedidentity      = $True;
            TenantId             = $ConfigurationData.NonNodeData.TenantId;
            Url                  = "https://$($OrganizationName.Split('.')[0]).sharepoint.com/sites/GovernanceCenter";
            Value                = "6213392c-62dc-4cc8-afe4-d0f0b1754b1d";
        }
        SPOPropertyBag "SPOPropertyBag"
        {
            Ensure               = "Present";
            Key                  = "vti_defaultlanguage";
            Managedidentity      = $True;
            TenantId             = $ConfigurationData.NonNodeData.TenantId;
            Url                  = "https://$($OrganizationName.Split('.')[0]).sharepoint.com/sites/GovernanceCenter";
            Value                = "en-us";
        }
        SPOPropertyBag "SPOPropertyBag"
        {
            Ensure               = "Present";
            Key                  = "taxonomyhiddenlist";
            Managedidentity      = $True;
            TenantId             = $ConfigurationData.NonNodeData.TenantId;
            Url                  = "https://$($OrganizationName.Split('.')[0]).sharepoint.com/sites/GovernanceCenter";
            Value                = "034af0b5-e83d-4cbc-aa9c-ff0fe5618c35";
        }
        SPOPropertyBag "SPOPropertyBag"
        {
            Ensure               = "Present";
            Key                  = "sharepointhelpoverride";
            Managedidentity      = $True;
            TenantId             = $ConfigurationData.NonNodeData.TenantId;
            Url                  = "https://$($OrganizationName.Split('.')[0]).sharepoint.com/sites/GovernanceCenter";
            Value                = "SPOStandard";
        }
        SPOPropertyBag "SPOPropertyBag"
        {
            Ensure               = "Present";
            Key                  = "vti_sitemasterid";
            Managedidentity      = $True;
            TenantId             = $ConfigurationData.NonNodeData.TenantId;
            Url                  = "https://$($OrganizationName.Split('.')[0]).sharepoint.com/sites/GovernanceCenter";
            Value                = "d94fadf4-ddf5-48b9-aee9-1201d2853495";
        }

could be replaced with this configuration Data:

$ConfigurationData.NonNodeData.SPOPropertyBag = @(
    @{
        Ensure = "Present"
        Key    = "TestKey"
        Url    = "https://contoso.sharepoint.com/sites/contoso"
        Value  = "TestValue"
    }
    ...
)

and configuration


$SPOPropertyBag = $ConfigurationData.NonNodeData.SPOPropertyBag

$SPOPropertyBag | ForEach-Object {
    SPOPropertyBag "SPOPropertyBag"
    {
        Ensure               = $SPOPropertyBag.Ensure;
        Key                  = $SPOPropertyBag.Key;
        Managedidentity      = $True;
        TenantId             = $ConfigurationData.NonNodeData.TenantId;
        Url                  = $SPOPropertyBag.Url;
        Value                = $SPOPropertyBag.Value;
    }
}
ykuijs commented 1 year ago

I like the idea, but this addition will break our reporting and compare features. We use the DSCParser for those features and that doesn't support dynamic configurations.

Alternative would be an additional parameter to specify the creation of a dynamic config (placing data in a ConfigurationData file and the logic in the ps1 file). That way a normal export would create the current type of export, which can be used with reporting and compare features.

NikCharlebois commented 1 year ago

Agreed with Yorick about this breaking the reporting feature. I get how this could reduce the overall size of the config. My take on this is that advanced users can include inline scripting and abstract values in the ConfigData themselves if they want to. I do not want us to try and handle this dynamically from the Snapshot/Export feature. Closing this issue.