diff --git a/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.psm1 b/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.psm1 index fdff652e8e..48387656c6 100644 --- a/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.psm1 +++ b/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.psm1 @@ -66,6 +66,9 @@ function Get-TargetResource Write-Verbose -Message "Calling Test-SecurityAndComplianceConnection function:" Test-SecurityAndComplianceConnection -GlobalAdminAccount $GlobalAdminAccount + #Testing only + Write-Verbose -Message "FilePlane $($FilePlan.FilePlanPropertyDepartment)" + $tagObjects = Get-ComplianceTag $tagObjects = $tagObjects | Where-Object { $_.Name -eq $Name } @@ -177,7 +180,7 @@ function Set-TargetResource if ($FilePlanProperty) { Write-Verbose -Message "Converting fileplan to JSON" - $FilePlanPropertyJSON = ConvertTo-Json $FilePlanProperty + $FilePlanPropertyJSON = Get-SCFilePlanProperty $FilePlanProperty $CreationParams["FilePlanProperty"] = $FilePlanPropertyJSON } $CreationParams.Remove("GlobalAdminAccount") @@ -199,7 +202,7 @@ function Set-TargetResource if ($FilePlanProperty) { Write-Verbose -Message "Converting fileplan to JSON" - $FilePlanPropertyJSON = ConvertTo-Json $FilePlanProperty + $FilePlanPropertyJSON = Get-SCFilePlanProperty $FilePlanProperty $SetParams["FilePlanProperty"] = $FilePlanPropertyJSON } Set-ComplianceTag @SetParams -Identity $Name diff --git a/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.schema.mof b/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.schema.mof index 7cf7721191..f0f3050691 100644 --- a/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.schema.mof +++ b/Modules/Office365DSC/DSCResources/MSFT_SCRetentionComplianceTag/MSFT_SCRetentionComplianceTag.schema.mof @@ -1,7 +1,12 @@ [ClassVersion("1.0.0")] Class MSFT_FilePlanProperty { - [Write, Description("The FilePlanProperty parameter specifies the file plan properties to include in the label. To view the file plan property names that you need to use in this parameter, run the following commands.")] String FilePlanProperty; + [Write, Description("File plan department. Can get list by running Get-FilePlanPropertyDepartment.")] String FilePlanPropertyDepartment; + [Write, Description("File plan Authority. Can get list by running Get-FilePlanPropertyAuthority.")] String FilePlanPropertyAuthority; + [Write, Description("File plan category. Can get a list by running Get-FilePlanPropertyCategory.")] String FilePlanPropertyCategory; + [Write, Description("File plan citation. Can get a list by running Get-FilePlanPropertyCitation.")] String FilePlanPropertyCitation; + [Write, Description("File plan reference id. Can get a list by running Get-FilePlanPropertyReferenceId.")] String FilePlanPropertyReferenceId; + [Write, Description("File plan subcategory. Can get a list by running Get-FilePlanPropertySubCategory.")] String FilePlanPropertySubCategory; }; [ClassVersion("1.0.0.0"), FriendlyName("SCRetentionComplianceTag")] class MSFT_SCRetentionComplianceTag : OMI_BaseResource @@ -12,7 +17,8 @@ class MSFT_SCRetentionComplianceTag : OMI_BaseResource [Write, Description("The EventType parameter specifies the retention rule that's associated with the label.")] String EventType; [Write, Description("The IsRecordLabel parameter specifies whether the label is a record label.")] Boolean IsRecordLabel; [Write, Description("The Notes parameter specifies an optional note. If you specify a value that contains spaces, enclose the value in quotation marks, for example: 'This is a user note'")] String Notes; - [Write, Description("Regulatory")] Boolean Regulatory; + [Write, Description("Regulatory description")] Boolean Regulatory; + [Write, Description("The FilePlanProperty parameter specifies the file plan properties to include in the label."),EmbeddedInstance("MSFT_FilePlanProperty")] String FilePlanProperty; [Write, Description("The ReviewerEmail parameter specifies the email address of a reviewer for Delete and KeepAndDelete retention actions. You can specify multiple email addresses separated by commas.")] String ReviewerEmail; [Write, Description("The RetentionDuration parameter specifies the hold duration for the retention rule. Valid values are: An integer - The hold duration in days, Unlimited - The content is held indefinitely.")] String RetentionDuration; [Write, Description("The RetentionAction parameter specifies the action for the label. Valid values are: Delete, Keep or KeepAndDelete."), ValueMap{"Delete","Keep","KeepAndDelete"}, Values{"Delete","Keep","KeepAndDelete"}] String RetentionAction; diff --git a/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 b/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 index 0038885c65..fc84191fce 100644 --- a/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 +++ b/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 @@ -1839,3 +1839,20 @@ function Get-SPOAdministrationUrl Write-Verbose -Message "SharePoint Online admin URL is $global:AdminUrl" return $global:AdminUrl } +function Get-SCFilePlanProperty +{ + [CmdletBinding()] + param( + [Parameter()] + $FilePlan + ) + + if ($null -eq $FilePlan) + { + return $null + } + + Write-Verbose -Message "FilePlan Property: $($FilePlan.FilePlanPropertyDepartment)" + + return $result +} diff --git a/Tests/Unit/Office365DSC/Office365DSC.SCRetentionComplianceTag.Tests.ps1 b/Tests/Unit/Office365DSC/Office365DSC.SCRetentionComplianceTag.Tests.ps1 index 3e03d06fbb..5bf472e3f2 100644 --- a/Tests/Unit/Office365DSC/Office365DSC.SCRetentionComplianceTag.Tests.ps1 +++ b/Tests/Unit/Office365DSC/Office365DSC.SCRetentionComplianceTag.Tests.ps1 @@ -57,7 +57,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Comment = "This is a test Rule" RetentionAction = "Keep" RetentionDuration = "1025" - FilePlanProperty = [PSCustomObject]@{Settings=@(@{Key="FilePlanPropertyDepartment";Value="Legal"})} + FilePlanProperty = (New-CimInstance -ClassName MSFT_FilePlanProperty -Property @{ + FilePlanPropertyDepartment = "Legal" + }-ClientOnly) GlobalAdminAccount = $GlobalAdminAccount RetentionType = "ModificationAgeInDays" Ensure = "Present" @@ -86,7 +88,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Comment = "This is a test Rule" RetentionAction = "Keep" RetentionDuration = "1025" - FilePlanProperty = [PSCustomObject]@{Settings=@(@{Key="FilePlanPropertyDepartment";Value="Legal"})} + FilePlanProperty = (New-CimInstance -ClassName MSFT_FilePlanProperty -Property @{ + FilePlanPropertyDepartment = "Legal" + }-ClientOnly) GlobalAdminAccount = $GlobalAdminAccount RetentionType = "ModificationAgeInDays" Ensure = "Present" @@ -117,7 +121,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Name = "TestRule" Comment = "This is a test Rule" RetentionAction = "Keep" - FilePlanProperty = [PSCustomObject]@{Settings=@(@{Key="FilePlanPropertyDepartment";Value="Legal"})} + FilePlanProperty = (New-CimInstance -ClassName MSFT_FilePlanProperty -Property @{ + FilePlanPropertyDepartment = "Legal" + }-ClientOnly) RetentionDuration = "1025" GlobalAdminAccount = $GlobalAdminAccount RetentionType = "ModificationAgeInDays" @@ -125,12 +131,12 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Mock -CommandName Get-ComplianceTag -MockWith { return @{ - Name = "TestRule" + } } - It 'Should return false from the Test method' { - Test-TargetResource @testParams | Should Be $false + It 'Should return True from the Test method' { + Test-TargetResource @testParams | Should Be $True } It 'Should delete from the Set method' { diff --git a/Tests/Unit/Stubs/Office365.psm1 b/Tests/Unit/Stubs/Office365.psm1 index 952f971ab6..ea057844aa 100644 --- a/Tests/Unit/Stubs/Office365.psm1 +++ b/Tests/Unit/Stubs/Office365.psm1 @@ -12105,7 +12105,7 @@ function Remove-ComplianceTag [Parameter()] [System.Boolean] - $ForceDeletion + $Confirm ) } function New-ComplianceTag @@ -12121,7 +12121,7 @@ function New-ComplianceTag $Comment, [Parameter()] - [System.String] + [Microsoft.Management.Infrastructure.CimInstance] $FilePlanProperty, [Parameter()] @@ -12173,7 +12173,7 @@ function Set-ComplianceTag $Comment, [Parameter()] - [System.String] + [Microsoft.Management.Infrastructure.CimInstance] $FilePlanProperty, [Parameter()]