fix: 7.3.4 so it outputs a pipe separated table

This commit is contained in:
DrIOS
2024-06-07 14:15:57 -05:00
parent c530d2df76
commit 8de61dda9f

View File

@@ -1,7 +1,6 @@
function Test-RestrictCustomScripts { function Test-RestrictCustomScripts {
[CmdletBinding()] [CmdletBinding()]
param ( param (
# Aligned
# Define your parameters here if needed # Define your parameters here if needed
) )
@@ -25,24 +24,22 @@ function Test-RestrictCustomScripts {
# Compliance is true if no sites allow custom scripts # Compliance is true if no sites allow custom scripts
$complianceResult = $customScriptAllowedSites.Count -eq 0 $complianceResult = $customScriptAllowedSites.Count -eq 0
# Gather details for non-compliant sites (where custom scripts are allowed)
$nonCompliantSiteDetails = $customScriptAllowedSites | ForEach-Object {
"$($_.Title) ($($_.Url)): Custom Script Allowed"
}
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $complianceResult) { $failureReasons = if ($complianceResult) {
"The following site collections allow custom script execution: " + ($nonCompliantSiteDetails -join "; ")
}
else {
"N/A" "N/A"
} else {
"The following site collections allow custom script execution:"
} }
$details = if ($complianceResult) { $details = if ($complianceResult) {
"All site collections have custom script execution restricted" "All site collections have custom script execution restricted"
} } else {
else { # Create pipe-separated table for non-compliant sites
$nonCompliantSiteDetails -join "; " $nonCompliantSiteDetails = $customScriptAllowedSites | ForEach-Object {
$title = if ($_.Title) { $_.Title } else { "No Title" }
"$title|$($_.Url)|True"
}
"Title|Url|CustomScriptAllowed`n" + ($nonCompliantSiteDetails -join "`n")
} }
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object