diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e6491d7..32f21b580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,9 @@ - Now it correctly tests passwords when parameter DomainName is set to distinguished name and parameter Credential is used ([issue #451](https://github.com/PowerShell/ActiveDirectoryDsc/issues/451)). - Added integration tests ([issue #359](https://github.com/PowerShell/ActiveDirectoryDsc/issues/359)). + - Update the logic for setting the default value for the parameter + `CommonName`. This is due to an how LCM handles parameters when a + default value is derived from another parameter ([issue #427](https://github.com/PowerShell/ActiveDirectoryDsc/issues/427)). - Changes to ADDomain - BREAKING CHANGE: Renamed the parameter `DomainAdministratorCredential` to `Credential` to better indicate that it is possible to impersonate diff --git a/DSCResources/MSFT_ADUser/MSFT_ADUser.psm1 b/DSCResources/MSFT_ADUser/MSFT_ADUser.psm1 index 6a9817a60..d6fc72061 100644 --- a/DSCResources/MSFT_ADUser/MSFT_ADUser.psm1 +++ b/DSCResources/MSFT_ADUser/MSFT_ADUser.psm1 @@ -460,7 +460,7 @@ function Get-TargetResource [Parameter()] [ValidateNotNull()] [System.String] - $CommonName = $UserName, + $CommonName, [Parameter()] [ValidateNotNull()] @@ -734,6 +734,15 @@ function Get-TargetResource $ProxyAddresses ) + <# + This is a workaround to make the resource able to enter debug mode. + For more information see issue https://github.com/PowerShell/ActiveDirectoryDsc/issues/427. + #> + if (-not $PSBoundParameters.ContainsKey('CommonName')) + { + $CommonName = $UserName + } + Assert-Module -ModuleName 'ActiveDirectory' try @@ -1107,7 +1116,7 @@ function Test-TargetResource [Parameter()] [ValidateNotNull()] [System.String] - $CommonName = $UserName, + $CommonName, [Parameter()] [ValidateNotNull()] @@ -1381,6 +1390,15 @@ function Test-TargetResource $ProxyAddresses ) + <# + This is a workaround to make the resource able to enter debug mode. + For more information see issue https://github.com/PowerShell/ActiveDirectoryDsc/issues/427. + #> + if (-not $PSBoundParameters.ContainsKey('CommonName')) + { + $CommonName = $UserName + } + Assert-Parameters @PSBoundParameters $targetResource = Get-TargetResource @PSBoundParameters @@ -1723,7 +1741,7 @@ function Set-TargetResource [Parameter()] [ValidateNotNull()] [System.String] - $CommonName = $UserName, + $CommonName, [Parameter()] [ValidateNotNull()] @@ -1997,6 +2015,15 @@ function Set-TargetResource $ProxyAddresses ) + <# + This is a workaround to make the resource able to enter debug mode. + For more information see issue https://github.com/PowerShell/ActiveDirectoryDsc/issues/427. + #> + if (-not $PSBoundParameters.ContainsKey('CommonName')) + { + $CommonName = $UserName + } + Assert-Parameters @PSBoundParameters $targetResource = Get-TargetResource @PSBoundParameters