From c918f0203e35e17e2a084d77a17205e22a9eafa9 Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Tue, 28 May 2024 11:31:45 -0500 Subject: [PATCH] fix: 7.2.4 aligned with test-template --- .../Test-OneDriveContentRestrictions.ps1 | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/source/tests/Test-OneDriveContentRestrictions.ps1 b/source/tests/Test-OneDriveContentRestrictions.ps1 index 2a610ca..5d52bad 100644 --- a/source/tests/Test-OneDriveContentRestrictions.ps1 +++ b/source/tests/Test-OneDriveContentRestrictions.ps1 @@ -1,41 +1,58 @@ function Test-OneDriveContentRestrictions { [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.2.4 (L2) Ensure OneDrive content sharing is restricted + + # Retrieve OneDrive sharing capability settings $SPOTenant = Get-SPOTenant | Select-Object OneDriveSharingCapability $isOneDriveSharingRestricted = $SPOTenant.OneDriveSharingCapability -eq 'Disabled' - # Populate the auditResult object with the required properties + # Prepare failure reasons and details based on compliance + $failureReasons = if (-not $isOneDriveSharingRestricted) { + "OneDrive content sharing is not restricted to 'Disabled'. Current setting: $($SPOTenant.OneDriveSharingCapability)" + } + else { + "N/A" + } + + $details = if ($isOneDriveSharingRestricted) { + "OneDrive content sharing is restricted." + } + else { + "OneDriveSharingCapability: $($SPOTenant.OneDriveSharingCapability)" + } + + # Create and populate the CISAuditResult object + $auditResult = [CISAuditResult]::new() + $auditResult.Status = if ($isOneDriveSharingRestricted) { "Pass" } else { "Fail" } + $auditResult.ELevel = "E3" + $auditResult.ProfileLevel = "L2" + $auditResult.Rec = "7.2.4" + $auditResult.RecDescription = "Ensure OneDrive content sharing is restricted" $auditResult.CISControlVer = "v8" $auditResult.CISControl = "3.3" $auditResult.CISDescription = "Configure Data Access Control Lists" - - $auditResult.Rec = "7.2.4" - $auditResult.ELevel = "E3" - $auditResult.ProfileLevel = "L2" $auditResult.IG1 = $true $auditResult.IG2 = $true $auditResult.IG3 = $true - $auditResult.RecDescription = "Ensure OneDrive content sharing is restricted" - $auditResult.Result = $isOneDriveSharingRestricted - $auditResult.Details = "OneDriveSharingCapability: $($SPOTenant.OneDriveSharingCapability)" - $auditResult.FailureReason = if (-not $isOneDriveSharingRestricted) { "OneDrive content sharing is not restricted to 'Disabled'. Current setting: $($SPOTenant.OneDriveSharingCapability)" } else { "N/A" } - $auditResult.Status = if ($isOneDriveSharingRestricted) { "Pass" } else { "Fail" } + $auditResult.Details = $details + $auditResult.FailureReason = $failureReasons } end { # Return auditResult return $auditResult } -} +} \ No newline at end of file