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
When trying to use EXODistributionGroup to create a resource without specifying 'Ensure', Test-TargetResource always returns True even if the resource doesn't exist
It looks like this is because Test-M365DSCParameterState is called with -DesiredValues $PSBoundParameters, which of course does not include parameters which have the 'default value' - therefore the value is not tested:
This seems to affect many resources using this template style (e.g. ADGroup)
Not sure the best way to fix. Perhaps $PSBoundParameters could be modified to always add Ensure = $Ensure?
Microsoft 365 DSC Version
dev
Which workloads are affected
Exchange Online
The DSC configuration
ConfigurationExample
{
param(
[Parameter()]
[System.String]
$ApplicationId,
[Parameter()]
[System.String]
$TenantId,
[Parameter()]
[System.String]
$CertificateThumbprint
)
Import-DscResource-ModuleName Microsoft365DSC
node localhost
{
EXODistributionGroup 'Distribution Group Name'
{
Alias ="DistributionGroupName";
Identity ="Distribution Group Name";
Name ="Distribution Group Name";
PrimarySmtpAddress ="[email protected]";
Type ='Security'
ApplicationId =$ApplicationId
TenantId =$TenantId
CertificateThumbprint =$CertificateThumbprint
}
}
}
Verbose logs showing the problem
VERBOSE: [HOSTNAME]: LCM: [ StartResource ] [[EXODistributionGroup]DistributionGroupName::[DomainController]HOSTNAME]
VERBOSE: [HOSTNAME]: LCM: [ StartTest ] [[EXODistributionGroup]DistributionGroupName::[DomainController]HOSTNAME]
VERBOSE: [HOSTNAME]: [[EXODistributionGroup]DistributionGroupName::[DomainController]HOSTNAME] Testing Distribution Group configuration for {Distribution Group Name}
VERBOSE: [HOSTNAME]: [[EXODistributionGroup]DistributionGroupName::[DomainController]HOSTNAME] Getting configuration of Distribution Group for Distribution Group Name
VERBOSE: [HOSTNAME]: [[EXODistributionGroup]DistributionGroupName::[DomainController]HOSTNAME] Current Values: Alias=DistributionGroupName
ApplicationId=***
CertificateThumbprint=***
Ensure=Absent
Identity=Distribution Group Name
Name=Distribution Group Name
PrimarySmtpAddress=DistributionGroupName@contoso.onmicrosoft.com
TenantId=***
Type=Security
Verbose=True
VERBOSE: [HOSTNAME]: [[EXODistributionGroup]DistributionGroupName::[DomainController]HOSTNAME] Target Values: Alias=DistributionGroupName
ApplicationId=***
CertificateThumbprint=***
Identity=Distribution Group Name
Name=Distribution Group Name
PrimarySmtpAddress=DistributionGroupName@contoso.onmicrosoft.com
TenantId=***
Type=Security
Verbose=True
VERBOSE: [HOSTNAME]: [[EXODistributionGroup]DistributionGroupName::[DomainController]HOSTNAME] Test-TargetResource returned True
Environment Information + PowerShell Version
OsName : Microsoft Windows Server 2019 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Key : PSVersion
Value : 5.1.17763.6189
Name : PSVersion
Key : PSEdition
Value : Desktop
Name : PSEdition
Key : PSCompatibleVersions
Value : {1.0,2.0,3.0,4.0...}
Name : PSCompatibleVersions
Key : BuildVersion
Value : 10.0.17763.6189
Name : BuildVersion
Key : CLRVersion
Value : 4.0.30319.42000
Name : CLRVersion
Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion
Key : PSRemotingProtocolVersion
Value : 2.3
Name : PSRemotingProtocolVersion
Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion
The text was updated successfully, but these errors were encountered:
Updating the $PSBoundParameters value in all resources would be quite the amount of work to put in. In other resources, we have the following check that exits early if the Ensure property is different:
if ($CurrentValues.Ensure-ne$Ensure)
{
Write-Verbose-Message "Test-TargetResource returned $false"return$false
}
Either we add the above check to the resources that don't have it, or we add the Ensure check with its default value Present to the Test-M365DSCParameterState function.
@NikCharlebois What do you think is the better approach? Personally, I would go for the second one, far simpler, much easier to achieve and affects all resources at once.
Description of the issue
When trying to use EXODistributionGroup to create a resource without specifying 'Ensure', Test-TargetResource always returns True even if the resource doesn't exist
It looks like this is because Test-M365DSCParameterState is called with -DesiredValues $PSBoundParameters, which of course does not include parameters which have the 'default value' - therefore the value is not tested:
Microsoft365DSC/Modules/Microsoft365DSC/DSCResources/MSFT_EXODistributionGroup/MSFT_EXODistributionGroup.psm1
Line 983 in ca59c6c
This seems to affect many resources using this template style (e.g. ADGroup)
Not sure the best way to fix. Perhaps $PSBoundParameters could be modified to always add Ensure = $Ensure?
Microsoft 365 DSC Version
dev
Which workloads are affected
Exchange Online
The DSC configuration
Verbose logs showing the problem
Environment Information + PowerShell Version
The text was updated successfully, but these errors were encountered: