dsccommunity / SecurityPolicyDsc

A wrapper around secedit.exe to configure local security policies
MIT License
177 stars 53 forks source link

UserRightsAssignment: A resource conflict occurs when trying to remove and add Identities in the same configuration #118

Open jcwalker opened 5 years ago

jcwalker commented 5 years ago

Details of the scenario you tried and the problem that is occurring

A resource conflict occurs when trying to remove and add Identities in the same configuration

Verbose logs showing the problem

Test-ConflictingResources : A conflict was detected between resources '[UserRightsAssignment]LogOnAsService (C:\Users\Administrator\Documents\TestLogonAsService.ps1::7::9::UserRightsAssignment)' and '[UserRightsAssignment]LogOnAsService1 (C:\Users\Administrator\Documents\TestLogonAsService.ps1::14::9::UserRightsAssignment)' in node 'localhost'. Resources have identical key properties but there are differences in the following non-key properties: 'Ensure;Identity'. Values 'Present;User1' don't match values 'Absent;User2'. Please update these property values so that they are identical in both cases.

Suggested solution to the issue

Make Identity a Key property along with Policy

The DSC configuration that is used to reproduce the issue (as detailed as possible)

configuration testLogonAsService
{
    Import-DscResource -ModuleName SecurityPolicyDsc

    node localhost
    {
        UserRightsAssignment LogOnAsService
        {
            Ensure = 'Present'
            Policy = 'Log_on_as_a_service'
            Identity = 'User1'
        }
        UserRightsAssignment LogOnAsService1
        {
            Ensure = 'Absent'
            Policy = 'Log_on_as_a_service'
            Identity = 'User2'
        }
    }
}
testLogonAsService

The operating system the target node is running

OsName : Microsoft Windows Server 2012 R2 Standard OsOperatingSystemSKU : StandardServerEdition OsArchitecture : 64-bit WindowsBuildLabEx : 9600.18505.amd64fre.winblue_ltsb.160930-0600 OsLanguage : en-US OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

5.1

Version of the DSC module that was used ('dev' if using current dev branch)

2.8.0.0