Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
8fbad4c
Feat: Add functions to list and manage trusted and blocked senders
kris6673 Dec 15, 2025
fe845d1
typo dammit
kris6673 Dec 15, 2025
a87fed3
Add Azure Storage SAS and blob upload utilities
JohnDuprey Dec 21, 2025
c0457be
Update New-CIPPAzServiceSAS.ps1
JohnDuprey Dec 21, 2025
968ed82
Fix for management stats
KelvinTegelaar Dec 21, 2025
e9576d3
Add data collection for tests
KelvinTegelaar Dec 21, 2025
2ad0dcf
db request add type
KelvinTegelaar Dec 21, 2025
a4633fe
reporting
KelvinTegelaar Dec 22, 2025
8a86ddb
Reporting template tests
KelvinTegelaar Dec 22, 2025
85ac7ee
reporting updates
KelvinTegelaar Dec 22, 2025
418a8cc
Tests
KelvinTegelaar Dec 22, 2025
df632ea
tests with reporting
KelvinTegelaar Dec 22, 2025
a0203a8
Allow reserved app names in include/exclude applications
JohnDuprey Dec 23, 2025
9666ed8
Improve handling of arrays in CA template and comparison
sfaxluke Dec 23, 2025
b090550
ZTNA test batch1
KelvinTegelaar Dec 23, 2025
2323719
Add more tests
KelvinTegelaar Dec 23, 2025
9c8f1de
updates
KelvinTegelaar Dec 23, 2025
950ec36
More ZTNA tests(untested)
KelvinTegelaar Dec 23, 2025
e4c9818
Added Tests
KelvinTegelaar Dec 24, 2025
f61e984
Next batch
KelvinTegelaar Dec 24, 2025
20158d3
Next batch
KelvinTegelaar Dec 24, 2025
e8e1465
extra test
KelvinTegelaar Dec 24, 2025
2ceb15c
Add new tests
KelvinTegelaar Dec 24, 2025
eaae2d8
Added caches
KelvinTegelaar Dec 24, 2025
90a084f
Named locations
KelvinTegelaar Dec 24, 2025
1ef2c30
NEw tests, not tested
KelvinTegelaar Dec 24, 2025
bdc4330
Tests
KelvinTegelaar Dec 24, 2025
e9a6336
updates to tests
KelvinTegelaar Dec 24, 2025
58681f0
Added overwrite toggle for transport rule standard
kakaiwa Dec 24, 2025
d6dde87
Removed yarn files
kakaiwa Dec 24, 2025
749a40d
new tests
KelvinTegelaar Dec 24, 2025
489f507
new tests
KelvinTegelaar Dec 24, 2025
020776a
more tests
KelvinTegelaar Dec 24, 2025
97f1ac6
More tests
KelvinTegelaar Dec 24, 2025
2f885bb
Updated Tests
KelvinTegelaar Dec 24, 2025
291fbf9
Tested first files
KelvinTegelaar Dec 24, 2025
c9cb112
functions that are done
KelvinTegelaar Dec 24, 2025
94663be
Updated New-CIPPCAPolicy to update named locations when overwrite is …
kakaiwa Dec 25, 2025
ac7a4dc
remove backtics, mark as tested.
KelvinTegelaar Dec 26, 2025
4403e7b
Updated tests after testing
KelvinTegelaar Dec 26, 2025
9660318
bug fixes for tests
KelvinTegelaar Dec 26, 2025
a065711
Moved tests
KelvinTegelaar Dec 27, 2025
5536b25
Move files
KelvinTegelaar Dec 27, 2025
e03c96a
Move files
KelvinTegelaar Dec 27, 2025
59838cd
Fix: Fix broken expand for app protection policies
kris6673 Dec 27, 2025
6580150
Initial plan
Copilot Dec 29, 2025
598d5d3
Fix service principal alert URL structure
Copilot Dec 29, 2025
4c1ac08
Fix message text for Remove service principal alert
Copilot Dec 29, 2025
167d2dc
Merge pull request #18 from Zacgoose/copilot/fix-service-principle-al…
Zacgoose Dec 29, 2025
b9d0e39
report update
KelvinTegelaar Dec 29, 2025
6a29014
Merge branch 'KelvinTegelaar:dev' into dev
Zacgoose Dec 30, 2025
4c48a74
Merge pull request #1755 from cipptesting/dev
KelvinTegelaar Dec 30, 2025
7fbadce
Add MFA state and license overviews
KelvinTegelaar Dec 30, 2025
ee8e3ec
Add MFA state
KelvinTegelaar Dec 30, 2025
3338a42
New creation apis
KelvinTegelaar Dec 30, 2025
f28596a
small updates
KelvinTegelaar Dec 31, 2025
9846930
add autocleanup
KelvinTegelaar Dec 31, 2025
73a4311
Improve scheduled task handling and rerun protection
JohnDuprey Jan 1, 2026
acc1dba
push db cache
KelvinTegelaar Jan 1, 2026
52091ef
data collection fix
KelvinTegelaar Jan 1, 2026
8f6543e
test results
KelvinTegelaar Jan 2, 2026
7aa4490
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into…
JohnDuprey Jan 2, 2026
de77f61
Refactor backup to use blob storage and enhance restore
JohnDuprey Jan 2, 2026
c761bb9
Merge pull request #1757 from Zacgoose/dev
KelvinTegelaar Jan 2, 2026
0f815bb
Merge pull request #1756 from kris6673/fix-app-prot
KelvinTegelaar Jan 2, 2026
0f5dd3c
Create Test-BackupStorageComparison.ps1
JohnDuprey Jan 2, 2026
ab15097
Update Start-DurableCleanup.ps1
JohnDuprey Jan 2, 2026
ec101ef
Check accountEnabled property for shared mailbox user
Zacgoose Jan 2, 2026
89828df
Fix deleted data bug
KelvinTegelaar Jan 2, 2026
1591d04
frontend updates
KelvinTegelaar Jan 2, 2026
c58f485
feat(alerts): add Get-CIPPAlertIntunePolicyConflicts function
MWG-Logan Jan 2, 2026
90c90bc
fix(alerts): correct state comparison in Get-CIPPAlertIntunePolicyCon…
MWG-Logan Jan 2, 2026
1bc2f4b
Merge pull request #1759 from BezaluLLC/intune-error-alerts
KelvinTegelaar Jan 2, 2026
4820ac2
Fix: hashtable alert errors
kris6673 Jan 2, 2026
6cd233d
Merge pull request #1760 from kris6673/fix-CIPPAlertOneDriveQuota
JohnDuprey Jan 2, 2026
a02c796
Skip templates with empty tenant filter groups
JohnDuprey Jan 2, 2026
9e44455
Add synopsis
KelvinTegelaar Jan 2, 2026
1c1bba8
Add synopsis
KelvinTegelaar Jan 2, 2026
adf2d8f
skipped message no data
KelvinTegelaar Jan 2, 2026
a1ce380
skipped when data is missing
KelvinTegelaar Jan 2, 2026
ed4fae1
Updates for tests
KelvinTegelaar Jan 2, 2026
f124bbf
create ability to run tests
KelvinTegelaar Jan 3, 2026
d4e6b20
output binding fixes
KelvinTegelaar Jan 3, 2026
b41127c
clean code
KelvinTegelaar Jan 3, 2026
9d2831d
three new tests
KelvinTegelaar Jan 3, 2026
bbba735
Merge pull request #1754 from sfaxluke/dev
KelvinTegelaar Jan 4, 2026
fdb75e7
Merge pull request #1758 from Zacgoose/accountEnabled-fix
KelvinTegelaar Jan 4, 2026
6ad08e8
updates to cippstandardscomparefield for new planning.
KelvinTegelaar Jan 4, 2026
470c024
updates to compares and prettification
KelvinTegelaar Jan 4, 2026
e96a91e
Fix DynamicRules assignment in Invoke-ExecTenantGroup
JohnDuprey Jan 5, 2026
bd2dd91
Add secret name / ID to table
chase-vgo Jan 5, 2026
1b1e1c7
Simplify log date range filter in Invoke-ListLogs
JohnDuprey Jan 5, 2026
bfe9a6f
Add null checks for tenant and standard keys
JohnDuprey Jan 5, 2026
e9b6d29
Fix: Remove measure command
kris6673 Jan 5, 2026
f5489de
Improve template update logic and compress JSON output
JohnDuprey Jan 5, 2026
f4c5ed0
Add Source property to package tag entity
JohnDuprey Jan 5, 2026
98ce1a3
undo rowkey check
JohnDuprey Jan 5, 2026
5c96f7b
fix mx record alert
JohnDuprey Jan 6, 2026
df13333
Add SkipCache option to tenant group retrieval
JohnDuprey Jan 6, 2026
1a89c01
Add IP range restrictions to roles and enforce in access checks
JohnDuprey Jan 7, 2026
cd60ad2
Update Update-CIPPDynamicTenantGroups.ps1
JohnDuprey Jan 7, 2026
72065da
fix group type in edituser
JohnDuprey Jan 7, 2026
37387c7
Optimize MFA state retrieval and policy mapping
Zacgoose Jan 8, 2026
beecc6e
Fix: Sort group members and owners by displayName
kris6673 Jan 8, 2026
de57f93
Update Invoke-ExecUniversalSearch.ps1
JohnDuprey Jan 9, 2026
0b26bba
Merge pull request #1744 from kris6673/JunkEmailConfiguration
JohnDuprey Jan 10, 2026
8d1cea3
Merge pull request #1765 from kris6673/fix-group-members-sorting
JohnDuprey Jan 10, 2026
cb83916
Merge pull request #1762 from kris6673/fix-alert-app-reg
JohnDuprey Jan 10, 2026
7d19f64
Merge pull request #1761 from chase-vgo/dev
JohnDuprey Jan 10, 2026
3542562
EIDSCA tests
KelvinTegelaar Jan 11, 2026
4b0d646
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into…
KelvinTegelaar Jan 11, 2026
ae712bf
EIDSCA
KelvinTegelaar Jan 11, 2026
878e30a
Remove periods
KelvinTegelaar Jan 11, 2026
d5069f6
Fix incorrect pass/fail markers
KelvinTegelaar Jan 11, 2026
470597d
EIDSCA test names
KelvinTegelaar Jan 11, 2026
4fd3255
ORCA tests start
KelvinTegelaar Jan 11, 2026
cc2b7f0
Introduce ORCA tests
KelvinTegelaar Jan 11, 2026
d28bdfb
reports
KelvinTegelaar Jan 11, 2026
c0163b3
fixes 5171
KelvinTegelaar Jan 11, 2026
ed30fb0
Merge pull request #1764 from Zacgoose/mfareport
KelvinTegelaar Jan 11, 2026
3248729
remove extra ip range calculation
JohnDuprey Jan 11, 2026
7b5996c
Replace Get-AzStorageQueue with Get-CIPPAzStorageQueue
JohnDuprey Jan 11, 2026
c9a5b8f
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into…
JohnDuprey Jan 11, 2026
8c484e6
ORCA MD files
KelvinTegelaar Jan 11, 2026
a68c883
added MD files
KelvinTegelaar Jan 11, 2026
c2db73d
filename changes
KelvinTegelaar Jan 11, 2026
b697709
Add Set-CIPPDBCacheMailboxes function
JohnDuprey Jan 11, 2026
5d9ad10
Sanitize RowKey values in Add-CIPPDbItem
JohnDuprey Jan 11, 2026
91ad846
Add Exchange license checks and mailbox cache support
JohnDuprey Jan 11, 2026
d938047
Add mailbox cache tasks to DB cache orchestrator
JohnDuprey Jan 11, 2026
8dcee24
CISA tests
KelvinTegelaar Jan 11, 2026
c99ba82
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into…
KelvinTegelaar Jan 11, 2026
d870bd7
Fix issue with conflict
KelvinTegelaar Jan 11, 2026
ffbf9a4
Optimize group and role member caching with bulk requests
JohnDuprey Jan 11, 2026
1c30389
update Identity
KelvinTegelaar Jan 12, 2026
acaab51
fixes bug
KelvinTegelaar Jan 12, 2026
4b4018d
SecDefaultsDisabled
KelvinTegelaar Jan 12, 2026
93ba288
ActivityBasedTimeout to DefaultPlatformRestrictions
JohnDuprey Jan 12, 2026
124a8eb
Add JIT Admin template management and settings
Zacgoose Jan 13, 2026
5ae674d
fix report creation
KelvinTegelaar Jan 13, 2026
ef06f9c
Merge pull request #1767 from Zacgoose/JIT-featues
KelvinTegelaar Jan 13, 2026
e982446
add-member incase object does not yet exist.
KelvinTegelaar Jan 13, 2026
9d634a5
AnonReportDisable to EnrollmentWindowsHelloForBusinessConfiguration
JohnDuprey Jan 13, 2026
05151f8
feat(users): enhance user creation task handling
kris6673 Jan 13, 2026
d43c903
drop log message
JohnDuprey Jan 14, 2026
4adc6fe
Remove redundant log message in template retrieval
JohnDuprey Jan 14, 2026
121cecd
Optimize app template creation with bulk Graph requests
JohnDuprey Jan 14, 2026
2ef9731
Serialize non-string values in standards compare
JohnDuprey Jan 14, 2026
e896fab
Refactor Exchange Connector template handling
JohnDuprey Jan 14, 2026
32566f4
Replace $User with $Headers in Write-LogMessage calls
JohnDuprey Jan 14, 2026
64f11a9
Refactor templateId to TemplateId property usage
JohnDuprey Jan 14, 2026
ec7bdcd
Mark as compliant fixes for policies in tags
KelvinTegelaar Jan 14, 2026
ab8911e
Standardize reporting for CIPP standards modules
JohnDuprey Jan 14, 2026
e30606a
Improve group assignment handling in intune apps
JohnDuprey Jan 15, 2026
3813692
Fix assignment logic in Invoke-AddStoreApp
JohnDuprey Jan 15, 2026
bb22fbc
Fix: Update return message for license assignment
kris6673 Jan 15, 2026
ce3125a
Require tenantFilter in Invoke-AddUser endpoint
JohnDuprey Jan 15, 2026
763574e
Merge pull request #1770 from kris6673/patch-1
KelvinTegelaar Jan 15, 2026
ecce6fc
reliability changes
KelvinTegelaar Jan 15, 2026
8bbd74a
bug fixes drift
KelvinTegelaar Jan 15, 2026
dab467f
Merge branch 'dev' into happy-gary-happy-life
kris6673 Jan 15, 2026
b3d76a6
Merge pull request #1768 from kris6673/happy-gary-happy-life
KelvinTegelaar Jan 15, 2026
b13b1a4
Improve filtering logic in Get-CIPPDbItem
JohnDuprey Jan 16, 2026
095a981
Add Get-CIPPMailboxPermissionReport function
JohnDuprey Jan 16, 2026
f57e458
Refactor Intune policy caching to use bulk Graph requests
JohnDuprey Jan 16, 2026
6f88252
Add mailbox and OneDrive usage cache functions
JohnDuprey Jan 16, 2026
44a8942
Switch to CIPP Reporting DB for extension sync
JohnDuprey Jan 16, 2026
01f3a53
Enhance reporting data and update NinjaOne sync logic
JohnDuprey Jan 16, 2026
958fd19
Deprecate legacy extension sync tasks and update data flow
JohnDuprey Jan 16, 2026
0b7d604
Add universal search for CIPP Reporting DB data
JohnDuprey Jan 16, 2026
251eaec
Update search parameters
JohnDuprey Jan 16, 2026
1da358e
Prevent duplicate scheduled tasks unless completed or failed
JohnDuprey Jan 16, 2026
4b36d96
Enhance mailbox permission report
JohnDuprey Jan 16, 2026
a6b6162
Add support for AllTenants in mailbox permission report
JohnDuprey Jan 16, 2026
2fe8c1d
Show relative time until scheduled task runs
JohnDuprey Jan 16, 2026
a7b91e7
Handle multi-tenant scheduled task completion logic
JohnDuprey Jan 16, 2026
37fc094
update text
KelvinTegelaar Jan 16, 2026
8b94057
JSON convert fix
KelvinTegelaar Jan 16, 2026
59805ed
Fixes cippcatemplate
KelvinTegelaar Jan 16, 2026
37d53a2
Refactor mailbox permissions caching to use batching
JohnDuprey Jan 16, 2026
fb72b2a
Improve AllTenants handling in Invoke-ExecCIPPDBCache
JohnDuprey Jan 16, 2026
5bba822
Enhance MFA state reporting and CA policy resolution
JohnDuprey Jan 16, 2026
c9d2940
Fix typo in log message in Push-ExecCIPPDBCache.ps1
JohnDuprey Jan 16, 2026
f6f26d5
Update default version to 10.0.0
JohnDuprey Jan 16, 2026
2f19fe5
minor prerelease change
KelvinTegelaar Jan 16, 2026
6cc72db
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into…
KelvinTegelaar Jan 16, 2026
47b5958
Merge pull request #1772 from KelvinTegelaar/dev
KelvinTegelaar Jan 16, 2026
c5eeab1
Change log message severity from Info to Debug
JohnDuprey Jan 16, 2026
6d85886
Filter MFADevices to exclude password auth methods
JohnDuprey Jan 16, 2026
869e768
Update default and latest version to 10.0.1
JohnDuprey Jan 16, 2026
d76bdea
Merge pull request #1774 from KelvinTegelaar/dev
JohnDuprey Jan 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ ExcludedTenants
SendNotifications/config.json
.env
Output/
node_modules/.yarn-integrity
yarn.lock

