From 26fa3a8922eb7f88429244bd1800edc9185e9d2f Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Tue, 28 May 2024 13:08:36 -0500 Subject: [PATCH] fix: 7.3.2 aligned with test-template --- .../tests/Test-OneDriveSyncRestrictions.ps1 | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/source/tests/Test-OneDriveSyncRestrictions.ps1 b/source/tests/Test-OneDriveSyncRestrictions.ps1 index 5b3ca53..67be5d3 100644 --- a/source/tests/Test-OneDriveSyncRestrictions.ps1 +++ b/source/tests/Test-OneDriveSyncRestrictions.ps1 @@ -1,37 +1,54 @@ function Test-OneDriveSyncRestrictions { [CmdletBinding()] param ( + # Aligned # Define your parameters here ) begin { - # Initialization code - - $auditResult = [CISAuditResult]::new() + # Dot source the class script if necessary + #. .\source\Classes\CISAuditResult.ps1 + # Initialization code, if needed } process { # 7.3.2 (L2) Ensure OneDrive sync is restricted for unmanaged devices + + # Retrieve OneDrive sync client restriction settings $SPOTenantSyncClientRestriction = Get-SPOTenantSyncClientRestriction | Select-Object TenantRestrictionEnabled, AllowedDomainList $isSyncRestricted = $SPOTenantSyncClientRestriction.TenantRestrictionEnabled -and $SPOTenantSyncClientRestriction.AllowedDomainList - # Populate the auditResult object with the required properties + # Prepare failure reasons and details based on compliance + $failureReasons = if (-not $isSyncRestricted) { + "OneDrive sync is not restricted to managed devices. TenantRestrictionEnabled should be True and AllowedDomainList should contain trusted domains GUIDs." + } + else { + "N/A" + } + + $details = if ($isSyncRestricted) { + "OneDrive sync is restricted for unmanaged devices." + } + else { + "TenantRestrictionEnabled: $($SPOTenantSyncClientRestriction.TenantRestrictionEnabled); AllowedDomainList: $($SPOTenantSyncClientRestriction.AllowedDomainList -join ', ')" + } + + # Create and populate the CISAuditResult object + $auditResult = [CISAuditResult]::new() + $auditResult.Status = if ($isSyncRestricted) { "Pass" } else { "Fail" } + $auditResult.ELevel = "E3" + $auditResult.ProfileLevel = "L2" + $auditResult.Rec = "7.3.2" + $auditResult.RecDescription = "Ensure OneDrive sync is restricted for unmanaged devices" $auditResult.CISControlVer = "v8" $auditResult.CISControl = "0.0" $auditResult.CISDescription = "Explicitly Not Mapped" - - $auditResult.Rec = "7.3.2" - $auditResult.ELevel = "E3" - $auditResult.ProfileLevel = "L2" $auditResult.IG1 = $false $auditResult.IG2 = $false $auditResult.IG3 = $false - $auditResult.RecDescription = "Ensure OneDrive sync is restricted for unmanaged devices" - $auditResult.Result = $isSyncRestricted - $auditResult.Details = "TenantRestrictionEnabled: $($SPOTenantSyncClientRestriction.TenantRestrictionEnabled); AllowedDomainList: $($SPOTenantSyncClientRestriction.AllowedDomainList -join ', ')" - $auditResult.FailureReason = if (-not $isSyncRestricted) { "OneDrive sync is not restricted to managed devices. TenantRestrictionEnabled should be True and AllowedDomainList should contain trusted domains GUIDs." } else { "N/A" } - $auditResult.Status = if ($isSyncRestricted) { "Pass" } else { "Fail" } + $auditResult.Details = $details + $auditResult.FailureReason = $failureReasons } end {