Skip to content
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

SCRetentionCompliancePolicy TeamsChatLocation not enabled in the Tenant after creating Microsoft Teams Chat Standard Retention Policy/Rule via DSC #2472

Closed
atdheekurteshi opened this issue Oct 31, 2022 · 5 comments · Fixed by #2557 or #2584

Comments

@atdheekurteshi
Copy link

Details of the scenario you tried and the problem that is occurring

SCRetentionCompliancePolicy -Name 'Microsoft Teams Chat Standard Retention Policy' can be created with the following PS Code but the settings weren't applied correctly on the tenant:

PS C:\Windows\system32> Publish-DscConfiguration -Path C:\Users\src\MOFs\MainConfig -Force -Verbose
PS C:\Windows\system32> Start-DscConfiguration -UseExisting -Force -Verbose -Wait  

SCRetentionCompliancePolicy -Name 'Microsoft Teams Chat Standard Retention Policy' can be crated with -TeamsChatLocation 'All' attribute but it was not enabled on the Tenant via Microsoft365DSC.

In PowerShell when I run the following commands everything seems to be working fine for SCRetentionCompliancePolicy and i can see the changes in the Tenant and TeamsChatLocation its enabled:

PS C:\Windows\system32> New-RetentionCompliancePolicy -Name 'Microsoft Teams Chat Standard Retention Policy' -Comment 'abc' -Enabled:$false -RestrictiveRetention:$false -TeamsChatLocation 'All'

Name Workload                                                                    Enabled Mode
---- --------                                                                    ------- ----
Microsoft Teams Chat Standard Retention Policy Exchange, SharePoint, OneDriveForBusiness, Skype, ModernGroup, DynamicScope False   Enforce

PS C:\Windows\system32>

The DSC configuration that is used to reproduce the issue (as detailed as possible)

MOF file extract:

/*
@TargetNode='localhost'
@GeneratedBy=
@GenerationDate=
@GenerationHost=
*/

instance of MSFT_Credential as $MSFT_Credential2ref
{
Password = ""
UserName = "";
};

instance of MSFT_SCRetentionCompliancePolicy as $MSFT_SCRetentionCompliancePolicy2ref
{
ResourceID = "[SCRetentionCompliancePolicy]Container-107-7a9fb40b-94a8-42c4-96ae-08fcb8304d34";
 TeamsChatLocation = {
    "All"
};
 Enabled = False;
 Credential = $MSFT_Credential2ref;
 Ensure = "Present";
 Comment = "Standard Aufbewahrungsrichtlinie für Microsoft Teams Chat Protokolle";
 SourceInfo = "::20::3::SCRetentionCompliancePolicy";
 Name = "Microsoft Teams Chat Standard Retention Policy";
 ModuleName = "Microsoft365DSC";
 RestrictiveRetention = False;
 ModuleVersion = "1.22.1026.2";

 ConfigurationName = "MainConfig";

};

instance of MSFT_SCRetentionComplianceRule as $MSFT_SCRetentionComplianceRule2ref
{
ResourceID = "[SCRetentionComplianceRule]Container-110-f9a02134-4c19-4b97-8009-e8baaec2a7ab";
 ExpirationDateOption = "CreationAgeInDays";
 RetentionDurationDisplayHint = "Days";
 Ensure = "Present";
 RetentionDuration = "730";
 Policy = "Microsoft Teams Chat Standard Retention Policy";
 SourceInfo = "::52::3::SCRetentionComplianceRule";
 Name = "Microsoft Teams Chat Standard Retention Rule";
 ModuleName = "Microsoft365DSC";
 RetentionComplianceAction = "KeepAndDelete";
 Credential = $MSFT_Credential5ref;
 ModuleVersion = "1.22.1026.2";

 ConfigurationName = "MainConfig";

};

instance of OMI_ConfigurationDocument


                    {
 Version="2.0.0";
 

                        MinimumCompatibleVersion = "1.0.0";
 

                        CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
 

                        Author="";
 

                        GenerationDate=
 

                        GenerationHost="";


                        ContentType="PasswordEncrypted";
 

                        Name="MainConfig";


                    };