# Cursor IDE
.cursor/rules
18 changes: 18 additions & 0 deletions CIPPTimers.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,23 @@
"Priority": 21,
"RunOnProcessor": true,
"IsSystem": true
},
{
"Id": "9a7f8e6d-5c4b-3a2d-1e0f-9b8c7d6e5f4a",
"Command": "Start-CIPPDBCacheOrchestrator",
"Description": "Timer to collect and cache Microsoft Graph data for all tenants",
"Cron": "0 0 3 * * *",
"Priority": 22,
"RunOnProcessor": true,
"IsSystem": true
},
{
"Id": "1f2e3d4c-5b6a-7c8d-9e0f-1a2b3c4d5e6f",
"Command": "Start-TestsOrchestrator",
"Description": "Timer to run security and compliance tests against cached data",
"Cron": "0 0 4 * * *",
"Priority": 23,
"RunOnProcessor": true,
"IsSystem": true
}
]
19 changes: 19 additions & 0 deletions ExampleReportTemplate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$Table = Get-CippTable -tablename 'CippReportTemplates'

# Dynamically discover all ZTNA test files
$TestFiles = Get-ChildItem "C:\Github\CIPP-API\Modules\CIPPCore\Public\Tests\Invoke-CippTestZTNA*.ps1" | Sort-Object Name
$AllTestIds = $TestFiles.BaseName | ForEach-Object { $_ -replace 'Invoke-CippTestZTNA', 'ZTNA' }

