Skip to content

Commit 874ddfd

Browse files
committed
Added Docs
1 parent ab5bca9 commit 874ddfd

File tree

86 files changed

+3202
-247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3202
-247
lines changed

Modules/CIPPCore/Public/CippQueue/Invoke-ListCippQueue.ps1

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,64 @@
11
function Invoke-ListCippQueue {
22
<#
3+
.SYNOPSIS
4+
List CIPP queue entries and their task status
5+
6+
.DESCRIPTION
7+
Retrieves a list of CIPP queue entries with detailed task status, progress information, and completion statistics
8+
39
.FUNCTIONALITY
410
Entrypoint
511
.ROLE
612
CIPP.Core.Read
13+
14+
.NOTES
15+
Group: CIPP Queue
16+
Summary: List CIPP Queue
17+
Description: Retrieves a list of CIPP queue entries from the last 3 hours with detailed task status, progress tracking, and completion statistics
18+
Tags: Queue,Monitoring,Progress
19+
Response: Returns an array of queue objects with the following properties:
20+
Response: - PartitionKey (string): Queue partition key
21+
Response: - RowKey (string): Queue unique identifier
22+
Response: - Name (string): Queue name or description
23+
Response: - Link (string): Reference link for the queue
24+
Response: - Reference (string): Additional reference information
25+
Response: - TotalTasks (number): Total number of tasks in the queue
26+
Response: - CompletedTasks (number): Number of completed tasks (including failed)
27+
Response: - RunningTasks (number): Number of currently running tasks
28+
Response: - FailedTasks (number): Number of failed tasks
29+
Response: - PercentComplete (number): Percentage of tasks completed
30+
Response: - PercentFailed (number): Percentage of tasks that failed
31+
Response: - PercentRunning (number): Percentage of tasks currently running
32+
Response: - Tasks (array): Array of individual task objects with timestamp, name, and status
33+
Response: - Status (string): Overall queue status: Running, Completed, or Completed (with errors)
34+
Response: - Timestamp (string): Queue creation timestamp
35+
Example: [
36+
{
37+
"PartitionKey": "CippQueue",
38+
"RowKey": "12345678-1234-1234-1234-123456789012",
39+
"Name": "Tenant License Update",
40+
"Link": "https://example.com/reference",
41+
"Reference": "License audit 2024",
42+
"TotalTasks": 10,
43+
"CompletedTasks": 8,
44+
"RunningTasks": 1,
45+
"FailedTasks": 1,
46+
"PercentComplete": 80.0,
47+
"PercentFailed": 10.0,
48+
"PercentRunning": 10.0,
49+
"Tasks": [
50+
{
51+
"Timestamp": "2024-01-15T10:30:00Z",
52+
"Name": "Update tenant A",
53+
"Status": "Completed"
54+
}
55+
],
56+
"Status": "Running",
57+
"Timestamp": "2024-01-15T10:00:00Z"
58+
}
59+
]
760
#>
61+
[CmdletBinding()]
862
param($Request = $null, $TriggerMetadata = $null)
963

1064
if ($Request) {
@@ -28,10 +82,12 @@ function Invoke-ListCippQueue {
2882
if ($Tasks.Status -notcontains 'Running' -and ($TaskStatus.Completed + $TaskStatus.Failed) -ge $Queue.TotalTasks) {
2983
if ($Tasks.Status -notcontains 'Failed') {
3084
$Queue.Status = 'Completed'
31-
} else {
85+
}
86+
else {
3287
$Queue.Status = 'Completed (with errors)'
3388
}
34-
} else {
89+
}
90+
else {
3591
$Queue.Status = 'Running'
3692
}
3793
}
@@ -66,7 +122,8 @@ function Invoke-ListCippQueue {
66122
StatusCode = [HttpStatusCode]::OK
67123
Body = @($QueueData)
68124
})
69-
} else {
125+
}
126+
else {
70127
return $QueueData
71128
}
72129
}

