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

ADObjectPermissionEntry: Cannot find drive. A drive with the name 'AD' does not exist #547

Closed
shurick81 opened this issue Jan 15, 2020 · 15 comments · Fixed by #565
Closed
Labels
bug The issue is a bug.

Comments

@shurick81
Copy link
Contributor

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

I am trying to apply permissions to an OU and getting get an error when applying the configuration with Start-DscConfiguration

Verbose logs showing the problem

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 AD01 with user sid S-1-5-21-3638333018-712442695-4229731031-1001.
VERBOSE: [AD01]: LCM:  [ Start  Set      ]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADUser]CRMInstallAccountUser]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADUser]CRMInstallAccountUser]
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Retrieving Active Directory user
'_crmadmin' ([email protected]). (ADU0004)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Active Directory user '_crmadmin'
([email protected]) was NOT present. (ADU0008)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Creating connection to Active Directory
domain 'contoso.local'. (ADU0005)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Missing the type
'System.DirectoryServices.AccountManagement.PrincipalContext' from the PowerShell session. (ADCOMMON0044)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Adding the assembly
'System.DirectoryServices.AccountManagement' into the PowerShell session. (ADCOMMON0045)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Checking Active Directory user '_crmadmin'
password. (ADU0006)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] User 'Password' property is NOT in the
desired state. Expected '<Password>', actual '<Password>'. (ADU0009)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] User 'PasswordNeverExpires' property is NOT
 in the desired state. Expected 'True', actual ''. (ADU0009)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] User 'Ensure' property is NOT in the
desired state. Expected 'Present', actual 'Absent'. (ADU0009)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] User 'Enabled' property is NOT in the
desired state. Expected 'True', actual ''. (ADU0009)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADUser]CRMInstallAccountUser]  in 0.4480 seconds.
VERBOSE: [AD01]: LCM:  [ Start  Set      ]  [[ADUser]CRMInstallAccountUser]
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Retrieving Active Directory user
'_crmadmin' ([email protected]). (ADU0004)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Active Directory user '_crmadmin'
([email protected]) was NOT present. (ADU0008)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Adding Active Directory user '_crmadmin'.
(ADU0010)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Retrieving Active Directory user
'_crmadmin' ([email protected]). (ADU0004)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Active Directory user '_crmadmin'
([email protected]) is present. (ADU0007)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Creating connection to Active Directory
domain 'contoso.local'. (ADU0005)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] The type
'System.DirectoryServices.AccountManagement.PrincipalContext' is already loaded into the PowerShell session.
(ADCOMMON0043)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Checking Active Directory user '_crmadmin'
password. (ADU0006)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Setting Active Directory user password.
(ADU0013)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Updating user property
'PasswordNeverExpires' with/to 'True'. (ADU0014)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Updating user property 'Enabled' with/to
'True'. (ADU0014)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Updating Active Directory user '_crmadmin'.
 (ADU0012)