#### The operating system the target node is running
<!--
    Please provide as much as possible about the target node, for example
    edition, version, build and language.
    On OS with WMF 5.1 the following command can help get this information.

OsName               : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US, de-DE}

-->

#### Version of the DSC module that was used ('dev' if using current dev branch)
1.22.1026.2
@andikrueger andikrueger added Bug Something isn't working Teams V1.22.1026.2 Version 1.22.1026.2 labels Nov 2, 2022
@atdheekurteshi
Copy link
Author

Configuration MainConfig
{
    param
    (
         [Parameter(Mandatory = $true,Position=0)][ValidateNotNull()][System.Management.Automation.PSCredential]$AdminCred
    )
    Import-DscResource -ModuleName "Microsoft365DSC"
    Node localhost
    {
                SCRetentionCompliancePolicy Container-106-635eb06c-ee60-4ab5-8ed0-bacef7032821
                {
                        Comment = "Standard Aufbewahrungsfrist für Exchange Online 93 Tage";
                        Enabled = $False;
                        Ensure = "Present";
                        Name = "Exchange Online Standard Retention Policy";
                        ExchangeLocation = "All";
                        RestrictiveRetention = $False;
                        Credential = $AdminCred;
                }
                SCRetentionCompliancePolicy Container-107-13fc9a4b-bf6e-46fa-bdc9-8a9ad8d1f5da
                {
                        Comment = "Standard Aufbewahrungsrichtlinie für Microsoft Teams Chat Protokolle";
                        TeamsChatLocation = "All";
                        Enabled = $False;
                        Ensure = "Present";
                        Name = "Microsoft Teams Chat Standard Retention Policy";
                        RestrictiveRetention = $False;
                        Credential = $AdminCred;
                }
                SCRetentionCompliancePolicy Container-108-e155ed94-a351-41a5-ac01-b27e58825cf5
                {
                        Comment = "Standard Aufbewahrungsrichtlinie für Microsoft OneDrive";
                        Enabled = $True;
                        Ensure = "Present";
                        Name = "OneDrive Standard Retention Policy";
                        SharePointLocation = "All";
                        OneDriveLocation = "All";
                        RestrictiveRetention = $False;
                        Credential = $AdminCred;
                }
                SCRetentionComplianceRule Container-109-59c77f32-6990-49cf-b449-42f8ce637c46
                {
                        RetentionComplianceAction = "Keep";
                        ExpirationDateOption = "ModificationAgeInDays";
                        RetentionDurationDisplayHint = "Days";
                        Ensure = "Present";
                        RetentionDuration = "93";
                        Policy = "Exchange Online Standard Retention Policy";
                        Name = "Exchange Online Standard Retention Rule";
                        Credential = $AdminCred;
                }
                SCRetentionComplianceRule Container-110-4c097e33-a2a0-41c0-9536-db88d74d2c54
                {
                        RetentionComplianceAction = "KeepAndDelete";
                        ExpirationDateOption = "CreationAgeInDays";
                        RetentionDurationDisplayHint = "Days";
                        Ensure = "Present";
                        RetentionDuration = "730";
                        Policy = "Microsoft Teams Chat Standard Retention Policy";
                        Name = "Microsoft Teams Chat Standard Retention Rule";
                        Credential = $AdminCred;
                }
                SCRetentionComplianceRule Container-111-a1974584-3f18-4e58-8458-4433815c74b4
                {
                        RetentionComplianceAction = "Keep";
                        ExpirationDateOption = "ModificationAgeInDays";
                        RetentionDurationDisplayHint = "Days";
                        Ensure = "Present";
                        RetentionDuration = "93";
                        Policy = "OneDrive Standard Retention Policy";
                        Name = "OneDrive Standard Retention Rule";
                        Credential = $AdminCred;
                }
      }
}

@NikCharlebois
Copy link
Collaborator

