Skip to content

Commit 9bbba84

Browse files
authored
Merge branch 'KelvinTegelaar:master' into master
2 parents 3696552 + d8d9df3 commit 9bbba84

File tree

78 files changed

+2779
-936
lines changed

Some content is hidden

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

78 files changed

+2779
-936
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 - clouduptest
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: ubuntu-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: 'clouduptest'
28+
slot-name: 'Production'
29+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
30+
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_9B9E8B9A9BBE446188BCA9F126A1B646 }}
31+
sku: 'flexconsumption'
32+

Modules/CIPPCore/Public/Add-CIPPAzDataTableEntity.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function Add-CIPPAzDataTableEntity {
102102

103103
$propertiesToRemove = [System.Collections.Generic.List[object]]::new()
104104
foreach ($key in $SingleEnt.Keys) {
105+
if ($key -in @('RowKey', 'PartitionKey')) { continue }
105106
$newEntitySize = [System.Text.Encoding]::UTF8.GetByteCount($($newEntity | ConvertTo-Json -Compress))
106107
if ($newEntitySize -lt $MaxRowSize) {
107108
$propertySize = [System.Text.Encoding]::UTF8.GetByteCount($SingleEnt[$key].ToString())

Modules/CIPPCore/Public/Add-CIPPScheduledTask.ps1

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ function Add-CIPPScheduledTask {
1919
[Parameter(Mandatory = $true, ParameterSetName = 'RunNow')]
2020
[string]$RowKey,
2121

22+
[Parameter(Mandatory = $false, ParameterSetName = 'Default')]
23+
[string]$DesiredStartTime = $null,
24+
2225
[Parameter(Mandatory = $false, ParameterSetName = 'Default')]
2326
[Parameter(Mandatory = $false, ParameterSetName = 'RunNow')]
2427
$Headers
@@ -119,8 +122,24 @@ function Add-CIPPScheduledTask {
119122
$task.Recurrence.value
120123
}
121124

122-
if ([int64]$task.ScheduledTime -eq 0 -or [string]::IsNullOrEmpty($task.ScheduledTime)) {
123-
$task.ScheduledTime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds
125+
if ($DesiredStartTime) {
126+
try {
127+
# Parse the epoch time
128+
$epochSeconds = [int64]$DesiredStartTime
129+
# Set ScheduledTime to the desired time
130+
$task.ScheduledTime = $epochSeconds
131+
} catch {
132+
Write-Warning "Failed to parse DesiredStartTime: $DesiredStartTime. Using provided ScheduledTime."
133+
# Fall back to default
134+
if ([int64]$task.ScheduledTime -eq 0 -or [string]::IsNullOrEmpty($task.ScheduledTime)) {
135+
$task.ScheduledTime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds
136+
}
137+
}
138+
} else {
139+
# No DesiredStartTime - use current behavior (immediate execution)
140+
if ([int64]$task.ScheduledTime -eq 0 -or [string]::IsNullOrEmpty($task.ScheduledTime)) {
141+
$task.ScheduledTime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds
142+
}
124143
}
125144
$excludedTenants = if ($task.excludedTenants.value) {
126145
$task.excludedTenants.value -join ','
@@ -166,6 +185,10 @@ function Add-CIPPScheduledTask {
166185
Hidden = [bool]$Hidden
167186
Results = 'Planned'
168187
}
188+
# Always store DesiredStartTime if provided
189+
if ($DesiredStartTime) {
190+
$entity['DesiredStartTime'] = [string]$DesiredStartTime
191+
}
169192

170193
# Store the original tenant filter for group expansion during execution
171194
if ($originalTenantFilter -is [PSCustomObject] -and $originalTenantFilter.type -eq 'Group') {
@@ -190,6 +213,7 @@ function Add-CIPPScheduledTask {
190213
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
191214
return "Could not add task: $ErrorMessage"
192215
}
216+
Write-LogMessage -headers $Headers -API 'ScheduledTask' -message "Added task $($entity.Name) with ID $($entity.RowKey)" -Sev 'Info' -Tenant $tenantFilter
193217
return "Successfully added task: $($entity.Name)"
194218
}
195219
} catch {

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertDepTokenExpiry.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Get-CIPPAlertDepTokenExpiry {
44
Entrypoint
55
#>
66
[CmdletBinding()]
7-
Param (
7+
param (
88
[Parameter(Mandatory = $false)]
99
[Alias('input')]
1010
$InputValue,
@@ -13,7 +13,7 @@ function Get-CIPPAlertDepTokenExpiry {
1313

1414
try {
1515
try {
16-
$DepTokens = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/depOnboardingSettings' -tenantid $TenantFilter).value
16+
$DepTokens = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/depOnboardingSettings' -tenantid $TenantFilter
1717
$AlertData = foreach ($Dep in $DepTokens) {
1818
if ($Dep.tokenExpirationDateTime -lt (Get-Date).AddDays(30) -and $Dep.tokenExpirationDateTime -gt (Get-Date).AddDays(-7)) {
1919
$Message = 'Apple Device Enrollment Program token expiring on {0}' -f $Dep.tokenExpirationDateTime

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertNoCAConfig.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ function Get-CIPPAlertNoCAConfig {
1212
)
1313

1414
try {
15-
$CAAvailable = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter -ErrorAction Stop).serviceplans
16-
if ('AAD_PREMIUM' -in $CAAvailable.servicePlanName) {
15+
# Only consider CA available when a SKU that grants it has enabled seats (> 0)
16+
$SubscribedSkus = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/subscribedSkus?`$select=prepaidUnits,servicePlans" -tenantid $TenantFilter -ErrorAction Stop
17+
$CAAvailable = foreach ($sku in $SubscribedSkus) {
18+
if ([int]$sku.prepaidUnits.enabled -gt 0) { $sku.servicePlans }
19+
}
20+
21+
if (('AAD_PREMIUM' -in $CAAvailable.servicePlanName) -or ('AAD_PREMIUM_P2' -in $CAAvailable.servicePlanName)) {
1722
$CAPolicies = (New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies' -tenantid $TenantFilter)
1823
if (!$CAPolicies.id) {
1924
$AlertData = 'Conditional Access is available, but no policies could be found.'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function Get-CIPPAlertSmtpAuthSuccess {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint – Check sign-in logs for SMTP AUTH with success status
5+
#>
6+
[CmdletBinding()]
7+
Param (
8+
[Parameter(Mandatory = $false)]
9+
[Alias('input')]
10+
$InputValue,
11+
$TenantFilter
12+
)
13+
14+
try {
15+
# Graph API endpoint for sign-ins
16+
$uri = "https://graph.microsoft.com/v1.0/auditLogs/signIns?`$filter=clientAppUsed eq 'SMTP' and status/errorCode eq 0"
17+
18+
# Call Graph API for the given tenant
19+
$SignIns = New-GraphGetRequest -uri $uri -tenantid $TenantFilter
20+
21+
# Select only the properties you care about
22+
$AlertData = $SignIns.value | Select-Object userPrincipalName, createdDateTime, clientAppUsed, ipAddress, status
23+
24+
# Write results into the alert pipeline
25+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
26+
27+
} catch {
28+
# Suppress errors if no data returned
29+
# Uncomment if you want explicit error logging
30+
# Write-AlertMessage -tenant $($TenantFilter) -message "Failed to query SMTP AUTH sign-ins for $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)"
31+
}
32+
}

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertVppTokenExpiry.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ function Get-CIPPAlertVppTokenExpiry {
44
Entrypoint
55
#>
66
[CmdletBinding()]
7-
Param (
7+
param (
88
[Parameter(Mandatory = $false)]
99
[Alias('input')]
1010
$InputValue,
1111
$TenantFilter
1212
)
1313
try {
1414
try {
15-
$VppTokens = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceAppManagement/vppTokens' -tenantid $TenantFilter).value
15+
$VppTokens = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceAppManagement/vppTokens' -tenantid $TenantFilter
1616
$AlertData = foreach ($Vpp in $VppTokens) {
1717
if ($Vpp.state -ne 'valid') {
1818
$Message = 'Apple Volume Purchase Program Token is not valid, new token required'
1919
$Vpp | Select-Object -Property organizationName, appleId, vppTokenAccountType, @{Name = 'Message'; Expression = { $Message } }
20-
}
21-
if ($Vpp.expirationDateTime -lt (Get-Date).AddDays(30) -and $Vpp.expirationDateTime -gt (Get-Date).AddDays(-7)) {
20+
} elseif ($Vpp.expirationDateTime -lt (Get-Date).AddDays(30).ToUniversalTime() -and $Vpp.expirationDateTime -gt (Get-Date).AddDays(-7).ToUniversalTime()) {
2221
$Message = 'Apple Volume Purchase Program token expiring on {0}' -f $Vpp.expirationDateTime
2322
$Vpp | Select-Object -Property organizationName, appleId, vppTokenAccountType, @{Name = 'Message'; Expression = { $Message } }
2423
}

Modules/CIPPCore/Public/Authentication/Get-CippAllowedPermissions.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ function Get-CippAllowedPermissions {
7070

7171
# For admin and superadmin: Compute permissions from base role include/exclude rules
7272
if ($PrimaryRole -in @('admin', 'superadmin')) {
73-
Write-Information "Computing permissions for $PrimaryRole using base role rules"
7473

7574
if ($BaseRole) {
7675
# Start with all permissions and apply include/exclude rules
@@ -143,7 +142,19 @@ function Get-CippAllowedPermissions {
143142
}
144143

145144
# Restrict base permissions to only those allowed by custom roles
146-
$RestrictedPermissions = $BasePermissions | Where-Object { $CustomRolePermissions -contains $_ }
145+
# Include Read permissions when ReadWrite permissions are present
146+
$RestrictedPermissions = $BasePermissions | Where-Object {
147+
$Permission = $_
148+
if ($CustomRolePermissions -contains $Permission) {
149+
$true
150+
} elseif ($Permission -match 'Read$') {
151+
# Check if there's a corresponding ReadWrite permission
152+
$ReadWritePermission = $Permission -replace 'Read', 'ReadWrite'
153+
$CustomRolePermissions -contains $ReadWritePermission
154+
} else {
155+
$false
156+
}
157+
}
147158
foreach ($Permission in $RestrictedPermissions) {
148159
if ($null -ne $Permission -and $Permission -is [string]) {
149160
$AllowedPermissions.Add($Permission)
@@ -161,8 +172,6 @@ function Get-CippAllowedPermissions {
161172
}
162173
# Handle users with only custom roles (no base role)
163174
elseif ($CustomRoles.Count -gt 0) {
164-
Write-Information 'Computing permissions for custom roles only'
165-
166175
foreach ($CustomRole in $CustomRoles) {
167176
try {
168177
$RolePermissions = Get-CIPPRolePermissions -RoleName $CustomRole

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ function Invoke-ListCippQueue {
1515
$CippQueue = Get-CippTable -TableName 'CippQueue'
1616
$CippQueueTasks = Get-CippTable -TableName 'CippQueueTasks'
1717
$3HoursAgo = (Get-Date).ToUniversalTime().AddHours(-3).ToString('yyyy-MM-ddTHH:mm:ssZ')
18-
$CippQueueData = Get-CIPPAzDataTableEntity @CippQueue -Filter "Timestamp ge datetime'$3HoursAgo'" | Sort-Object -Property Timestamp -Descending
18+
$CippQueueData = Get-CIPPAzDataTableEntity @CippQueue -Filter "PartitionKey eq 'CippQueue' and Timestamp ge datetime'$3HoursAgo'" | Sort-Object -Property Timestamp -Descending
1919

2020
$QueueData = foreach ($Queue in $CippQueueData) {
21-
$Tasks = Get-CIPPAzDataTableEntity @CippQueueTasks -Filter "QueueId eq '$($Queue.RowKey)'" | Where-Object { $_.Name } | Select-Object @{n = 'Timestamp'; exp = { $_.Timestamp.DateTime.ToUniversalTime() } }, Name, Status
21+
$Tasks = Get-CIPPAzDataTableEntity @CippQueueTasks -Filter "PartitionKey eq 'Task' and QueueId eq '$($Queue.RowKey)'" | Where-Object { $_.Name } | Select-Object @{n = 'Timestamp'; exp = { $_.Timestamp.DateTime.ToUniversalTime() } }, Name, Status
2222
$TaskStatus = @{}
2323
$Tasks | Group-Object -Property Status | ForEach-Object {
2424
$TaskStatus.$($_.Name) = $_.Count

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOnboardTenantQueue.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ function Push-ExecOnboardTenantQueue {
364364
$Table = Get-CippTable -tablename 'templates'
365365
$ExistingTemplates = Get-CippazDataTableEntity @Table -Filter "PartitionKey eq 'StandardsTemplateV2'" | Where-Object { $_.JSON -match 'AllTenants' }
366366
foreach ($AllTenantsTemplate in $ExistingTemplates) {
367-
$object = $AllTenantesTemplate.JSON | ConvertFrom-Json
367+
$object = $AllTenantsTemplate.JSON | ConvertFrom-Json
368368
$NewExcludedTenants = [system.collections.generic.list[object]]::new()
369369
if (!$object.excludedTenants) {
370370
$object | Add-Member -MemberType NoteProperty -Name 'excludedTenants' -Value @() -Force

0 commit comments

Comments
 (0)