Modules/CIPPCore/Public/CippQueue/Invoke-RemoveCippQueue.ps1

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
function Invoke-RemoveCippQueue {
2+
<#
3+
.SYNOPSIS
4+
Remove all entries from the CIPP queue and task history
5+
6+
.DESCRIPTION
7+
Clears all entries from the CIPP queue and associated task history tables for a full reset of queue data.
8+
9+
.FUNCTIONALITY
10+
Entrypoint
11+
.ROLE
12+
CIPP.Core.ReadWrite
13+
14+
.NOTES
15+
Group: CIPP Queue
16+
Summary: Remove CIPP Queue
17+
Description: Clears all entries from the CIPP queue and associated task history tables for a full reset of queue data. This is typically used for maintenance or troubleshooting.
18+
Tags: Queue,Maintenance,Reset
19+
Response: Returns an object with the following properties:
20+
Response: - Results (array): Array with a single string indicating the history was cleared
21+
Response: On success: { "Results": ["History cleared"] } with HTTP 200 status
22+
Example: {
23+
"Results": ["History cleared"]
24+
}
25+
#>
26+
param($Request, $TriggerMetadata)
27+
28+
$APIName = $Request.Params.CIPPEndpoint
29+
$Headers = $Request.Headers
30+
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
31+
32+
$CippQueue = Get-CippTable -TableName 'CippQueue'
33+
Clear-AzDataTable @CippQueue
34+
$CippQueueTasks = Get-CippTable -TableName 'CippQueueTasks'
35+
Clear-AzDataTable @CippQueueTasks
36+
37+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
38+
StatusCode = [HttpStatusCode]::OK
39+
Body = @{Results = @('History cleared') }
40+
})
41+
}
42+
143
function Invoke-RemoveCippQueue {
244
<#
345
.FUNCTIONALITY

Modules/CIPPCore/Public/CustomData/Invoke-CustomDataSync.ps1

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
function Invoke-CustomDataSync {
2+
<#
3+
.SYNOPSIS
4+
Synchronize custom data mappings to directory objects
5+
6+
.DESCRIPTION
7+
Synchronizes custom data from CIPP extension cache to directory objects (e.g., users) in Microsoft Graph, based on mapping configuration.
8+
9+
.FUNCTIONALITY
10+
Entrypoint
11+
.ROLE
12+
CIPP.Extension.ReadWrite
13+
14+
.NOTES
15+
Group: Custom Data
16+
Summary: Custom Data Sync
17+
Description: Synchronizes custom data from CIPP extension cache to directory objects (e.g., users) in Microsoft Graph, based on mapping configuration. Supports bulk PATCH operations and flexible mapping logic.
18+
Tags: Custom Data,Directory,Graph API,Sync
19+
Parameter: TenantFilter (string) [parameter] - Target tenant identifier for synchronization
20+
Response: No direct response. Writes progress and error information to logs. Performs PATCH requests to Microsoft Graph for each mapped object.
21+
Example: Synchronizes extension attributes for users in a tenant based on custom mapping configuration.
22+
#>
223
param(
324
$TenantFilter
425
)
@@ -45,7 +66,8 @@ function Invoke-CustomDataSync {
4566
$SyncConfig
4667
if ($DirectoryObjectQueries | Where-Object { $_.id -eq $Query.id }) {
4768
continue
48-
} else {
69+
}
70+
else {
4971
$DirectoryObjectQueries.Add($Query)
5072
}
5173
}
@@ -91,7 +113,8 @@ function Invoke-CustomDataSync {
91113
break
92114
}
93115
}
94-
} else {
116+
}
117+
else {
95118
$DirectoryObject = $DirectoryObjects | Where-Object { $_.$DestinationMatchProperty -eq $Row.$SourceMatchProperty }
96119
}
97120

