Skip to content

Commit 0704685

Browse files
authored
Merge pull request #73 from KelvinTegelaar/master
[pull] master from KelvinTegelaar:master
2 parents f42eecd + c8da99d commit 0704685

17 files changed

+92
-87
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: Build and deploy Powershell project to Azure Function App - cippjta72-proc
5+
6+
on:
7+
push:
8+
branches:
9+
- dev
10+
workflow_dispatch:
11+
12+
env:
13+
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
14+
15+
jobs:
16+
deploy:
17+
runs-on: windows-latest
18+
19+
steps:
20+
- name: 'Checkout GitHub Action'
21+
uses: actions/checkout@v4
22+
23+
- name: 'Run Azure Functions Action'
24+
uses: Azure/functions-action@v1
25+
id: fa
26+
with:
27+
app-name: 'cippjta72-proc'
28+
slot-name: 'Production'
29+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
30+
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_A53AC5C52A55459DA0A3D8F1716638CB }}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecEditTemplate.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Function Invoke-ExecEditTemplate {
2424
$OriginalTemplate = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'IntuneTemplate' and RowKey eq '$GUID'"
2525
$OriginalTemplate = ($OriginalTemplate.JSON | ConvertFrom-Json -Depth 100)
2626
$RawJSON = $OriginalTemplate.RAWJson
27-
Set-CIPPIntuneTemplate -RawJSON $RawJSON -GUID $GUID -DisplayName $Request.body.displayName -Description $Request.body.description -templateType $OriginalTemplate.Type
27+
Set-CIPPIntuneTemplate -RawJSON $RawJSON -GUID $GUID -DisplayName $Request.body.displayName -Description $Request.body.description -templateType $OriginalTemplate.Type -Headers $Request.Headers
2828
} else {
2929
$Table.Force = $true
3030

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-ExecAssignPolicy.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Function Invoke-ExecAssignPolicy {
2020

2121
$results = try {
2222
if ($AssignTo) {
23-
$assign = Set-CIPPAssignedPolicy -PolicyId $ID -TenantFilter $tenant -GroupName $AssignTo -Type $Request.body.Type
23+
$assign = Set-CIPPAssignedPolicy -PolicyId $ID -TenantFilter $tenant -GroupName $AssignTo -Type $Request.body.Type -Headers $Request.Headers
2424
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($Tenant) -message "Assigned policy $($Displayname) to $AssignTo" -Sev 'Info'
2525
}
2626
"Successfully edited policy for $($Tenant)"

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ListBPATemplates.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Function Invoke-ListBPATemplates {
3131
$Templates = Get-CIPPAzDataTableEntity @Table -Filter $Filter
3232

3333
if ($Request.Query.RawJson) {
34-
$Templates
34+
$Templates = $Templates.JSON | ConvertFrom-Json
3535
} else {
3636
$Templates = $Templates | ForEach-Object {
3737
$Template = $_.JSON | ConvertFrom-Json

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tools/GitHub/Invoke-ExecGitHubAction.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Invoke-ExecGitHubAction {
2626
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json).GitHub
2727

2828
if (!$Configuration.Enabled) {
29-
$Response = Invoke-RestMethod -Uri 'https://cippy.azurewebsites.net/api/ExecGitHubAction' -Method POST -Body ($Action | ConvertTo-Json -Depth 10) -ContentType 'application/json'
29+
$Response = Invoke-RestMethod -Uri 'https://cippy.azurewebsites.net/api/ExecGitHubAction' -Method POST -Body ($Parameters | ConvertTo-Json -Depth 10) -ContentType 'application/json'
3030
$Results = $Response.Results
3131
$Metadata = $Response.Metadata
3232
} else {

Modules/CIPPCore/Public/New-CIPPRestore.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function New-CIPPRestore {
1111
Write-Host "Scheduled Restore psproperties: $(([pscustomobject]$RestoreValues).psobject.Properties)"
1212
Write-LogMessage -headers $Headers -API $APINAME -message 'Restored backup' -Sev 'Debug'
1313
$RestoreData = foreach ($ScheduledBackup in ([pscustomobject]$RestoreValues).psobject.Properties.Name | Where-Object { $_ -notin 'email', 'webhook', 'psa', 'backup', 'overwrite' }) {
14-
New-CIPPRestoreTask -Task $ScheduledBackup -TenantFilter $TenantFilter -backup $RestoreValues.backup.value -overwrite $RestoreValues.overwrite
14+
New-CIPPRestoreTask -Task $ScheduledBackup -TenantFilter $TenantFilter -backup $RestoreValues.backup.value -overwrite $RestoreValues.overwrite -Headers $Headers -APIName $APIName
1515
}
1616
return $RestoreData
1717
}

Modules/CIPPCore/Public/New-CIPPRestoreTask.ps1

+10-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ function New-CIPPRestoreTask {
44
$Task,
55
$TenantFilter,
66
$backup,
7-
$overwrite
7+
$overwrite,
8+
$APINAME,
9+
$Headers
810
)
911
$Table = Get-CippTable -tablename 'ScheduledBackup'
1012
$BackupData = Get-CIPPAzDataTableEntity @Table -Filter "RowKey eq '$backup'"
@@ -99,7 +101,7 @@ function New-CIPPRestoreTask {
99101
$BackupConfig = $BackupData.intuneconfig | ConvertFrom-Json
100102
foreach ($backup in $backupConfig) {
101103
try {
102-
Set-CIPPIntunePolicy -TemplateType $backup.Type -TenantFilter $TenantFilter -DisplayName $backup.DisplayName -Description $backup.Description -RawJSON ($backup.TemplateJson) -ErrorAction SilentlyContinue
104+
Set-CIPPIntunePolicy -TemplateType $backup.Type -TenantFilter $TenantFilter -DisplayName $backup.DisplayName -Description $backup.Description -RawJSON ($backup.TemplateJson) -Headers $Headers -APINAME $APINAME -ErrorAction SilentlyContinue
103105
} catch {
104106
$ErrorMessage = Get-CippException -Exception $_
105107
"Could not restore Intune Configuration $DisplayName : $($ErrorMessage.NormalizedError) "
@@ -112,7 +114,7 @@ function New-CIPPRestoreTask {
112114
$BackupConfig = $BackupData.intunecompliance | ConvertFrom-Json
113115
foreach ($backup in $backupConfig) {
114116
try {
115-
Set-CIPPIntunePolicy -TemplateType $backup.Type -TenantFilter $TenantFilter -DisplayName $backup.DisplayName -Description $backup.Description -RawJSON ($backup.TemplateJson) -ErrorAction SilentlyContinue
117+
Set-CIPPIntunePolicy -TemplateType $backup.Type -TenantFilter $TenantFilter -DisplayName $backup.DisplayName -Description $backup.Description -RawJSON ($backup.TemplateJson) -Headers $Headers -APINAME $APINAME -ErrorAction SilentlyContinue
116118
} catch {
117119
$ErrorMessage = Get-CippException -Exception $_
118120
"Could not restore Intune Compliance $DisplayName : $($ErrorMessage.NormalizedError) "
@@ -126,7 +128,7 @@ function New-CIPPRestoreTask {
126128
$BackupConfig = $BackupData.intuneprotection | ConvertFrom-Json
127129
foreach ($backup in $backupConfig) {
128130
try {
129-
Set-CIPPIntunePolicy -TemplateType $backup.Type -TenantFilter $TenantFilter -DisplayName $backup.DisplayName -Description $backup.Description -RawJSON ($backup.TemplateJson) -ErrorAction SilentlyContinue
131+
Set-CIPPIntunePolicy -TemplateType $backup.Type -TenantFilter $TenantFilter -DisplayName $backup.DisplayName -Description $backup.Description -RawJSON ($backup.TemplateJson) -Headers $Headers -APINAME $APINAME -ErrorAction SilentlyContinue
130132
} catch {
131133
$ErrorMessage = Get-CippException -Exception $_
132134
"Could not restore Intune Protection $DisplayName : $($ErrorMessage.NormalizedError) "
@@ -281,7 +283,7 @@ function New-CIPPRestoreTask {
281283
foreach ($param in $ruleparams) {
282284
if ($rule.PSObject.Properties[$param]) {
283285
if ($param -eq 'Enabled') {
284-
$cmdparams[$param] = if ($rule.State -eq 'Enabled') {$true} else {$false}
286+
$cmdparams[$param] = if ($rule.State -eq 'Enabled') { $true } else { $false }
285287
} else {
286288
$cmdparams[$param] = $rule.$param
287289
}
@@ -301,7 +303,7 @@ function New-CIPPRestoreTask {
301303
foreach ($param in $ruleparams) {
302304
if ($rule.PSObject.Properties[$param]) {
303305
if ($param -eq 'Enabled') {
304-
$cmdparams[$param] = if ($rule.State -eq 'Enabled') {$true} else {$false}
306+
$cmdparams[$param] = if ($rule.State -eq 'Enabled') { $true } else { $false }
305307
} else {
306308
$cmdparams[$param] = $rule.$param
307309
}
@@ -438,7 +440,7 @@ function New-CIPPRestoreTask {
438440
foreach ($param in $ruleparams) {
439441
if ($rule.PSObject.Properties[$param]) {
440442
if ($param -eq 'Enabled') {
441-
$cmdparams[$param] = if ($rule.State -eq 'Enabled') {$true} else {$false}
443+
$cmdparams[$param] = if ($rule.State -eq 'Enabled') { $true } else { $false }
442444
} else {
443445
$cmdparams[$param] = $rule.$param
444446
}
@@ -458,7 +460,7 @@ function New-CIPPRestoreTask {
458460
foreach ($param in $ruleparams) {
459461
if ($rule.PSObject.Properties[$param]) {
460462
if ($param -eq 'Enabled') {
461-
$cmdparams[$param] = if ($rule.State -eq 'Enabled') {$true} else {$false}
463+
$cmdparams[$param] = if ($rule.State -eq 'Enabled') { $true } else { $false }
462464
} else {
463465
$cmdparams[$param] = $rule.$param
464466
}

Modules/CIPPCore/Public/Set-CIPPIntunePolicy.ps1

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ function Set-CIPPIntunePolicy {
77
$RawJSON,
88
$AssignTo,
99
$Headers,
10+
$APINAME,
1011
$tenantFilter
1112
)
12-
$ReturnValue = try {
13+
try {
1314
switch ($TemplateType) {
1415
'AppProtection' {
1516
$TemplateType = ($RawJSON | ConvertFrom-Json).'@odata.type' -replace '#microsoft.graph.', ''
@@ -39,13 +40,13 @@ function Set-CIPPIntunePolicy {
3940
$PostType = 'edited'
4041
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $displayname
4142
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PATCH -body $RawJSON
42-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($DisplayName) to template defaults" -Sev 'info'
43+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($DisplayName) to template defaults" -Sev 'info'
4344
$CreateRequest = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName
4445
} else {
4546
$RawJSON = ConvertTo-Json -InputObject $JSON -Depth 20 -Compress
4647
$PostType = 'added'
4748
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON
48-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
49+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
4950
}
5051
}
5152
'Admin' {
@@ -62,13 +63,13 @@ function Set-CIPPIntunePolicy {
6263
$DeleteRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL('$($ExistingID.id)')/updateDefinitionValues" -tenantid $tenantFilter -type POST -body $DeleteJson
6364
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL('$($ExistingID.id)')/updateDefinitionValues" -tenantid $tenantFilter -type POST -body $RawJSON
6465
$CreateRequest = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName
65-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($Displayname) to template defaults" -Sev 'info'
66+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($Displayname) to template defaults" -Sev 'info'
6667
$PostType = 'edited'
6768
} else {
6869
$PostType = 'added'
6970
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $CreateBody
7071
$UpdateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL('$($CreateRequest.id)')/updateDefinitionValues" -tenantid $tenantFilter -type POST -body $RawJSON
71-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($Displayname) to template defaults" -Sev 'info'
72+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($Displayname) to template defaults" -Sev 'info'
7273

7374
}
7475
}
@@ -86,11 +87,11 @@ function Set-CIPPIntunePolicy {
8687
Write-Host "Raw JSON is $RawJSON"
8788
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PATCH -body $RawJSON
8889
$CreateRequest = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName
89-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($DisplayName) to template defaults" -Sev 'info'
90+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($DisplayName) to template defaults" -Sev 'info'
9091
} else {
9192
$PostType = 'added'
9293
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON
93-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
94+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
9495

9596
}
9697
}
@@ -106,7 +107,7 @@ function Set-CIPPIntunePolicy {
106107
} else {
107108
$PostType = 'added'
108109
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON
109-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
110+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
110111
}
111112
}
112113
'windowsDriverUpdateProfiles' {
@@ -124,7 +125,7 @@ function Set-CIPPIntunePolicy {
124125
} else {
125126
$PostType = 'added'
126127
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON
127-
Write-LogMessage -headers $Request.Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
128+
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info'
128129
}
129130
}
130131

@@ -142,5 +143,4 @@ function Set-CIPPIntunePolicy {
142143
Write-LogMessage -headers $Headers -API $APINAME -tenant $($tenantFilter) -message "Failed $($PostType) policy $($Displayname). Error: $($ErrorMessage.NormalizedError)" -Sev 'Error' -LogData $ErrorMessage
143144
throw "Failed to add or set policy for $($tenantFilter) with display name $($Displayname): $($ErrorMessage.NormalizedError)"
144145
}
145-
146146
}

Modules/CIPPCore/Public/Set-CIPPIntuneTemplate.ps1

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ function Set-CIPPIntuneTemplate {
55
$GUID,
66
$DisplayName,
77
$Description,
8-
$templateType
8+
$templateType,
9+
$Headers
910
)
1011
Write-Host "Received $DisplayName, $Description, $RawJSON, $templateType"
1112
if (!$DisplayName) { throw 'You must enter a displayname' }
@@ -26,7 +27,7 @@ function Set-CIPPIntuneTemplate {
2627
GUID = "$GUID"
2728
PartitionKey = 'IntuneTemplate'
2829
}
29-
Write-LogMessage -Headers $Request.Headers -API $APINAME -message "Created intune policy template named $($Request.body.displayname) with GUID $GUID" -Sev 'Debug'
30+
Write-LogMessage -Headers $Headers -API $APINAME -message "Created intune policy template named $($Request.body.displayname) with GUID $GUID" -Sev 'Debug'
3031

3132
return 'Successfully added template'
3233
}

Modules/CIPPCore/Public/Set-CIPPUserLicense.ps1

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ function Set-CIPPUserLicense {
44
[Parameter(Mandatory)][string]$UserId,
55
[Parameter(Mandatory)][string]$TenantFilter,
66
[Parameter()][array]$AddLicenses = @(),
7-
[Parameter()][array]$RemoveLicenses = @()
7+
[Parameter()][array]$RemoveLicenses = @(),
8+
$Headers
89
)
910

1011
# Build the addLicenses array
@@ -30,10 +31,10 @@ function Set-CIPPUserLicense {
3031
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$UserId/assignLicense" -tenantid $TenantFilter -type POST -body $LicenseBodyJson -Verbose
3132
} catch {
3233
$ErrorMessage = Get-CippException -Exception $_
33-
Write-LogMessage -Headers $Request.Headers -API $APIName -tenant $TenantFilter -message "Failed to assign the license. Error: $($ErrorMessage.NormalizedError)" -Sev Error -LogData $ErrorMessage
34+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message "Failed to assign the license. Error: $($ErrorMessage.NormalizedError)" -Sev Error -LogData $ErrorMessage
3435
throw "Failed to assign the license. $($ErrorMessage.NormalizedError)"
3536
}
3637

37-
Write-LogMessage -Headers $Request.Headers -API $APIName -tenant $TenantFilter -message "Assigned licenses to user $UserId. Added: $AddLicenses; Removed: $RemoveLicenses" -Sev 'Info'
38+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message "Assigned licenses to user $UserId. Added: $AddLicenses; Removed: $RemoveLicenses" -Sev 'Info'
3839
return 'Set licenses successfully'
3940
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardConditionalAccessTemplate.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function Invoke-CIPPStandardConditionalAccessTemplate {
3939
$Table = Get-CippTable -tablename 'templates'
4040
$Filter = "PartitionKey eq 'CATemplate' and RowKey eq '$($Setting.TemplateList.value)'"
4141
$JSONObj = (Get-CippAzDataTableEntity @Table -Filter $Filter).JSON
42-
$null = New-CIPPCAPolicy -TenantFilter $tenant -state $Setting.state -RawJSON $JSONObj -Overwrite $true -APIName $APIName -Headers $Request.Headers -ReplacePattern 'displayName'
42+
$null = New-CIPPCAPolicy -replacePattern 'displayName' -TenantFilter $tenant -state $Setting.state -RawJSON $JSONObj -Overwrite $true -APIName $APIName -Headers $Request.Headers
4343
} catch {
4444
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
4545
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to create or update conditional access rule $($JSONObj.displayName). Error: $ErrorMessage" -sev 'Error'

0 commit comments

Comments
 (0)