VERBOSE: [AD01]: LCM:  [ End    Set      ]  [[ADUser]CRMInstallAccountUser]  in 0.5880 seconds.
VERBOSE: [AD01]: LCM:  [ End    Resource ]  [[ADUser]CRMInstallAccountUser]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADOrganizationalUnit]CRMGroupsOU]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADOrganizationalUnit]CRMGroupsOU]
VERBOSE: [AD01]:                            [[ADOrganizationalUnit]CRMGroupsOU] Retrieving OU 'CRM groups' from path
'DC=contoso,DC=local'. (ADOU0001)
VERBOSE: [AD01]:                            [[ADOrganizationalUnit]CRMGroupsOU] OU 'CRM groups' does not exist when it
should exist. (ADOU0009)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADOrganizationalUnit]CRMGroupsOU]  in 0.0930 seconds.
VERBOSE: [AD01]: LCM:  [ Start  Set      ]  [[ADOrganizationalUnit]CRMGroupsOU]
VERBOSE: [AD01]:                            [[ADOrganizationalUnit]CRMGroupsOU] Retrieving OU 'CRM groups' from path
'DC=contoso,DC=local'. (ADOU0001)
VERBOSE: [AD01]:                            [[ADOrganizationalUnit]CRMGroupsOU] Creating OU 'CRM groups'. (ADOU0004)
VERBOSE: [AD01]: LCM:  [ End    Set      ]  [[ADOrganizationalUnit]CRMGroupsOU]  in 0.1080 seconds.
VERBOSE: [AD01]: LCM:  [ End    Resource ]  [[ADOrganizationalUnit]CRMGroupsOU]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADGroup]CRMPrivUserGroup]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADGroup]CRMPrivUserGroup]
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] AD Group 'CRM01PrivUserGroup' was not found.
(ADG00010)
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] AD Group 'GroupScope' is not correct. Expected
'Universal', actual ''. (ADG0011)
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] AD Group 'Path' is not correct. Expected
'OU=CRM groups,DC=contoso,DC=local', actual ''. (ADG0011)
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] Group membership is NOT in the desired state.
(ADG0002)
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] AD Group 'Ensure' is not correct. Expected
'Present', actual 'Absent'. (ADG0011)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADGroup]CRMPrivUserGroup]  in 0.1860 seconds.
VERBOSE: [AD01]: LCM:  [ Start  Set      ]  [[ADGroup]CRMPrivUserGroup]
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] AD Group 'CRM01PrivUserGroup' was not found.
(ADG00010)
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] Creating AD Group 'CRM01PrivUserGroup'.
(ADG0005)
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] Adding '1' member(s) to AD group
'CRM01PrivUserGroup'. (ADG0003)
VERBOSE: [AD01]: LCM:  [ End    Set      ]  [[ADGroup]CRMPrivUserGroup]  in 0.2010 seconds.
VERBOSE: [AD01]: LCM:  [ End    Resource ]  [[ADGroup]CRMPrivUserGroup]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADObjectPermissionEntry]OUPermissions]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADObjectPermissionEntry]OUPermissions]
VERBOSE: [AD01]:                            [[ADObjectPermissionEntry]OUPermissions] Creating new AD: PSDrive.
(ADCOMMON0032)
VERBOSE: [AD01]:                            [[ADObjectPermissionEntry]OUPermissions] Object permission entry not found
on object 'OU=CRM groups,DC=contoso,DC=local'. (OPE0002)
VERBOSE: [AD01]:                            [[ADObjectPermissionEntry]OUPermissions] Object permission entry on object
'OU=CRM groups,DC=contoso,DC=local' is not in the desired state. (OPE0006)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADObjectPermissionEntry]OUPermissions]  in 0.2470 seconds.
VERBOSE: [AD01]: LCM:  [ End    Set      ]
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.446 seconds
01/15/2020 12:13:10 Testing DSC
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 AD01 with user sid S-1-5-21-3638333018-712442695-4229731031-1001.
VERBOSE: [AD01]: LCM:  [ Start  Compare  ]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADUser]CRMInstallAccountUser]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADUser]CRMInstallAccountUser]
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Retrieving Active Directory user
'_crmadmin' ([email protected]). (ADU0004)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Active Directory user '_crmadmin'
([email protected]) is present. (ADU0007)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Creating connection to Active Directory
domain 'contoso.local'. (ADU0005)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] The type
'System.DirectoryServices.AccountManagement.PrincipalContext' is already loaded into the PowerShell session.
(ADCOMMON0043)
VERBOSE: [AD01]:                            [[ADUser]CRMInstallAccountUser] Checking Active Directory user '_crmadmin'
password. (ADU0006)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADUser]CRMInstallAccountUser] True in 0.0460 seconds.
VERBOSE: [AD01]: LCM:  [ End    Resource ]  [[ADUser]CRMInstallAccountUser]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADOrganizationalUnit]CRMGroupsOU]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADOrganizationalUnit]CRMGroupsOU]
VERBOSE: [AD01]:                            [[ADOrganizationalUnit]CRMGroupsOU] Retrieving OU 'CRM groups' from path
'DC=contoso,DC=local'. (ADOU0001)
VERBOSE: [AD01]:                            [[ADOrganizationalUnit]CRMGroupsOU] OU 'CRM groups' exists and is in the
desired state. (ADOU0006)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADOrganizationalUnit]CRMGroupsOU] True in 0.0620 seconds.
VERBOSE: [AD01]: LCM:  [ End    Resource ]  [[ADOrganizationalUnit]CRMGroupsOU]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADGroup]CRMPrivUserGroup]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADGroup]CRMPrivUserGroup]
VERBOSE: [AD01]:                            [[ADGroup]CRMPrivUserGroup] Retrieving group membership based on
'SamAccountName' property. (ADG0001)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADGroup]CRMPrivUserGroup] True in 0.2930 seconds.
VERBOSE: [AD01]: LCM:  [ End    Resource ]  [[ADGroup]CRMPrivUserGroup]
VERBOSE: [AD01]: LCM:  [ Start  Resource ]  [[ADObjectPermissionEntry]OUPermissions]
VERBOSE: [AD01]: LCM:  [ Start  Test     ]  [[ADObjectPermissionEntry]OUPermissions]
VERBOSE: [AD01]:                            [[ADObjectPermissionEntry]OUPermissions] Object permission entry not found
on object 'OU=CRM groups,DC=contoso,DC=local'. (OPE0002)
VERBOSE: [AD01]:                            [[ADObjectPermissionEntry]OUPermissions] Object permission entry on object
'OU=CRM groups,DC=contoso,DC=local' is not in the desired state. (OPE0006)
VERBOSE: [AD01]: LCM:  [ End    Test     ]  [[ADObjectPermissionEntry]OUPermissions] False in 0.0620 seconds.
VERBOSE: [AD01]: LCM:  [ *FAILED*Compare  ]     Completed processing compare operation. The operation returned False.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 0.633 seconds
01/15/2020 12:13:11 Test failed


