fix: 7.3.4 so it outputs a pipe separated table
This commit is contained in:
@@ -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 {
|
||||||
|
# Create pipe-separated table for non-compliant sites
|
||||||
|
$nonCompliantSiteDetails = $customScriptAllowedSites | ForEach-Object {
|
||||||
|
$title = if ($_.Title) { $_.Title } else { "No Title" }
|
||||||
|
"$title|$($_.Url)|True"
|
||||||
}
|
}
|
||||||
else {
|
"Title|Url|CustomScriptAllowed`n" + ($nonCompliantSiteDetails -join "`n")
|
||||||
$nonCompliantSiteDetails -join "; "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create and populate the CISAuditResult object
|
# Create and populate the CISAuditResult object
|
||||||
|
Reference in New Issue
Block a user