Skip to content

Commit 2440943

Browse files
authored
Merge branch 'KelvinTegelaar:master' into master
2 parents d0282fc + a352c4c commit 2440943

29 files changed

+547
-298
lines changed

CIPPTimers.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,13 @@
142142
"Priority": 15,
143143
"RunOnProcessor": true,
144144
"IsSystem": true
145+
},
146+
{
147+
"Command": "Start-TableCleanup",
148+
"Description": "Timer to cleanup tables",
149+
"Cron": "0 0 23 * * *",
150+
"Priority": 20,
151+
"RunOnProcessor": true,
152+
"IsSystem": true
145153
}
146154
]

Modules/CIPPCore/Public/Add-CIPPScheduledTask.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Add-CIPPScheduledTask {
2121
$Parameters = [System.Collections.Hashtable]@{}
2222
foreach ($Key in $task.Parameters.PSObject.Properties.Name) {
2323
$Param = $task.Parameters.$Key
24-
if ($Param -is [System.Collections.IDictionary]) {
24+
if ($Param -is [System.Collections.IDictionary] -or $Param.Key) {
2525
$ht = @{}
2626
foreach ($p in $Param.GetEnumerator()) {
2727
$ht[$p.Key] = $p.Value

Modules/CIPPCore/Public/AuditLogs/Get-CippAuditLogSearchResults.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,21 @@ function Get-CippAuditLogSearchResults {
1414
[string]$TenantFilter,
1515
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
1616
[Alias('id')]
17-
[string]$QueryId
17+
[string]$QueryId,
18+
[switch]$CountOnly
1819
)
1920

2021
process {
21-
New-GraphGetRequest -uri ('https://graph.microsoft.com/beta/security/auditLog/queries/{0}/records?$top=999' -f $QueryId) -AsApp $true -tenantid $TenantFilter -ErrorAction Stop
22+
$GraphRequest = @{
23+
Uri = ('https://graph.microsoft.com/beta/security/auditLog/queries/{0}/records?$top=999&$count=true' -f $QueryId)
24+
Method = 'GET'
25+
AsApp = $true
26+
tenantid = $TenantFilter
27+
}
28+
if ($CountOnly.IsPresent) {
29+
$GraphRequest.CountOnly = $true
30+
}
31+
32+
New-GraphGetRequest @GraphRequest -ErrorAction Stop
2233
}
2334
}

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Domain Analyser/Push-DomainAnalyserTenant.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ function Push-DomainAnalyserTenant {
2727
'*.excl.cloud'
2828
'*.codetwo.online'
2929
'*.call2teams.com'
30-
'*signature365.net'
30+
'*.signature365.net'
31+
'*.myteamsconnect.io'
32+
'*.teams.dstny.com'
3133
)
3234
$Domains = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/domains' -tenantid $Tenant.customerId | Where-Object { $_.isVerified -eq $true } | ForEach-Object {
3335
$Domain = $_

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogTenant.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ function Push-AuditLogTenant {
3232
# Get webhook rules
3333
$ConfigEntries = Get-CIPPAzDataTableEntity @ConfigTable
3434
$LogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'
35-
35+
Write-Information ("Audit: Memory usage before processing $([System.GC]::GetTotalMemory($false))")
36+
$SearchCount = 0
3637
$Configuration = $ConfigEntries | Where-Object { ($_.Tenants -match $TenantFilter -or $_.Tenants -match 'AllTenants') }
3738
if ($Configuration) {
3839
try {
@@ -88,12 +89,17 @@ function Push-AuditLogTenant {
8889
}
8990
}
9091
}
92+
$SearchCount++
93+
Write-Information "Audit: Memory usage after processing $SearchCount searches: $([System.GC]::GetTotalMemory($false))"
9194
}
9295
} catch {
9396
Write-Information ( 'Audit Log search: Error {0} line {1} - {2}' -f $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber, $_.Exception.Message)
9497
}
9598
}
9699
} catch {
97100
Write-Information ( 'Push-AuditLogTenant: Error {0} line {1} - {2}' -f $_.InvocationInfo.ScriptName, $_.InvocationInfo.ScriptLineNumber, $_.Exception.Message)
101+
} finally {
102+
Write-Information "Audit Logs: Completed processing $($TenantFilter)"
103+
Write-Information "Audit Logs: Memory usage after processing $([System.GC]::GetTotalMemory($false))"
98104
}
99105
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecRestoreBackup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Function Invoke-ExecRestoreBackup {
1313
$APIName = $TriggerMetadata.FunctionName
1414
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
1515
try {
16-
foreach ($line in ($Request.body | ConvertFrom-Json | Select-Object * -ExcludeProperty ETag)) {
16+
foreach ($line in ($Request.body | ConvertFrom-Json | Select-Object * -ExcludeProperty ETag, Timestamp)) {
1717
Write-Host ($line)
1818
$Table = Get-CippTable -tablename $line.table
1919
$ht2 = @{}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ Function Invoke-ExecDeviceAction {
2020
if ($Request.Query.Action -eq 'setDeviceName') {
2121
$ActionBody = @{ deviceName = $Request.Body.input } | ConvertTo-Json -Compress
2222
}
23-
$ActionResult = New-CIPPDeviceAction -Action $Request.Query.Action -ActionBody $ActionBody -DeviceFilter $Request.Query.GUID -TenantFilter $Request.Query.TenantFilter -ExecutingUser $request.headers.'x-ms-client-principal' -APINAME $APINAME
23+
else {
24+
$ActionBody = $Request.Body | ConvertTo-Json -Compress
25+
}
26+
27+
$cmdparams = @{
28+
Action = $Request.Query.Action
29+
ActionBody = $ActionBody
30+
DeviceFilter = $Request.Query.GUID
31+
TenantFilter = $Request.Query.TenantFilter
32+
ExecutingUser = $request.headers.'x-ms-client-principal'
33+
APINAME = $APINAME
34+
}
35+
$ActionResult = New-CIPPDeviceAction @cmdparams
2436
$body = [pscustomobject]@{'Results' = "$ActionResult" }
2537

2638
} catch {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Groups/Invoke-AddGroup.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ Function Invoke-AddGroup {
6868
}
6969
$GraphRequest = New-ExoRequest -tenantid $tenant -cmdlet 'New-DistributionGroup' -cmdParams $params
7070
}
71-
$GraphRequest = New-ExoRequest -tenantid $tenant -cmdlet 'New-DistributionGroup' -cmdParams $params
7271
# At some point add logic to use AddOwner/AddMember for New-DistributionGroup, but idk how we're going to brr that - rvdwegen
7372
}
7473
"Successfully created group $($groupobj.displayname) for $($tenant)"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using namespace System.Net
2+
3+
function Invoke-ListPerUserMFA {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint
7+
.ROLE
8+
Identity.User.Read
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
13+
$APIName = $TriggerMetadata.FunctionName
14+
$User = $request.headers.'x-ms-client-principal'
15+
Write-LogMessage -user $User -API $APINAME -message 'Accessed this API' -Sev 'Debug'
16+
17+
# Write to the Azure Functions log stream.
18+
Write-Host 'PowerShell HTTP trigger function processed a request.'
19+
20+
# Parse query parameters
21+
$Tenant = $Request.query.tenantFilter
22+
try {
23+
$AllUsers = [System.Convert]::ToBoolean($Request.query.allUsers)
24+
} catch {
25+
$AllUsers = $false
26+
}
27+
$UserId = $Request.query.userId
28+
29+
# Get the MFA state for the user/all users
30+
try {
31+
if ($AllUsers -eq $true) {
32+
$Results = Get-CIPPPerUserMFA -TenantFilter $Tenant -AllUsers $true
33+
} else {
34+
$Results = Get-CIPPPerUserMFA -TenantFilter $Tenant -userId $UserId
35+
}
36+
$StatusCode = [HttpStatusCode]::OK
37+
} catch {
38+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
39+
$Results = "Failed to get MFA State for $UserId : $ErrorMessage"
40+
$StatusCode = [HttpStatusCode]::Forbidden
41+
}
42+
43+
# Associate values to output bindings by calling 'Push-OutputBinding'.
44+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
45+
StatusCode = $StatusCode
46+
Body = @($Results)
47+
})
48+
49+
50+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Alerts/Invoke-PublicWebhooks.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ function Invoke-PublicWebhooks {
6565
}
6666
Add-CIPPAzDataTableEntity @WebhookIncoming -Entity $Entity
6767
} else {
68-
return 'Not replying to this webhook or processing it'
68+
$Body = 'This webhook is not authorized.'
69+
$StatusCode = [HttpStatusCode]::Forbidden
6970
}
7071
$Body = 'Webhook Recieved'
7172
$StatusCode = [HttpStatusCode]::OK
@@ -80,4 +81,4 @@ function Invoke-PublicWebhooks {
8081
StatusCode = $StatusCode
8182
Body = $Body
8283
})
83-
}
84+
}

0 commit comments

Comments
 (0)