@@ -118,10 +141,12 @@ function Invoke-CustomDataSync {
118141
Write-Host "Creating new object for $($Props[1])"
119142
$PatchObjects[$ObjectUrl][$Props[0]][$Props[1]] = $Row.$ExtensionSyncProperty
120143
}
121-
} else {
144+
}
145+
else {
122146
$PatchObjects[$ObjectUrl][$CustomDataAttribute] = $Row.$ExtensionSyncProperty
123147
}
124-
} elseif ($DatasetConfig.type -eq 'array') {
148+
}
149+
elseif ($DatasetConfig.type -eq 'array') {
125150
Write-Warning "Processing array data for $($CustomDataAttribute) on $($DirectoryObject.id) - found $($Row.Count) entries"
126151
#Write-Information ($Row | ConvertTo-Json -Depth 10)
127152
if ($DatasetConfig.select) {
@@ -134,7 +159,8 @@ function Invoke-CustomDataSync {
134159

135160
$Data = if ($DatasetConfig.storeAs -eq 'json') {
136161
$Row | ConvertTo-Json -Depth 5 -Compress
137-
} else {
162+
}
163+
else {
138164
$Row
139165
}
140166

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecCombinedSetup.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ function Invoke-ExecCombinedSetup {
8787
if ($Request.Body.ApplicationSecret) { $Secret.ApplicationSecret = $Request.Body.ApplicationSecret }
8888
Add-CIPPAzDataTableEntity @DevSecretsTable -Entity $Secret -Force
8989
$Results.add('Manual credentials have been set in the DevSecrets table.')
90-
} else {
90+
}
91+
else {
9192
if ($Request.Body.tenantId) {
9293
Set-AzKeyVaultSecret -VaultName $kv -Name 'tenantid' -SecretValue (ConvertTo-SecureString -String $Request.Body.tenantId -AsPlainText -Force)
9394
$Results.add('Set tenant ID in Key Vault.')
@@ -108,7 +109,8 @@ function Invoke-ExecCombinedSetup {
108109
$Results.add('Setup is now complete. You may navigate away from this page and start using CIPP.')
109110
#one more force of reauth so env vars update.
110111
$auth = Get-CIPPAuthentication
111-
} catch {
112+
}
113+
catch {
112114
$Results = [pscustomobject]@{'Results' = "Failed. $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.message)"; severity = 'failed' }
113115
}
114116

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecCreateSAMApp.ps1

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,31 @@ using namespace System.Net
22

33
function Invoke-ExecCreateSAMApp {
44
<#
5+
.SYNOPSIS
6+
Create or update SAM (Service Account Management) application registration
7+
8+
.DESCRIPTION
9+
Creates or updates a SAM application registration in Microsoft Graph for CIPP setup, including required service principals and secrets
10+
511
.FUNCTIONALITY
612
Entrypoint,AnyTenant
713
.ROLE
814
CIPP.AppSettings.ReadWrite
15+
16+
.NOTES
17+
Group: CIPP Setup
18+
Summary: Create SAM App Registration
19+
Description: Creates or updates a SAM application registration in Microsoft Graph for CIPP setup, including required service principals (Defender, Teams, O365 Management, Partner Center) and stores secrets in Azure Key Vault or development storage
20+
Tags: CIPP,SAM,App Registration,Setup,Graph API
21+
Parameter: Request.body (object) - Contains access token for Microsoft Graph authentication
22+
Response: Returns an object with the following properties:
23+
Response: - message (string): Success message with application ID and status
24+
Response: - severity (string): Success or failed status
25+
Example: {
26+
"message": "Successfully created the application registration. The application ID is 12345678-1234-1234-1234-123456789012. You may continue to the next step.",
27+
"severity": "success"
28+
}
29+
Error: Returns error details if the operation fails
930
#>
1031
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
1132
[CmdletBinding()]
@@ -31,7 +52,8 @@ function Invoke-ExecCreateSAMApp {
3152
$app.web.redirectUris = @("$($url)/authredirect")
3253
$app = ConvertTo-Json -Depth 15 -Compress -InputObject $app
3354
Invoke-RestMethod "https://graph.microsoft.com/v1.0/applications/$($AppId.id)" -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method PATCH -Body $app -ContentType 'application/json'
34-
} else {
55+
}
56+
else {
3557
$state = 'created'
3658
$ModuleBase = Get-Module -Name CIPPCore | Select-Object -ExpandProperty ModuleBase
3759
$SamManifestFile = Get-Item (Join-Path $ModuleBase 'Public\SAMManifest.json')
@@ -44,28 +66,33 @@ function Invoke-ExecCreateSAMApp {
4466
try {
4567
try {
4668
$SPNDefender = (Invoke-RestMethod 'https://graph.microsoft.com/v1.0/servicePrincipals' -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method POST -Body "{ `"appId`": `"fc780465-2017-40d4-a0c5-307022471b92`" }" -ContentType 'application/json')
47-
} catch {
69+
}
70+
catch {
4871
Write-Information "didn't deploy spn for defender, probably already there."
4972
}
5073
try {
5174
$SPNTeams = (Invoke-RestMethod 'https://graph.microsoft.com/v1.0/servicePrincipals' -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method POST -Body "{ `"appId`": `"48ac35b8-9aa8-4d74-927d-1f4a14a0b239`" }" -ContentType 'application/json')
52-
} catch {
75+
}
76+
catch {
5377
Write-Information "didn't deploy spn for Teams, probably already there."
5478
}
5579
try {
5680
$SPNO365Manage = (Invoke-RestMethod 'https://graph.microsoft.com/v1.0/servicePrincipals' -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method POST -Body "{ `"appId`": `"c5393580-f805-4401-95e8-94b7a6ef2fc2`" }" -ContentType 'application/json')
57-
} catch {
81+
}
82+
catch {
5883
Write-Information "didn't deploy spn for O365 Management, probably already there."
5984
}
6085
try {
6186
$SPNPartnerCenter = (Invoke-RestMethod 'https://graph.microsoft.com/v1.0/servicePrincipals' -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method POST -Body "{ `"appId`": `"fa3d9a0c-3fb0-42cc-9193-47c7ecd2edbd`" }" -ContentType 'application/json')
62-
} catch {
87+
}
88+
catch {
6389
Write-Information "didn't deploy spn for PartnerCenter, probably already there."
6490
}
6591
$SPN = (Invoke-RestMethod 'https://graph.microsoft.com/v1.0/servicePrincipals' -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method POST -Body "{ `"appId`": `"$($AppId.appId)`" }" -ContentType 'application/json')
6692
Start-Sleep 2
6793
$attempt ++
68-
} catch {
94+
}
95+
catch {
6996
$attempt ++
7097
}
7198
} until ($attempt -gt 3)
@@ -83,7 +110,8 @@ function Invoke-ExecCreateSAMApp {
83110
$Secret | Add-Member -MemberType NoteProperty -Name 'applicationsecret' -Value $AppPassword -Force
84111
Write-Information ($Secret | ConvertTo-Json -Depth 5)
85112
Add-CIPPAzDataTableEntity @DevSecretsTable -Entity $Secret -Force
86-
} else {
113+
}
114+
else {
87115

88116
Set-AzKeyVaultSecret -VaultName $kv -Name 'tenantid' -SecretValue (ConvertTo-SecureString -String $TenantId -AsPlainText -Force)
89117
Set-AzKeyVaultSecret -VaultName $kv -Name 'applicationid' -SecretValue (ConvertTo-SecureString -String $Appid.appId -AsPlainText -Force)
@@ -100,7 +128,8 @@ function Invoke-ExecCreateSAMApp {
100128
$Results = @{'message' = "Succesfully $state the application registration. The application ID is $($AppId.appid). You may continue to the next step."; severity = 'success' }
101129
}
102130

103-
} catch {
131+
}
132+
catch {
104133
$Results = [pscustomobject]@{'Results' = "Failed. $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.message)"; severity = 'failed' }
105134
}
106135

0 commit comments

Comments
 (0)