Stderr from the command:

Cannot find drive. A drive with the name 'AD' does not exist.
    + CategoryInfo          : ObjectNotFound: (AD:) [], CimException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetAclCommand
    + PSComputerName        : AD01

The PowerShell DSC resource '[ADObjectPermissionEntry]OUPermissions' with SourceInfo
'C:\tmp\vagrant-shell.ps1::80::13::ADObjectPermissionEntry' threw one or more non-terminating errors while running the
Test-TargetResource functionality. These errors are logged to the ETW channel called
Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : AD01

The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : AD01

Cannot find drive. A drive with the name 'AD' does not exist.
    + CategoryInfo          : ObjectNotFound: (AD:) [], CimException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetAclCommand
    + PSComputerName        : AD01

The PowerShell DSC resource '[ADObjectPermissionEntry]OUPermissions' with SourceInfo
'C:\tmp\vagrant-shell.ps1::80::13::ADObjectPermissionEntry' threw one or more non-terminating errors while running the
Test-TargetResource functionality. These errors are logged to the ETW channel called
Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : AD01

Suggested solution to the issue

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

Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName ActiveDirectoryDsc -ModuleVersion 5.0.0

$domainName = "contoso.local";

Node $AllNodes.NodeName
{

    ADUser CRMInstallAccountUser
    {
        DomainName              = $domainName
        UserName                = $CRMInstallAccountCredential.GetNetworkCredential().UserName
        Password                = $CRMInstallAccountCredential
        PasswordNeverExpires    = $true
    }
    
    ADOrganizationalUnit CRMGroupsOU
    {
        Name = "CRM groups"
        Path = "DC=contoso,DC=local"
    }

    ADGroup CRMPrivUserGroup
    {
        GroupName           = "CRM01PrivUserGroup"
        MembersToInclude    = $CRMInstallAccountCredential.GetNetworkCredential().UserName
        GroupScope          = "Universal"
        Path                = 'OU=CRM groups,DC=contoso,DC=local'
        DependsOn           = "[ADOrganizationalUnit]CRMGroupsOU", "[ADUser]CRMInstallAccountUser"
    }
    
    ADObjectPermissionEntry OUPermissions
    {
        Ensure                              = 'Present'
        Path                                = 'OU=CRM groups,DC=contoso,DC=local'
        IdentityReference                   = 'contoso\CRM01PrivUserGroup'
        ActiveDirectoryRights               = 'GenericAll'
        AccessControlType                   = 'Allow'
        ObjectType                          = '00000000-0000-0000-0000-000000000000'
        ActiveDirectorySecurityInheritance  = 'All'
        InheritedObjectType                 = '00000000-0000-0000-0000-000000000000'
        DependsOn                           = "[ADGroup]CRMPrivUserGroup"
    }

}

