Skip to content

Commit 1cf8ba4

Browse files
Merge pull request #131 from KelvinTegelaar/dev
Dev to release
2 parents aa90016 + 8ac5607 commit 1cf8ba4

File tree

7 files changed

+18
-25
lines changed

7 files changed

+18
-25
lines changed

AddAlert/run.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ param($Request, $TriggerMetadata)
66
$APIName = $TriggerMetadata.FunctionName
77
Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
88

9-
Write-Host "PowerShell HTTP trigger function processed a request."
10-
119
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value
1210
$Results = foreach ($Tenant in $tenants) {
1311
try {
1412
$CompleteObject = [PSCustomObject]@{
1513
tenant = $tenant
14+
tenantid = (get-tenants | Where-Object -Property defaultDomainName -EQ $Tenant).Customerid
1615
AdminPassword = [bool]$Request.body.AdminPassword
1716
DefenderMalware = [bool]$Request.body.DefenderMalware
1817
DefenderStatus = [bool]$Request.body.DefenderStatus

GetDashboard/run.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ $dash = [PSCustomObject]@{
192192
NextBPARun = (Get-CronNextExecutionTime -Expression '0 3 * * *').tostring('s')
193193
queuedApps = [int64](Get-ChildItem '.\ChocoApps.Cache' -ErrorAction SilentlyContinue).count
194194
queuedStandards = [int64](Get-ChildItem '.\Cache_Standards' -ErrorAction SilentlyContinue).count
195-
tenantCount = (get-tenants).count
195+
tenantCount = [int64](get-tenants -ErrorAction SilentlyContinue).count
196196
RefreshTokenDate = (Get-CronNextExecutionTime -Expression '0 0 * * 0').AddDays('-7').tostring('s') -split "T" | Select-Object -First 1
197197
ExchangeTokenDate = (Get-CronNextExecutionTime -Expression '0 0 * * 0').AddDays('-7').tostring('s') -split "T" | Select-Object -First 1
198-
LastLog = Get-Content "Logs\$((Get-Date).ToString('ddMMyyyy')).log" | ConvertFrom-Csv -Header "DateTime", "Tenant", "API", "Message", "User", "Severity" -Delimiter "|" | Select-Object -Last 10
198+
LastLog = @(Get-Content "Logs\$((Get-Date).ToString('ddMMyyyy')).log" | ConvertFrom-Csv -Header "DateTime", "Tenant", "API", "Message", "User", "Severity" -Delimiter "|" | Select-Object -Last 10)
199199
}
200200
# Write to the Azure Functions log stream.
201201

Scheduler_Alert/run.ps1

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
param($tenant)
2-
Write-Host $($Tenant.tenant)
3-
Write-Host $($Tenant.tag)
42
Write-Host $($Tenant | ConvertTo-Json)
5-
#thoughts: add more delta/tracking to prevent duplicate alerts.
63
if ($Tenant.tag -eq "AllTenants") {
74
$Alerts = Get-Content ".\Cache_Scheduler\AllTenants.alert.json" | ConvertFrom-Json
85
}
96
else {
107
$Alerts = Get-Content ".\Cache_Scheduler\$($tenant.tenant).alert.json" | ConvertFrom-Json
118
}
129
$ShippedAlerts = switch ($Alerts) {
10+
1311
{ $Alerts."AdminPassword" -eq $true } {
1412
New-GraphGETRequest -uri "https://graph.microsoft.com/beta/roleManagement/directory/roleAssignments?`$filter=roleDefinitionId eq '62e90394-69f5-4237-9190-012177145e10'" -tenantid $($tenant.tenant) | ForEach-Object {
1513
$LastChanges = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/users/$($_.principalId)?`$select=UserPrincipalName,lastPasswordChangeDateTime" -tenant $($tenant.tenant)
@@ -30,17 +28,17 @@ $ShippedAlerts = switch ($Alerts) {
3028
{ $_."MFAAdmins" -eq $true } {
3129
$AdminIds = (New-GraphGETRequest -uri "https://graph.microsoft.com/beta/roleManagement/directory/roleAssignments?`$filter=roleDefinitionId eq '62e90394-69f5-4237-9190-012177145e10'&expand=principal" -tenantid $($tenant.tenant)).principal
3230
$AdminList = Get-CIPPMSolUsers -tenant $tenant.tenant | Where-Object -Property ObjectID -In $AdminIds.id
33-
$MFARegistration = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails' -tenantid $tenant.tenant)
31+
try { $MFARegistration = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails' -tenantid $tenant.tenant -ErrorAction) } catch {}
3432
$AdminList | Where-Object { $_.Usertype -eq "Member" -and $_.BlockCredential -eq $false } | ForEach-Object {
35-
$CARegistered = ($MFARegistration | Where-Object -Property UserPrincipalName -EQ $_.UserPrincipalName).IsMFARegistered
33+
$CARegistered = [boolean]($MFARegistration | Where-Object -Property UserPrincipalName -EQ $_.UserPrincipalName).IsMFARegistered
3634
if ($_.StrongAuthenticationRequirements.StrongAuthenticationRequirement.state -eq $null -and $CARegistered -eq $false) { "Admin $($_.UserPrincipalName) is enabled but does not have any form of MFA configured." }
3735
}
3836
}
3937
{ $_."MFAAlertUsers" -eq $true } {
4038
$users = Get-CIPPMSolUsers -tenant $tenant.tenant
41-
$MFARegistration = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails' -tenantid $tenant.tenant)
39+
try { $MFARegistration = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails' -tenantid $tenant.tenant -ErrorAction) } catch {}
4240
$users | Where-Object { $_.Usertype -eq "Member" -and $_.BlockCredential -eq $false } | ForEach-Object {
43-
$CARegistered = ($MFARegistration | Where-Object -Property UserPrincipalName -EQ $_.UserPrincipalName).IsMFARegistered
41+
$CARegistered = [boolean]($MFARegistration | Where-Object -Property UserPrincipalName -EQ $_.UserPrincipalName).IsMFARegistered
4442
if ($_.StrongAuthenticationRequirements.StrongAuthenticationRequirement.state -eq $null -and $CARegistered -eq $false) { "User $($_.UserPrincipalName) is enabled but does not have any form of MFA configured." }
4543
}
4644
}
@@ -87,9 +85,13 @@ $ShippedAlerts = switch ($Alerts) {
8785
}
8886
}
8987
$currentlog = Get-Content "Logs\$((Get-Date).ToString('ddMMyyyy')).log" | ConvertFrom-Csv -Header "DateTime", "Tenant", "API", "Message", "User", "Severity" -Delimiter "|" | Where-Object -Property Tenant -EQ $tenant.tenant
88+
Write-Host $ShippedAlerts
9089
$ShippedAlerts | ForEach-Object {
9190
if ($_ -in $currentlog.message) {
9291
continue
9392
}
9493
Log-Request -message $_ -API "Alerts" -tenant $tenant.tenant -sev Alert
9594
}
95+
[PSCustomObject]@{
96+
ReturnedValues = $true
97+
}

Scheduler_CIPPNotifications/Config.Json

Lines changed: 0 additions & 11 deletions
This file was deleted.

Scheduler_CIPPNotifications/run.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ else {
1111
exit
1212
}
1313

14-
$Settings = $Config.psobject.properties.name + "Alerts"
14+
$Settings = if ($Config.psobject.properties.name) { @($Config.psobject.properties.name, "Alerts") } else { @("Alerts") }
1515
$logdate = (Get-Date).ToString('ddMMyyyy')
1616
$Currentlog = Get-Content "Logs\$($logdate).log" | ConvertFrom-Csv -Header 'DateTime', 'Tenant', 'API', 'Message', 'User', 'Severity' -Delimiter '|' | Where-Object { [datetime]$_.Datetime -gt (Get-Date).AddMinutes(-16) -and $_.api -in $Settings -and $_.Severity -ne 'debug' }
1717
if ($Config.email -ne '' -and $null -ne $CurrentLog) {
@@ -72,4 +72,6 @@ if ($Config.webhook -ne '' -and $null -ne $CurrentLog) {
7272
}
7373

7474

75-
75+
[PSCustomObject]@{
76+
ReturnedValues = $true
77+
}

Scheduler_GetQueue/run.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ $object = foreach ($Tenant in $tenants) {
77
if ($Typefile.Tenant -ne "AllTenants") {
88
[pscustomobject]@{
99
Tenant = $Typefile.Tenant
10+
Tag = "SingleTenant"
1011
TenantID = $TypeFile.tenantId
1112
Type = $Typefile.Type
1213
}

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8.0
1+
1.8.1

0 commit comments

Comments
 (0)