dsccommunity / ActiveDirectoryDsc

This module contains DSC resources for deployment and configuration of Active Directory Domain Services.
MIT License
345 stars 142 forks source link

AdUser: Add ability to show non-key values within Test-DSCConfiguration *DesiredState* properties #693

Closed albvar closed 2 years ago

albvar commented 2 years ago

I leverage Test-DSCConfiguration in scenarios where I don't trust the source of the data being fed to AdUser. Test-DSCConfiguration is being used to further build this trust.

Please feel free to change the subject of this topic as I am not sure what the correct technical term should be. Currently when running Test-DSCConfiguration on a resource tied to ADUser I can only see the values tied to keys within the ADUser schema. Being able to see non-key properties within *DesiredState* (output from Test-DSCConfiguration) would be beneficial in certain use cases. I am interested in understanding this limitation further. If this limitation lies in the DSC implementation and there is an opportunity to share additional context/information please consider doing so.

Example below

Verbose output from Test-DSCConfiguration

VERBOSE: [ABC-CONTOSO01]: LCM:  [ Start  Compare  ]
VERBOSE: [ABC-CONTOSO01]: LCM:  [ Start  Resource ]  [[ADUser]ABCNOSE\simone.niccol]
VERBOSE: [ABC-CONTOSO01]: LCM:  [ Start  Test     ]  [[ADUser]ABCNOSE\simone.niccol]
VERBOSE: [ABC-CONTOSO01]:                            [[ADUser]ABCNOSE\simone.niccol] Retrieving 'simone.niccol' from domain 'ABC.local'. (ADU0004)
VERBOSE: [ABC-CONTOSO01]:                            [[ADUser]ABC\simone.niccol] 'simone.niccol' is present in domain 'ABC.local'. (ADU0007)
VERBOSE: [ABC-CONTOSO01]:                            [[ADUser]ABC\simone.niccol] 'JobTitle' property is NOT in the desired state. Expected 'Supermarket Managers', actual 'Supermarket Manager'. (ADU0013)
VERBOSE: [ABC-CONTOSO01]:                            [[ADUser]ABC\simone.niccol] 'simone.niccol' is not in the desired state. (ADU0010)
VERBOSE: [ABC-CONTOSO01]: LCM:  [ End    Test     ]  [[ADUser]ABC\simone.niccol] False in 2.7960 seconds.
VERBOSE: [ABC-CONTOSO01]: LCM:  [ End    Resource ]  [[ADUser]ABC\simone.niccol]

Output from Test-DSCConfiguration ResourcesNotInDesiredState

ConfigurationName    : CreateUserAndManagePassword
DependsOn            : 
ModuleName           : ActiveDirectoryDsc
ModuleVersion        : 6.2.0
PsDscRunAsCredential : 
ResourceId           : [ADUser]ABC\simone.niccol
SourceInfo           : ::2::2::ADUser
DurationInSeconds    : 2.798
Error                : 
FinalState           : 
InDesiredState       : False
InitialState         : 
InstanceName         : ABC\simone.niccol
RebootRequested      : False
ResourceName         : ADUser
StartDate            : 6/3/2022 1:54:32 PM
PSComputerName       : ABC-CONTOSO01
johlju commented 2 years ago

That is not supported by the command Test-DscConfigration. What you looking for is that the resource supports Reason from the Get() (or Get-TargetResource) of the resource so that when you run Get-DscConfiguration the resource outputs which properties are not in desired state and why. See more information in the article https://docs.microsoft.com/en-us/powershell/dsc/concepts/resources?view=dsc-3.0. But for this to work the resource have had to implement it, and since it is rather new, no resource in the module are currently doing it.

For now you can run Get-DscConfiguration, or you can run the Invoke-DscResource with the method Get, to get the content for each property and then match it yourself to the expected values.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity from the community in the last 30 days. It will be closed if no further activity occurs within 10 days. If the issue is labelled with any of the work labels (e.g bug, enhancement, documentation, or tests) then the issue will not auto-close.

stale[bot] commented 2 years ago

This issue has been automatically closed because it is has not had activity from the community in the last 40 days.