The operating system the target node is running

OsName : Microsoft Windows Server 2016 Standard Evaluation
OsOperatingSystemSKU : 79
OsArchitecture : 64-bit
WindowsBuildLabEx : 14393.0.amd64fre.rs1_release.160715-1616
OsLanguage : en-US
OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

Name Value


PSVersion 5.1.14393.0
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.0
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

@X-Guardian
Copy link
Contributor

Hi @shurick81, thanks for raising this issue. I have tested your configuration and am not getting this error in my lab.
The ADObjectPermissionEntry resource uses the Set-ACL/ Get-ACL cmdlets and the AD PSDrive which should be created when the ActiveDirectory module is loaded by Dsc. We have seen issues before whereby sometimes the AD PSDrive is not created, and we have previously added code to check for this, but it looks like you are hitting another scenario.

Can you therefore provide more information on how you are running this, (locally on a DC or remote etc) and also whether you are able to recreate the error every time. Also, are you creating any other resources within the same Dsc other than the ones you have listed, as your Dsc configuration is not complete?

@X-Guardian X-Guardian added the waiting for author response The pull request is waiting for the author to respond to comments in the pull request. label Jan 15, 2020
@shurick81
Copy link
Contributor Author

Hi, thanks for prompt reply. The way I excute this config is basically running this script:

$configName = "CRMDomainCustomizations"
Write-Host "$(Get-Date) Defining DSC"
try
{
    Configuration $configName
    {
        param(
            [Parameter(Mandatory=$true)]
            [ValidateNotNullorEmpty()]
            [PSCredential]
            $CRMInstallAccountCredential
        )
        Import-DscResource -ModuleName PSDesiredStateConfiguration
        Import-DscResource -ModuleName ActiveDirectoryDsc -ModuleVersion 5.0.0

        $domainName = "contoso.local";

        Node $AllNodes.NodeName
        {

            ADUser CRMInstallAccountUser
            {
                DomainName              = $domainName
                UserName                = $CRMInstallAccountCredential.GetNetworkCredential().UserName
                Password                = $CRMInstallAccountCredential
                PasswordNeverExpires    = $true
            }
            
            ADOrganizationalUnit CRMGroupsOU
            {
               Name = "CRM groups"
               Path = "DC=contoso,DC=local"
            }

            ADGroup CRMPrivUserGroup
            {
                GroupName           = "CRM01PrivUserGroup"
                MembersToInclude    = $CRMInstallAccountCredential.GetNetworkCredential().UserName
                GroupScope          = "Universal"
                Path                = 'OU=CRM groups,DC=contoso,DC=local'
                DependsOn           = "[ADOrganizationalUnit]CRMGroupsOU", "[ADUser]CRMInstallAccountUser"
            }
            
            ADObjectPermissionEntry OUPermissions
            {
                Ensure                              = 'Present'
                Path                                = 'OU=CRM groups,DC=contoso,DC=local'
                IdentityReference                   = 'contoso\CRM01PrivUserGroup'
                ActiveDirectoryRights               = 'GenericAll'
                AccessControlType                   = 'Allow'
                ObjectType                          = '00000000-0000-0000-0000-000000000000'
                ActiveDirectorySecurityInheritance  = 'All'
                InheritedObjectType                 = '00000000-0000-0000-0000-000000000000'
                DependsOn                           = "[ADGroup]CRMPrivUserGroup"
            }
        
        }
    }
}
catch
{
    Write-Host "$(Get-Date) Exception in defining DCS:"
    $_.Exception.Message
    Exit 1;
}
$configurationData = @{ AllNodes = @(
    @{ NodeName = $env:COMPUTERNAME; PSDscAllowPlainTextPassword = $True; PsDscAllowDomainUser = $True }
) }

