-
Notifications
You must be signed in to change notification settings - Fork 502
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
Resources using Test-M365DSCParameterState do not support default Ensure value when using -DesiredValues $PSBoundParameters #5085
Comments
Updating the 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 @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. |
@NikCharlebois Any thoughts on this? |
@NikCharlebois Checking in, what do you think of this? |
@FabienTschanz I'd put in a PR for option 2 and see what happens :) |
@Borgquite Agree. Should I add the implementation and open the PR or do you want to do it? |
@FabienTschanz If don't mind doing it, that would be really helpful :) |
Alright, I'll take a shot at it. Will report back once I have the PR ready. |
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: