Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADOrganizationalUnit: throws an exception when parent path does not yet exist #553

Closed
oliveirt opened this issue Feb 3, 2020 · 0 comments · Fixed by #559
Closed

ADOrganizationalUnit: throws an exception when parent path does not yet exist #553

oliveirt opened this issue Feb 3, 2020 · 0 comments · Fixed by #559
Assignees
Labels
bug The issue is a bug.

Comments

@oliveirt
Copy link
Contributor

oliveirt commented Feb 3, 2020

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

Where a configuration contains both a Parent Organziational Unit and a child of that Parent, it is not possible to successfully call either Get-TargetResource or Test-TargetResource, as they throw an exception where the Parent object doesn't exist.

Verbose logs showing the problem

VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = TestConfiguration,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer DC01 with user sid S-1-5-21-#######-########-########-1531.
VERBOSE: [DC01]: LCM: [ Start Compare ]
VERBOSE: [DC01]: LCM: [ Start Resource ] [[ADOrganizationalUnit]DoesNotYetExist]
VERBOSE: [DC01]: LCM: [ Start Test ] [[ADOrganizationalUnit]DoesNotYetExist]
VERBOSE: [DC01]: [[ADOrganizationalUnit]DoesNotYetExist] Retrieving OU 'DoesNotYetExist' from path 'DC=contoso,DC=com'. (ADOU0001)
VERBOSE: [DC01]: [[ADOrganizationalUnit]DoesNotYetExist] OU 'DoesNotYetExist' does not exist when it should exist. (ADOU0009)
VERBOSE: [DC01]: LCM: [ End Test ] [[ADOrganizationalUnit]DoesNotYetExist] False in 0.8910 seconds.
VERBOSE: [DC01]: LCM: [ End Resource ] [[ADOrganizationalUnit]DoesNotYetExist]
VERBOSE: [DC01]: LCM: [ Start Resource ] [[ADOrganizationalUnit]ChildA]
VERBOSE: [DC01]: LCM: [ Start Test ] [[ADOrganizationalUnit]ChildA]
VERBOSE: [DC01]: [[ADOrganizationalUnit]ChildA] Retrieving OU 'ChildA' from path 'OU=DoesNotYetExist,DC=contoso,DC=com'. (ADOU0001)
VERBOSE: [DC01]: LCM: [ End Test ] [[ADOrganizationalUnit]ChildA] False in 0.1560 seconds.
VERBOSE: [DC01]: LCM: [ FAILEDCompare ] Completed processing compare operation. The operation returned False.
PowerShell DSC resource MSFT_ADOrganizationalUnit failed to execute Test-TargetResource functionality with error message: System.Exception: The Path 'OU=DoesNotYetExist,DC=contoso,DC=com' was not found. (ADOU0011)
+ CategoryInfo : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.254 seconds

Suggested solution to the issue

The resource should be returned as being absent, rather than throw an exception.

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

Configuration testConfiguration {
    [CmdletBinding(SupportsShouldProcess=$false, PositionalBinding=$false)]
    param(
    )

    if (!$PSBoundParameters.ContainsKey('OutputPath')) {
        Throw "A OutputPath parameter is mandatory." 
    }

    if ($null -eq $Domain)
    { 
        $Domain = Get-ADDomain
    }

    Import-DscResource -ModuleName PSDesiredStateConfiguration
    Import-DscResource -ModuleName ActivedirectoryDsc

    ADOrganizationalUnit DoesNotYetExist
    {
        Name = "DoesNotYetExist"
        Path = $Domain.distinguishedName
        Ensure = 'Present'
    }

    ADOrganizationalUnit ChildA
    {
        Name = "ChildA"
        Path = ("OU=DoesNotYetExist," + $Domain.distinguishedName)
        Ensure = 'Present'
        DependsOn = '[ADOrganizationalUnit]DoesNotYetExist'
    }

    ADOrganizationalUnit ChildB
    {
        Name = "ChildB"
        Path = ("OU=DoesNotYetExist," + $Domain.distinguishedName)
        Ensure = 'Present'
        DependsOn = '[ADOrganizationalUnit]DoesNotYetExist'
    }
}

The operating system the target node is running

OsName : Microsoft Windows Server 2016 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
WindowsBuildLabEx : 14393.3442.amd64fre.rs1_release.191219-1727
OsLanguage : en-US
OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

PSVersion 5.1.14393.3383
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3383
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Version of the DSC module that was used

5.0.0

oliveirt added a commit to oliveirt/ActiveDirectoryDsc that referenced this issue Feb 3, 2020
oliveirt added a commit to oliveirt/ActiveDirectoryDsc that referenced this issue Feb 3, 2020
@X-Guardian X-Guardian added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Feb 5, 2020
oliveirt added a commit to oliveirt/ActiveDirectoryDsc that referenced this issue Feb 5, 2020
X-Guardian pushed a commit that referenced this issue Feb 7, 2020
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
3 participants