$securedPassword = ConvertTo-SecureString "c0tmp1Expa~~" -AsPlainText -Force
$CRMInstallAccountCredential = New-Object System.Management.Automation.PSCredential( "contoso\_crmadmin", $securedPassword );
Write-Host "$(Get-Date) Compiling DSC"
try
{
    &$configName `
        -ConfigurationData $configurationData `
        -CRMInstallAccountCredential $CRMInstallAccountCredential;
}
catch
{
    Write-Host "$(Get-Date) Exception in compiling DCS:";
    $_.Exception.Message
    Exit 1;
}
Write-Host "$(Get-Date) Starting DSC"
try
{
    Start-DscConfiguration $configName -Verbose -Wait -Force;
}
catch
{
    Write-Host "$(Get-Date) Exception in starting DCS:"
    $_.Exception.Message
    Exit 1;
}
if ( $env:VMDEVOPSSTARTER_NODSCTEST -ne "TRUE" )
{
    Write-Host "$(Get-Date) Testing DSC"
    try {
        $result = Test-DscConfiguration $configName -Verbose;
        $inDesiredState = $result.InDesiredState;
        $failed = $false;
        $inDesiredState | % {
            if ( !$_ ) {
                Write-Host "$(Get-Date) Test failed"
                Exit 1;
            }
        }
    }
    catch {
        Write-Host "$(Get-Date) Exception in testing DCS:"
        $_.Exception.Message
        Exit 1;
    }
} else {
    Write-Host "$(Get-Date) Skipping tests"
}
Exit 0;

@shurick81
Copy link
Contributor Author

shurick81 commented Jan 15, 2020

Actually, when I am running it just like this on the AD01 machine in console, it works. The condition that I get error from is that I run it with Vagrant remotely, I guess. I will get back with further details later.

@X-Guardian X-Guardian added needs more information The issue needs more information from the author or the community. and removed waiting for author response The pull request is waiting for the author to respond to comments in the pull request. labels Jan 15, 2020
@shurick81
Copy link
Contributor Author

Here's what I found. It does not matter if I execute it remotely or not.