I am trying to better understand the issue at hand. Let's say I am using the following config:

                SCRetentionCompliancePolicy Container-107-13fc9a4b-bf6e-46fa-bdc9-8a9ad8d1f5da
                {
                        Comment = "Standard Aufbewahrungsrichtlinie für Microsoft Teams Chat Protokolle";
                        TeamsChatLocation = "All";
                        Enabled = $False;
                        Ensure = "Present";
                        Name = "Microsoft Teams Chat Standard Retention Policy";
                        RestrictiveRetention = $False;
                        Credential = $Credscredential;
                }
                SCRetentionComplianceRule Container-110-4c097e33-a2a0-41c0-9536-db88d74d2c54
                {
                        RetentionComplianceAction = "KeepAndDelete";
                        ExpirationDateOption = "CreationAgeInDays";
                        RetentionDurationDisplayHint = "Days";
                        Ensure = "Present";
                        RetentionDuration = "730";
                        Policy = "Microsoft Teams Chat Standard Retention Policy";
                        Name = "Microsoft Teams Chat Standard Retention Rule";
                        Credential = $Credscredential;
                }

The policy gets created properly, but is disabled, because its Enabled parameter is set to $false. What is the issue exactly?

@atdheekurteshi
Copy link
Author

Changed it Enabled = $True; for Microsoft Teams Chat Standard Retention Policy
Still TeamsChatLocation = All its not enabled.

Configuration MainConfig
{
    param
    (
         [Parameter(Mandatory = $true,Position=0)][ValidateNotNull()][System.Management.Automation.PSCredential]$AdminCred
    )
    Import-DscResource -ModuleName "Microsoft365DSC"
    Node localhost
    {
                SCRetentionCompliancePolicy Container-106-635eb06c-ee60-4ab5-8ed0-bacef7032821
                {
                        Comment = "Standard Aufbewahrungsfrist für Exchange Online 93 Tage";
                        Enabled = $False;
                        Ensure = "Present";
                        Name = "Exchange Online Standard Retention Policy";
                        ExchangeLocation = "All";
                        RestrictiveRetention = $False;
                        Credential = $AdminCred;
                }
                SCRetentionCompliancePolicy Container-107-13fc9a4b-bf6e-46fa-bdc9-8a9ad8d1f5da
                {
                        Comment = "Standard Aufbewahrungsrichtlinie für Microsoft Teams Chat Protokolle";
                        TeamsChatLocation = "All";
                        Enabled = $True;
                        Ensure = "Present";
                        Name = "Microsoft Teams Chat Standard Retention Policy";
                        RestrictiveRetention = $False;
                        Credential = $AdminCred;
                }
                SCRetentionCompliancePolicy Container-108-e155ed94-a351-41a5-ac01-b27e58825cf5
                {
                        Comment = "Standard Aufbewahrungsrichtlinie für Microsoft OneDrive";
                        Enabled = $True;
                        Ensure = "Present";
                        Name = "OneDrive Standard Retention Policy";
                        SharePointLocation = "All";
                        OneDriveLocation = "All";
                        RestrictiveRetention = $False;
                        Credential = $AdminCred;
                }
                SCRetentionComplianceRule Container-109-59c77f32-6990-49cf-b449-42f8ce637c46
                {
                        RetentionComplianceAction = "Keep";
                        ExpirationDateOption = "ModificationAgeInDays";
                        RetentionDurationDisplayHint = "Days";
                        Ensure = "Present";
                        RetentionDuration = "93";
                        Policy = "Exchange Online Standard Retention Policy";
                        Name = "Exchange Online Standard Retention Rule";
                        Credential = $AdminCred;
                }
                SCRetentionComplianceRule Container-110-4c097e33-a2a0-41c0-9536-db88d74d2c54
                {
                        RetentionComplianceAction = "KeepAndDelete";
                        ExpirationDateOption = "CreationAgeInDays";
                        RetentionDurationDisplayHint = "Days";
                        Ensure = "Present";
                        RetentionDuration = "730";
                        Policy = "Microsoft Teams Chat Standard Retention Policy";
                        Name = "Microsoft Teams Chat Standard Retention Rule";
                        Credential = $AdminCred;
                }
                SCRetentionComplianceRule Container-111-a1974584-3f18-4e58-8458-4433815c74b4
                {
                        RetentionComplianceAction = "Keep";
                        ExpirationDateOption = "ModificationAgeInDays";
                        RetentionDurationDisplayHint = "Days";
                        Ensure = "Present";
                        RetentionDuration = "93";
                        Policy = "OneDrive Standard Retention Policy";
                        Name = "OneDrive Standard Retention Rule";
                        Credential = $AdminCred;
                }
      }
}

