tests/Test-SharePointAADB2B.ps1
function Test-SharePointAADB2B { [CmdletBinding()] [OutputType([CISAuditResult])] param ( # Aligned # Define your parameters here ) begin { # Conditions for 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled # # Validate test for a pass: # - Confirm that the automated test results align with the manual audit steps outlined in the CIS benchmark. # - Specific conditions to check: # - Condition A: Ensure the `EnableAzureADB2BIntegration` property is set to `True` for the SharePoint tenant. # - Condition B: Verify that the SharePoint and OneDrive integration with Azure AD B2B is active. # - Condition C: Ensure that guest accounts are managed in Azure AD and subject to access policies. # # Validate test for a fail: # - Confirm that the failure conditions in the automated test are consistent with the manual audit results. # - Specific conditions to check: # - Condition A: The `EnableAzureADB2BIntegration` property is set to `False` for the SharePoint tenant. # - Condition B: The integration between SharePoint, OneDrive, and Azure AD B2B is not active. # - Condition C: Guest accounts are not managed in Azure AD and are not subject to access policies. # Dot source the class script if necessary #. .\source\Classes\CISAuditResult.ps1 # Initialization code, if needed $recnum = "7.2.2" Write-Verbose "Running Test-SharePointAADB2B for $recnum..." } process { try { # 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled # $SPOTenantAzureADB2B Mock Object <# $SPOTenantAzureADB2B = [PSCustomObject]@{ EnableAzureADB2BIntegration = $false } #> $SPOTenantAzureADB2B = Get-CISSpoOutput -Rec $recnum # Populate the auditResult object with the required properties $params = @{ Rec = $recnum Result = $SPOTenantAzureADB2B.EnableAzureADB2BIntegration Status = if ($SPOTenantAzureADB2B.EnableAzureADB2BIntegration) { "Pass" } else { "Fail" } Details = "EnableAzureADB2BIntegration: $($SPOTenantAzureADB2B.EnableAzureADB2BIntegration)" FailureReason = if (-not $SPOTenantAzureADB2B.EnableAzureADB2BIntegration) { "Azure AD B2B integration is not enabled. The following command can be used to enable:`nSet-SPOTenant -EnableAzureADB2BIntegration `$true" } else { "N/A" } } $auditResult = Initialize-CISAuditResult @params } catch { $LastError = $_ $auditResult = Get-TestError -LastError $LastError -recnum $recnum } } end { # Return auditResult return $auditResult } } |