When I run it like this, it works:

  1. Domain creation with the following configuration:
        $domainName = "contoso.local";

        Node $AllNodes.NodeName
        {

            ADDomain ADDomain
            {
                DomainName                      = $domainName
                SafemodeAdministratorPassword   = $domainSafeModeAdministratorPasswordCredential
                Credential                      = $shortDomainAdminCredential
            }
  1. machine reboot
  2. domain validation with the same code as above
  3. pause 60 seconds
  4. OU creation with permissions customizations (as per my opening message in this thread)

However, if I don't do pause and run the configuration immediately, it throws the error

@X-Guardian
Copy link
Contributor

If you are creating the domain as part of the same DSC configuration, you need to use the WaitForADDomain resource before any other AD resources to make sure the domain is fully up and ready to accept connections.

@shurick81
Copy link
Contributor Author

Hi, I'm not creating the docmain as part of the same DSC configuration and not even as part of the same PS session.
Anyway, I tried to use WaitForADDomain before running other resources and that did not make a difference. So the only case I made it working was making a pause before running the script with ADObjectPermissionEntry.

@X-Guardian
Copy link
Contributor

Ok, but you are creating the domain as part of the same 'process', whatever that may be, (set of scripts etc), so it is most probably a timing issue between the creation of the domain and applying the ADObjectPermissionEntry resource. If you want to post the DSC configuration and verbose logging that includes the WaitForADDomain and ADObjectPermissionEntry resource, I'll try and help.

@shurick81
Copy link
Contributor Author

shurick81 commented Jan 20, 2020

Ok, let me be more specific
I temporary set variable "VMDEVOPSSTARTER_NODSCTEST:TRUE" and run the following script:
https://github.com/shurick81/vm-devops-starter/blob/76f63f2a2b8a38701879257bbd772597332ee9d0/infrastructure/stacks/domain.ps1

Then as soon as it is finished, I restart the machine, then as soon as winrm is available again, I run the same script again, but this time I don't set this varialbe:
https://github.com/shurick81/vm-devops-starter/blob/76f63f2a2b8a38701879257bbd772597332ee9d0/infrastructure/stacks/domain.ps1
As soon as this script is executed, I run this:
https://github.com/shurick81/vm-devops-starter/blob/76f63f2a2b8a38701879257bbd772597332ee9d0/infrastructure/stacks/crmdomaincustomizations.ps1 which fails with the error above.

As you suggested, I tried to add WaitForADDomain in domain.ps1 but it did not make any difference. What I've imperically found as a temporary solution is running Start-Sleep 60 before running crmdomaincustomizations.ps1. I hope this helps. Let me know if you need more info.

@X-Guardian
Copy link
Contributor

Hi @shurick81, I need to be able to see the DSC configuration and verbose logging that includes the WaitForADDomain and ADObjectPermissionEntry resource to investigate this further.

@shurick81
Copy link
Contributor Author

@X-Guardian
Copy link
Contributor

Hi @shurick81, can you post the raw DSC logs from the run, rather than the vagrant script output? You can find these on the target server in 'C:\Windows\System32\Configuration\ConfigurationStatus' with a suffix of 'details.json'. Reason being as it is not clear from the script output exactly when the exception is occurring and it will be clearer from the raw DSC logs.

@shurick81
Copy link
Contributor Author

shurick81 commented Feb 6, 2020

Here's the output from the console itself, when I run manually, without vagrant: https://gist.github.com/shurick81/f6d7a1e19748d26449c977d5988a8a86

Here's the contents of 'C:\Windows\System32\Configuration\ConfigurationStatus{BB5B9146-48D7-11EA-9DF9-080027009DD1}-0.details.json' file: https://gist.github.com/shurick81/077c3d3f4ca32a472a745b5a55837675

Here's the contents of 'C:\Windows\System32\Configuration\ConfigurationStatus{BB5B9146-48D7-11EA-9DF9-080027009DD1}-0.mof' file: https://gist.github.com/shurick81/b6467d3c38038df7eb1c8229bf8d8b61

@X-Guardian
Copy link
Contributor

OK, that's better. I can now see that it is attempting to create a new AD: PSDrive at the Test stage of the [[ADObjectPermissionEntry]OUPermissions] resource but looks like it is silently failing. We are going to need to manually add some debugging output to the resource to investigate this further. Are you ok to work with me on this?

@shurick81
Copy link
Contributor Author

Yes, if you mean authoring source code of DSC module, it would be great for me to gain some hands on experience, I'm ready.

@X-Guardian
Copy link
Contributor

Great, shall we chat on the PowerShell Slack channel: http://slack.poshcode.org.

shurick81 added a commit to shurick81/ActiveDirectoryDsc that referenced this issue Feb 8, 2020
shurick81 added a commit to shurick81/ActiveDirectoryDsc that referenced this issue Feb 8, 2020
X-Guardian pushed a commit that referenced this issue Feb 8, 2020
@X-Guardian X-Guardian added bug The issue is a bug. and removed needs more information The issue needs more information from the author or the community. labels Feb 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
Development

Successfully merging a pull request may close this issue.

2 participants