It dosen't enable the TeamsChatLocation on the GUI.

    <ConfigurationDrift Source="MSFT_SCRetentionComplianceRule">
        <ParametersNotInDesiredState>
            <Param Name="RetentionDurationDisplayHint"><CurrentValue></CurrentValue><DesiredValue>Days</DesiredValue></Param>
            <Param Name="ExpirationDateOption"><CurrentValue></CurrentValue><DesiredValue>CreationAgeInDays</DesiredValue></Param>
        </ParametersNotInDesiredState>
    </ConfigurationDrift>
    <DesiredValues>
        <Param Name ="Name">Microsoft Teams Chat Standard Retention Rule</Param>
        <Param Name ="Policy">Microsoft Teams Chat Standard Retention Policy</Param>
        <Param Name ="Ensure">Present</Param>
        <Param Name ="ExpirationDateOption">CreationAgeInDays</Param>
        <Param Name ="RetentionComplianceAction">KeepAndDelete</Param>
        <Param Name ="RetentionDuration">730</Param>
        <Param Name ="RetentionDurationDisplayHint">Days</Param>
        <Param Name ="Verbose">True</Param>
    </DesiredValues>
</M365DSCEvent>
<M365DSCEvent>
    <ConfigurationDrift Source="MSFT_SCRetentionCompliancePolicy">
        <ParametersNotInDesiredState>
            <Param Name="TeamsChatLocation"><CurrentValue></CurrentValue><DesiredValue>All</DesiredValue></Param>
        </ParametersNotInDesiredState>
    </ConfigurationDrift>
    <DesiredValues>
        <Param Name ="Name">Microsoft Teams Chat Standard Retention Policy</Param>
        <Param Name ="Ensure">Present</Param>
        <Param Name ="Comment">Standard Aufbewahrungsrichtlinie für Microsoft Teams Chat Protokolle</Param>
        <Param Name ="Enabled">True</Param>
        <Param Name ="RestrictiveRetention">False</Param>
        <Param Name ="TeamsChatLocation">All</Param>
        <Param Name ="Verbose">True</Param>
    </DesiredValues>
</M365DSCEvent>

@atdheekurteshi
Copy link
Author

atdheekurteshi commented Nov 15, 2022

Here is the Power-Shell Skript how should it work in the DSC

-DistributionDetail should be provieded if not the TeamsChatLocation: {All} would not be shown in the Power-Shell if Get command is executed but only like this TeamsChatLocation: {}

New-RetentionCompliancePolicy -Name "Microsoft Teams Chat Standard Retention Policy" -Comment 'Test' -TeamsChatLocation 'All' -Enabled:$false -RestrictiveRetention:$false

Name                                           Workload                                                                    Enabled Mode
----                                           --------                                                                    ------- ----
Microsoft Teams Chat Standard Retention Policy Exchange, SharePoint, OneDriveForBusiness, Skype, ModernGroup, DynamicScope False   Enforce

PS C:\windows\system32> Get-RetentionCompliancePolicy -Identity 'Microsoft Teams Chat Standard Retention Policy' -DistributionDetail | select Name ,Comment, TeamsChatLocation,Enabled,RestrictiveRetention


Name                 : Microsoft Teams Chat Standard Retention Policy
Comment              : Test
TeamsChatLocation    : {All}
Enabled              : False
RestrictiveRetention : False

@NikCharlebois
Copy link
Collaborator

The resource is already using the -DistributionDetail switch. This was fixed in a release 2 weeks ago. I am investigating why switching Enabled from False to True on a policy doesn't kick in.

NikCharlebois added a commit to NikCharlebois/Microsoft365DSC that referenced this issue Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants