You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Details of the scenario you tried and the problem that is occurring
If ManagedBy property cannot be resolved, then the code falls into the wrong path saying that the group does not exist.
Verbose logs showing the problem
Context When using configuration MSFT_ADGroup_UpdateGroup1_Config
WARNING: It is not recommended to use domain credential for node 'localhost'. In order to suppress the warning, you can add a property named 'PSDscAllowDomainUser' with a value of $true to your DSC configuration data for node 'localhost'.
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer DC01 with user sid S-1-5-21-530133819-3181352061-503517500-500.
VERBOSE: [DC01]: LCM: [ Start Set ]
VERBOSE: [DC01]: [DSCEngine] Importing the module C:\source\ActiveDirectoryDsc\DscResources\MSFT_ADGroup\MSFT_ADGroup.psm1 in force mode.
VERBOSE: [DC01]: LCM: [ Start Resource ] [[ADGroup]Integration_Test]
VERBOSE: [DC01]: LCM: [ Start Test ] [[ADGroup]Integration_Test]
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Importing the module MSFT_ADGroup in force mode.
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Retrieving group membership based on 'SamAccountName' property. (ADG0001)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] AD Group 'Description' is not correct. Expected 'A DSC description', actual ''. (ADG0011)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] AD Group 'DisplayName' is not correct. Expected 'DSC Group 1', actual ''. (ADG0011)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] AD Group 'ManagedBy' is not correct. Expected 'CONTOSO\Administrator', actual ''. (ADG0011)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] AD Group 'Notes' is not correct. Expected 'Notes for this group', actual ''. (ADG0011)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Group membership is NOT in the desired state. (ADG0002)
VERBOSE: [DC01]: LCM: [ End Test ] [[ADGroup]Integration_Test] in 0.5150 seconds.
VERBOSE: [DC01]: LCM: [ Start Set ] [[ADGroup]Integration_Test]
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Importing the module MSFT_ADGroup in force mode.
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Updating AD Group 'DscGroup1'. (ADG0006)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Updating AD Group property 'Description' to 'A DSC description'. (ADG0012)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Updating AD Group property 'DisplayName' to 'DSC Group 1'. (ADG0012)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Updating AD Group property 'ManagedBy' to 'CONTOSO\Administrator'. (ADG0012)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] AD Group 'DscGroup1' was not found. (ADG00010)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Updating AD Group property 'Notes' to 'Notes for this group'. (ADG0012)
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Adding '2' member(s) to AD group 'DscGroup1'. (ADG0003)
VERBOSE: [DC01]: LCM: [ End Set ] [[ADGroup]Integration_Test] in 1.3750 seconds.
VERBOSE: [DC01]: LCM: [ End Resource ] [[ADGroup]Integration_Test]
VERBOSE: [DC01]: LCM: [ End Set ]
VERBOSE: [DC01]: LCM: [ End Set ] in 2.7040 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 3.189 seconds
[+] Should compile and apply the MOF without throwing 3.52s
VERBOSE: An LCM method call arrived from computer DC01 with user sid S-1-5-21-530133819-3181352061-503517500-500.
VERBOSE: [DC01]: [DSCEngine] Importing the module C:\source\ActiveDirectoryDsc\DscResources\MSFT_ADGroup\MSFT_ADGroup.psm1 in force mode.
VERBOSE: [DC01]: LCM: [ Start Get ]
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Importing the module MSFT_ADGroup in force mode.
VERBOSE: [DC01]: [[ADGroup]Integration_Test] Retrieving group membership based on 'SamAccountName' property. (ADG0001)
VERBOSE: [DC01]: LCM: [ End Get ] [[ADGroup]Integration_Test] in 0.4380 seconds.
VERBOSE: [DC01]: LCM: [ End Get ] in 0.8440 seconds.
[+] Should be able to call Get-DscConfiguration without throwing 1.41s
[-] Should have set the resource and all the parameters should match 111ms
Expected 'CONTOSO\Administrator', but got $null.
456: $resourceCurrentState.ManagedBy | Should -Be $ConfigurationData.AllNodes.AdministratorUserName
at <ScriptBlock>, C:\source\ActiveDirectoryDsc\Tests\Integration\MSFT_ADGroup.Integration.Tests.ps1: line 456
Suggested solution to the issue
Refactor Set-TargetResource to correct use Get-TargetResource, then the existing try-block might be unnecessary. Instead a try-block can be added around the Set-ADObject when setting the property ManagedBy.
When ManagedBy fails to resolve the following error is thrown
PS > Set-ADGroup -Identity 'DscGroup1' -ManagedBy 'CONTOSO\Administrator'
Set-ADGroup : Identity info provided in the extended attribute: 'ManagedBy' could not be resolved. Reason: 'Cannot find
an object with identity: 'CONTOSO\Administrator' under: 'DC=contoso,DC=com'.'.
At line:1 char:1
+ Set-ADGroup -Identity 'DscGroup1' -Replace @{ Description = 'test'; ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (DscGroup1:ADGroup) [Set-ADGroup], ADIdentityResolutionException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityResolutionException
,Microsoft.ActiveDirectory.Management.Commands.SetADGroup
The DSC configuration that is used to reproduce the issue (as detailed as possible)
Version of the DSC module that was used ('dev' if using current dev branch)
dev
The text was updated successfully, but these errors were encountered:
johlju
added
bug
The issue is a bug.
help wanted
The issue is up for grabs for anyone in the community.
in progress
The issue is being actively worked on by someone.
and removed
help wanted
The issue is up for grabs for anyone in the community.
labels
Aug 31, 2019
johlju
added a commit
to johlju/ActiveDirectoryDsc
that referenced
this issue
Sep 1, 2019
- Changes to ActiveDirectoryDsc.Common
- Update helper function `Add-ADCommonGroupMember` to reduce duplicated
code, and add an evaluation if `Members` is empty.
- Updated helper function `Restore-ADCommonObject` to write out a verbose
message when no object was found in the recycle bin.
- Updated helper function `Assert-MemberParameters` to not throw an error
if the parameter `Members` is en empty array.
- Changes to ADGroup
- Added a read-only property `DistinguishedName`.
- Refactor the function `Set-TargetResource` to use the function
`Get-TargetResource` so that `Set-TargetResource` can correctly throw
an error when something goes wrong (issue #151, issue #166, issue #493).
- It is now possible to enforce a group with no members by using
`Members = @()` in a configuration (issue #189).
Details of the scenario you tried and the problem that is occurring
If
ManagedBy
property cannot be resolved, then the code falls into the wrong path saying that the group does not exist.Verbose logs showing the problem
Suggested solution to the issue
Refactor
Set-TargetResource
to correct useGet-TargetResource
, then the existingtry
-block might be unnecessary. Instead atry
-block can be added around theSet-ADObject
when setting the propertyManagedBy
.When
ManagedBy
fails to resolve the following error is thrownThe DSC configuration that is used to reproduce the issue (as detailed as possible)
The operating system the target node is running
Version and build of PowerShell the target node is running
Version of the DSC module that was used ('dev' if using current dev branch)
dev
The text was updated successfully, but these errors were encountered: