Skip to content

Commit a4633fe

Browse files
reporting
1 parent 2ad0dcf commit a4633fe

File tree

2 files changed

+99
-2
lines changed

2 files changed

+99
-2
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
function Add-CippTestResult {
2+
<#
3+
.SYNOPSIS
4+
Adds a test result to the CIPP test results database
5+
6+
.DESCRIPTION
7+
Stores test result data in the CippTestResults table with tenant and test ID as keys
8+
9+
.PARAMETER TenantFilter
10+
The tenant domain or GUID for the test result
11+
12+
.PARAMETER TestId
13+
Unique identifier for the test
14+
15+
.PARAMETER Status
16+
Test status (e.g., Pass, Fail, Skip)
17+
18+
.PARAMETER ResultMarkdown
19+
Markdown formatted result details
20+
21+
.PARAMETER Risk
22+
Risk level (e.g., High, Medium, Low)
23+
24+
.PARAMETER Name
25+
Display name of the test
26+
27+
.PARAMETER Pillar
28+
Security pillar category
29+
30+
.PARAMETER UserImpact
31+
Impact level on users
32+
33+
.PARAMETER ImplementationEffort
34+
Effort required for implementation
35+
36+
.PARAMETER Category
37+
Test category or classification
38+
39+
.EXAMPLE
40+
Add-CippTestResult -TenantFilter 'contoso.onmicrosoft.com' -TestId 'MFA-001' -Status 'Pass' -Name 'MFA Enabled' -Risk 'High'
41+
#>
42+
[CmdletBinding()]
43+
param(
44+
[Parameter(Mandatory = $true)]
45+
[string]$TenantFilter,
46+
47+
[Parameter(Mandatory = $true)]
48+
[string]$TestId,
49+
50+
[Parameter(Mandatory = $true)]
51+
[string]$Status,
52+
53+
[Parameter(Mandatory = $false)]
54+
[string]$ResultMarkdown,
55+
56+
[Parameter(Mandatory = $false)]
57+
[string]$Risk,
58+
59+
[Parameter(Mandatory = $false)]
60+
[string]$Name,
61+
62+
[Parameter(Mandatory = $false)]
63+
[string]$Pillar,
64+
65+
[Parameter(Mandatory = $false)]
66+
[string]$UserImpact,
67+
68+
[Parameter(Mandatory = $false)]
69+
[string]$ImplementationEffort,
70+
71+
[Parameter(Mandatory = $false)]
72+
[string]$Category
73+
)
74+
75+
try {
76+
$Table = Get-CippTable -tablename 'CippTestResults'
77+
78+
$Entity = @{
79+
PartitionKey = $TenantFilter
80+
RowKey = $TestId
81+
Status = $Status
82+
ResultMarkdown = $ResultMarkdown ?? ''
83+
Risk = $Risk ?? ''
84+
Name = $Name ?? ''
85+
Pillar = $Pillar ?? ''
86+
UserImpact = $UserImpact ?? ''
87+
ImplementationEffort = $ImplementationEffort ?? ''
88+
Category = $Category ?? ''
89+
}
90+
91+
Add-CIPPAzDataTableEntity @Table -Entity $Entity -Force
92+
Write-LogMessage -API 'CIPPTestResults' -tenant $TenantFilter -message "Added test result: $TestId - $Status" -sev Info
93+
} catch {
94+
Write-LogMessage -API 'CIPPTestResults' -tenant $TenantFilter -message "Failed to add test result: $($_.Exception.Message)" -sev Error
95+
throw
96+
}
97+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Invoke-ListTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function Invoke-ListTests {
2626
$TestResultsData = Get-CIPPTestResults -TenantFilter $TenantFilter
2727

2828
if ($ReportId) {
29-
$ReportTable = Get-CippTable -tablename 'CippReportTemplates'
30-
$Filter = "PartitionKey eq 'ReportTemplate' and RowKey eq '{0}'" -f $ReportId
29+
$ReportTable = Get-CippTable -tablename 'CippReportingTemplates'
30+
$Filter = "PartitionKey eq 'ReportingTemplate' and RowKey eq '{0}'" -f $ReportId
3131
$ReportTemplate = Get-CIPPAzDataTableEntity @ReportTable -Filter $Filter
3232

3333
if ($ReportTemplate) {

0 commit comments

Comments
 (0)