Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Error when deploying a HostedContentFilterPolicy

Open RuudGijsbers opened this issue 5 years ago • 5 comments

Hi,

When I apply my HostedContentFilterPolicy configuration to my tenant, I see a non terminating error in the logs: Cannot find an overload for "Contains" and the argument count: "1"

After the error I looked it up in the module file and noticed that there are 2 if statements which check if the policy contains the EndUserSpamNotificationCustomFromAddress setting. I expect that the second if needs to check for EndUserSpamNotificationCustomFromName Can someone have a look at it, or can I fork a copy of the module, change the setting and create a pull request for it?

https://github.com/microsoft/Microsoft365DSC/blob/0e5afdedef22d9a96d5118821359a1d5090c0309/Modules/Microsoft365DSC/DSCResources/MSFT_EXOHostedContentFilterPolicy/MSFT_EXOHostedContentFilterPolicy.psm1#L659-L669

RuudGijsbers avatar Apr 08 '21 09:04 RuudGijsbers

Feel free to create a pull request that fixes it

Swampen avatar Apr 09 '21 20:04 Swampen

It looks lik it's not solved by only making this change. I'll look into it.

RuudGijsbers avatar Apr 17 '21 12:04 RuudGijsbers

Added a PR that fixes this

Swampen avatar Apr 17 '21 15:04 Swampen

During the Get-TargetResource $PSBoundParameters is already defined as Hashtable, so i'm not sure if it will fix it.: function Get-TargetResource { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] param

In another issue it was mentioned that not all parameters are removed during Set: $HostedContentFilterPolicyParams = $PSBoundParameters $HostedContentFilterPolicyParams.Remove('Ensure') | Out-Null $HostedContentFilterPolicyParams.Remove('GlobalAdminAccount') | Out-Null $HostedContentFilterPolicyParams.Remove('MakeDefault') | Out-Null $HostedContentFilterPolicyParams.Remove('ApplicationId') | Out-Null $HostedContentFilterPolicyParams.Remove('TenantId') | Out-Null $HostedContentFilterPolicyParams.Remove('CertificateThumbprint') | Out-Null $HostedContentFilterPolicyParams.Remove('CertificatePath') | Out-Null $HostedContentFilterPolicyParams.Remove('CertificatePassword') | Out-Null So i was thinking to add the last 5 rules.

RuudGijsbers avatar Apr 17 '21 15:04 RuudGijsbers

Get-TargetResource and Set-TargetResource is not related in that regard. The OutputType only defines what type of object the function returns. Like I mentioned in my PR, the HostedContentFilterPolicyParams was an System.Management.Automation.PSBoundParametersDictionary object. I added a verbose log wil .GetType() locally in my module, and that is what I got. After changing it to a Hashtable, the Set-TargetResource succeded.

Adding the last 5 rules will not fix the error with Cannot find an overload for "Contains" and the argument count: "1", but it maybe should have been implemented? Not sure if that is intended or just simply being overlooked.

Swampen avatar Apr 17 '21 16:04 Swampen