fix: 7.3.2 aligned with test-template
This commit is contained in:
@@ -1,37 +1,54 @@
|
|||||||
function Test-OneDriveSyncRestrictions {
|
function Test-OneDriveSyncRestrictions {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
|
# Aligned
|
||||||
# Define your parameters here
|
# Define your parameters here
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# Initialization code
|
# Dot source the class script if necessary
|
||||||
|
#. .\source\Classes\CISAuditResult.ps1
|
||||||
$auditResult = [CISAuditResult]::new()
|
# Initialization code, if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
# 7.3.2 (L2) Ensure OneDrive sync is restricted for unmanaged devices
|
# 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
|
$SPOTenantSyncClientRestriction = Get-SPOTenantSyncClientRestriction | Select-Object TenantRestrictionEnabled, AllowedDomainList
|
||||||
$isSyncRestricted = $SPOTenantSyncClientRestriction.TenantRestrictionEnabled -and $SPOTenantSyncClientRestriction.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.CISControlVer = "v8"
|
||||||
$auditResult.CISControl = "0.0"
|
$auditResult.CISControl = "0.0"
|
||||||
$auditResult.CISDescription = "Explicitly Not Mapped"
|
$auditResult.CISDescription = "Explicitly Not Mapped"
|
||||||
|
|
||||||
$auditResult.Rec = "7.3.2"
|
|
||||||
$auditResult.ELevel = "E3"
|
|
||||||
$auditResult.ProfileLevel = "L2"
|
|
||||||
$auditResult.IG1 = $false
|
$auditResult.IG1 = $false
|
||||||
$auditResult.IG2 = $false
|
$auditResult.IG2 = $false
|
||||||
$auditResult.IG3 = $false
|
$auditResult.IG3 = $false
|
||||||
$auditResult.RecDescription = "Ensure OneDrive sync is restricted for unmanaged devices"
|
|
||||||
|
|
||||||
$auditResult.Result = $isSyncRestricted
|
$auditResult.Result = $isSyncRestricted
|
||||||
$auditResult.Details = "TenantRestrictionEnabled: $($SPOTenantSyncClientRestriction.TenantRestrictionEnabled); AllowedDomainList: $($SPOTenantSyncClientRestriction.AllowedDomainList -join ', ')"
|
$auditResult.Details = $details
|
||||||
$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.FailureReason = $failureReasons
|
||||||
$auditResult.Status = if ($isSyncRestricted) { "Pass" } else { "Fail" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
Reference in New Issue
Block a user