Write-Host "Discovered $($AllTestIds.Count) ZTNA tests"

$Entity = @{
RowKey = 'd5d1e123-bce0-482d-971f-be6ed820dd92'
PartitionKey = 'ReportingTemplate'
IdentityTests = [string]($AllTestIds | ConvertTo-Json -Compress)
Description = 'Complete Zero Trust Network Assessment Report'
Name = 'Full ZTNA Report'
}

Add-CIPPAzDataTableEntity @Table -Entity $Entity -Force

Write-Host "Report template created successfully with ID: $($Entity.RowKey)"
91 changes: 91 additions & 0 deletions Modules/CIPPCore/Public/Add-CIPPDbItem.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
function Add-CIPPDbItem {
<#
.SYNOPSIS
Add items to the CIPP Reporting database

.DESCRIPTION
Adds items to the CippReportingDB table with support for bulk inserts and count mode

.PARAMETER TenantFilter
The tenant domain or GUID (used as partition key)

.PARAMETER Type
The type of data being stored (used in row key)

.PARAMETER Data
Array of items to add to the database

.PARAMETER Count
If specified, stores a single row with count of each object property as separate properties

.EXAMPLE
Add-CIPPDbItem -TenantFilter 'contoso.onmicrosoft.com' -Type 'Groups' -Data $GroupsData

.EXAMPLE
Add-CIPPDbItem -TenantFilter 'contoso.onmicrosoft.com' -Type 'Groups' -Data $GroupsData -Count
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$TenantFilter,

[Parameter(Mandatory = $true)]
[string]$Type,

[Parameter(Mandatory = $true)]
[AllowEmptyCollection()]
[array]$Data,

[Parameter(Mandatory = $false)]
[switch]$Count
)

