dsccommunity / SharePointDsc

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

[SPFarmPropertyBag] Resource is only able to configure string values #1398

Closed ykuijs closed 2 years ago

ykuijs commented 2 years ago

Problem description

The schema of the SPFarmPropertyBag resource currently allows the configuration of a string value. However it is unable to configure any other type of value like a boolean:

[Key, Description("The key of the SPFarm property bag")] string Key;
[Write, Description("Value of the SPfarm property bag")] String Value;
[Write, Description("Set to present to ensure the SPfarm property exists, or absent to ensure it is removed"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;

Verbose logs

When the value is configured manually as a boolean, the Test always returns false:

Current Values: Ensure=Present; Key=disableIntranetCalls; Value=False
Target Values: Ensure=Present; Key=disableIntranetCalls; Value=False; Verbose=True
Test-TargetResource returned False

This is because the types of the current values (boolean) and the desired value (string) are not the same.

DSC configuration

SPFarmPropertyBas DisableIntranetCalls
{
    Key = 'disableIntranetCalls'
    Value = 'False'
    Ensure = 'Present'
}

Suggested solution

Add the possibility to specify other types

SharePoint version and build

All

Operating system the target node is running

All

PowerShell version and build the target node is running

v5.1

SharePointDsc version

Dev
ykuijs commented 2 years ago

Fix is implemented and will be merged in my next Bugfix PR

ykuijs commented 2 years ago

With this fix you will be able to specify the type of the data in the Value parameter:


SPFarmPropertyBag 'DisableIntranetCalls'
{
    Key                  = 'disableIntranetCalls'
    Value                = 'False'
    ParameterType        = 'Boolean'
    Ensure               = 'Present'
    PsDscRunAsCredential = $SPSetupAccount
}