ActiveDirectoryDsc
ActiveDirectoryDsc copied to clipboard
ADDomainController: Test method does not check all values
Test-TargetResource has some issues.
- It does not look for properties SysvolPath, LogPath and DatabasePath
- It throws an exception if the site name is wrong instead of returning a bool
- Provided a non-existing path still returns true
Test-TargetResource -DomainName contoso.com -DomainAdministratorCredential $cred -SafemodeAdministratorPassword $cred -DatabasePath C:\WrongPath -SiteName Default-First-Site-Name
True
- Providing a non-existing site throws an exception and does not return a bool
Test-TargetResource -DomainName contoso.com -DomainAdministratorCredential $cred -SafemodeAdministratorPassword $cred -DatabasePath C:\WrongPath -SiteName WrongSite
Site 'WrongSite' could not be found.
At line:196 char:13
+ throw (New-Object -TypeName System.InvalidOperationExcept ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], InvalidOperationException
+ FullyQualifiedErrorId : Site 'WrongSite' could not be found.
SysvolPath, LogPath and DatabasePath not being detected are valid points.
But I'm not sure about wrong site name. If Test-TargetResource
won't catch it you'll get an error later when Set-TargetResource
kicks in for example.
Can you move all of the paths after a machine has been promoted? If they cannot be moved easily, then I suggest we document this rather than try to implement it.
Doesn't look particularly easy 😢
- https://support.microsoft.com/en-us/help/842162/how-to-relocate-the-sysvol-tree-on-a-domain-controller-that-is-running-nt-file-replication-service-for-sysvol
- https://technet.microsoft.com/en-us/library/cc816594%28v=ws.10%29.aspx
I could see implementing a check to make sure the path is passed can be created if it doesn't exist. But as long as it is a valid path meaning the drive letter exists, then it will create those files in that location.