try {
$Table = Get-CippTable -tablename 'CippReportingDB'

# Helper function to format RowKey values by removing disallowed characters
function Format-RowKey {
param([string]$RowKey)

# Remove disallowed characters: / \ # ? and control characters (U+0000 to U+001F and U+007F to U+009F)
$sanitized = $RowKey -replace '[/\\#?]', '_' -replace '[\u0000-\u001F\u007F-\u009F]', ''

return $sanitized
}

if ($Count) {
$Entity = @{
PartitionKey = $TenantFilter
RowKey = Format-RowKey "$Type-Count"
DataCount = [int]$Data.Count
}

Add-CIPPAzDataTableEntity @Table -Entity $Entity -Force | Out-Null

} else {
#Get the existing type entries and nuke them. This ensures we don't have stale data.
$Filter = "PartitionKey eq '{0}' and RowKey ge '{1}-' and RowKey lt '{1}0'" -f $TenantFilter, $Type
$ExistingEntities = Get-CIPPAzDataTableEntity @Table -Filter $Filter
if ($ExistingEntities) {
Remove-AzDataTableEntity @Table -Entity $ExistingEntities -Force | Out-Null
}
$Entities = foreach ($Item in $Data) {
$ItemId = $Item.id ?? $Item.ExternalDirectoryObjectId ?? $Item.Identity ?? $Item.skuId
@{
PartitionKey = $TenantFilter
RowKey = Format-RowKey "$Type-$ItemId"
Data = [string]($Item | ConvertTo-Json -Depth 10 -Compress)
Type = $Type
}
}
Add-CIPPAzDataTableEntity @Table -Entity $Entities -Force | Out-Null

}

Write-LogMessage -API 'CIPPDbItem' -tenant $TenantFilter -message "Added $($Data.Count) items of type $Type$(if ($Count) { ' (count mode)' })" -sev Debug

} catch {
Write-LogMessage -API 'CIPPDbItem' -tenant $TenantFilter -message "Failed to add items of type $Type : $($_.Exception.Message)" -sev Error
throw
}
}
55 changes: 48 additions & 7 deletions Modules/CIPPCore/Public/Add-CIPPScheduledTask.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ function Add-CIPPScheduledTask {
return "Could not run task: $ErrorMessage"
}
} else {
if (!$Task.RowKey) {
$RowKey = (New-Guid).Guid
} else {
$RowKey = $Task.RowKey
}

if ($DisallowDuplicateName) {
$Filter = "PartitionKey eq 'ScheduledTask' and Name eq '$($Task.Name)'"
$Filter = "PartitionKey eq 'ScheduledTask' and Name eq '$($Task.Name)' and TaskState ne 'Completed' and TaskState ne 'Failed'"
$ExistingTask = (Get-CIPPAzDataTableEntity @Table -Filter $Filter)
if ($ExistingTask) {
return "Task with name $($Task.Name) already exists"
Expand Down Expand Up @@ -110,11 +116,7 @@ function Add-CIPPScheduledTask {
}
$AdditionalProperties = ([PSCustomObject]$AdditionalProperties | ConvertTo-Json -Compress)
if ($Parameters -eq 'null') { $Parameters = '' }
if (!$Task.RowKey) {
$RowKey = (New-Guid).Guid
} else {
$RowKey = $Task.RowKey
}


$Recurrence = if ([string]::IsNullOrEmpty($task.Recurrence.value)) {
$task.Recurrence
Expand Down Expand Up @@ -258,7 +260,46 @@ function Add-CIPPScheduledTask {
return "Error - Could not add task: $ErrorMessage"
}
Write-LogMessage -headers $Headers -API 'ScheduledTask' -message "Added task $($entity.Name) with ID $($entity.RowKey)" -Sev 'Info' -Tenant $tenantFilter
return "Successfully added task: $($entity.Name)"

# Calculate relative time for next run
$scheduledEpoch = [int64]$entity.ScheduledTime
$currentTime = [datetime]::UtcNow

if ($scheduledEpoch -eq 0 -or $scheduledEpoch -le ([int64](($currentTime) - (Get-Date '1/1/1970')).TotalSeconds)) {
# Task will run at next 15-minute interval - calculate efficiently
$minutesToAdd = 15 - ($currentTime.Minute % 15)
$nextRunTime = $currentTime.AddMinutes($minutesToAdd).AddSeconds(-$currentTime.Second).AddMilliseconds(-$currentTime.Millisecond)
$timeUntilRun = $nextRunTime - $currentTime
} else {
# Task is scheduled for a specific time in the future
$scheduledTime = [datetime]'1/1/1970' + [TimeSpan]::FromSeconds($scheduledEpoch)
$timeUntilRun = $scheduledTime - $currentTime
}

# Format relative time
$relativeTime = switch ($timeUntilRun.TotalMinutes) {
{ $_ -ge 1440 } {
$days = [Math]::Floor($timeUntilRun.TotalDays)
$hours = $timeUntilRun.Hours
$result = "$days day$(if ($days -ne 1) { 's' })"
if ($hours -gt 0) { $result += " and $hours hour$(if ($hours -ne 1) { 's' })" }
$result
break
}
{ $_ -ge 60 } {
$hours = [Math]::Floor($timeUntilRun.TotalHours)
$minutes = $timeUntilRun.Minutes
$result = "$hours hour$(if ($hours -ne 1) { 's' })"
if ($minutes -gt 0) { $result += " and $minutes minute$(if ($minutes -ne 1) { 's' })" }
$result
break
}
{ $_ -ge 2 } { "about $([Math]::Round($_)) minutes"; break }
{ $_ -ge 1 } { 'about 1 minute'; break }
default { 'less than a minute' }
}

return "Successfully added task: $($entity.Name). It will run in $relativeTime."
}
} catch {
Write-Warning "Failed to add scheduled task: $($_.Exception.Message)"
Expand Down
101 changes: 101 additions & 0 deletions Modules/CIPPCore/Public/Add-CippTestResult.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
function Add-CippTestResult {
<#
.SYNOPSIS
Adds a test result to the CIPP test results database

.DESCRIPTION
Stores test result data in the CippTestResults table with tenant and test ID as keys

.PARAMETER TenantFilter
The tenant domain or GUID for the test result

.PARAMETER TestId
Unique identifier for the test

.PARAMETER Status
Test status (e.g., Pass, Fail, Skip)

.PARAMETER ResultMarkdown
Markdown formatted result details

.PARAMETER Risk
Risk level (e.g., High, Medium, Low)

.PARAMETER Name
Display name of the test

.PARAMETER Pillar
Security pillar category

.PARAMETER UserImpact
Impact level on users

.PARAMETER ImplementationEffort
Effort required for implementation

.PARAMETER Category
Test category or classification

.EXAMPLE
Add-CippTestResult -TenantFilter 'contoso.onmicrosoft.com' -TestId 'MFA-001' -Status 'Pass' -Name 'MFA Enabled' -Risk 'High'
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$TenantFilter,

[Parameter(Mandatory = $true)]
[string]$TestId,

[Parameter(Mandatory = $false)]
[string]$testType = 'Identity',

[Parameter(Mandatory = $true)]
[string]$Status,

[Parameter(Mandatory = $false)]
[string]$ResultMarkdown,

[Parameter(Mandatory = $false)]
[string]$Risk,

[Parameter(Mandatory = $false)]
[string]$Name,

[Parameter(Mandatory = $false)]
[string]$Pillar,

[Parameter(Mandatory = $false)]
[string]$UserImpact,

[Parameter(Mandatory = $false)]
[string]$ImplementationEffort,

[Parameter(Mandatory = $false)]
[string]$Category
)

try {
$Table = Get-CippTable -tablename 'CippTestResults'

$Entity = @{
PartitionKey = $TenantFilter
RowKey = $TestId
Status = $Status
ResultMarkdown = $ResultMarkdown ?? ''
Risk = $Risk ?? ''
Name = $Name ?? ''
Pillar = $Pillar ?? ''
UserImpact = $UserImpact ?? ''
ImplementationEffort = $ImplementationEffort ?? ''
Category = $Category ?? ''
TestType = $TestType
}

Add-CIPPAzDataTableEntity @Table -Entity $Entity -Force
Write-LogMessage -API 'CIPPTestResults' -tenant $TenantFilter -message "Added test result: $TestId - $Status" -sev Debug
} catch {
Write-LogMessage -API 'CIPPTestResults' -tenant $TenantFilter -message "Failed to add test result: $($_.Exception.Message)" -sev Error
throw
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ function Get-CIPPAlertAppSecretExpiry {
AppName = $App.displayName
AppId = $App.appId
Expires = $Credential.endDateTime
SecretName = $Credential.displayName
SecretID = $Credential.keyId
Tenant = $TenantFilter
}
$AlertData.Add($Message)
Expand Down
Loading