Skip to content

Commit ac8b589

Browse files
latest dev update
1 parent 6ac1879 commit ac8b589

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using namespace System.Net
2+
3+
Function Invoke-ExecCombinedSetup {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint,AnyTenant
7+
.ROLE
8+
CIPP.AppSettings.ReadWrite.
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
#Make arraylist of Results
13+
$Results = [System.Collections.ArrayList]::new()
14+
try {
15+
if ($request.body.selectedBaselines -and $request.body.baselineOption -eq 'downloadBaselines') {
16+
#do a single download of the selected baselines.
17+
foreach ($template in $request.body.selectedBaselines) {
18+
$object = @{
19+
TenantFilter = 'No tenant'
20+
Name = "Download Single Baseline: $($template.value)"
21+
Command = @{
22+
value = 'New-CIPPTemplateRun'
23+
}
24+
Parameters = @{
25+
TemplateSettings = @{
26+
ca = $false
27+
intuneconfig = $false
28+
intunecompliance = $false
29+
intuneprotection = $false
30+
templateRepo = @{
31+
label = $Template.label
32+
value = $template.value
33+
addedFields = @{
34+
branch = 'main'
35+
}
36+
}
37+
templateRepoBranch = @{
38+
label = 'main'
39+
value = 'main'
40+
}
41+
standardsconfig = $true
42+
groupTemplates = $true
43+
policyTemplates = $true
44+
caTemplates = $true
45+
}
46+
}
47+
ScheduledTime = 0
48+
}
49+
$null = Add-CIPPScheduledTask -task $object -hidden $false -DisallowDuplicateName $true -Headers $Request.Headers
50+
$Results.add("Scheduled download of baseline: $($template.value)")
51+
}
52+
}
53+
if ($Request.body.email -or $Request.body.webhook) {
54+
$notificationConfig = $request.body
55+
$notificationResults = Set-CIPPNotificationConfig @notificationConfig
56+
$Results.add($notificationResults)
57+
}
58+
$Results.add('Setup is now complete. You may navigate away from this page and start using CIPP.')
59+
#one more force of reauth so env vars update.
60+
$auth = Get-CIPPAuthentication
61+
} catch {
62+
$Results = [pscustomobject]@{'Results' = "Failed. $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.message)"; severity = 'failed' }
63+
}
64+
65+
# Associate values to output bindings by calling 'Push-OutputBinding'.
66+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
67+
StatusCode = [HttpStatusCode]::OK
68+
Body = $Results
69+
})
70+
71+
}

0 commit comments

Comments
 (0)