Skip to content

Commit a8298c7

Browse files
authored
Merge pull request #300 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents c31b6ad + cf2536d commit a8298c7

File tree

4 files changed

+123
-74
lines changed

4 files changed

+123
-74
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@ function Get-CIPPAlertHuntressRogueApps {
1313
Param (
1414
[Parameter(Mandatory = $false)]
1515
[Alias('input')]
16-
$InputValue,
17-
$TenantFilter,
18-
[Parameter(Mandatory = $false)]
19-
[bool]$IgnoreDisabledApps = $false
16+
[bool]$InputValue = $false,
17+
$TenantFilter
2018
)
2119

2220
try {
2321
$RogueApps = Invoke-RestMethod -Uri 'https://raw.githubusercontent.com/huntresslabs/rogueapps/main/public/rogueapps.json'
2422
$RogueAppFilter = $RogueApps.appId -join "','"
2523
$ServicePrincipals = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/servicePrincipals?`$filter=appId in ('$RogueAppFilter')" -tenantid $TenantFilter
2624
# If IgnoreDisabledApps is true, filter out disabled service principals
27-
if ($IgnoreDisabledApps) {
25+
if ($InputValue) {
2826
$ServicePrincipals = $ServicePrincipals | Where-Object { $_.accountEnabled -eq $true }
2927
}
3028

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
function Get-CIPPAlertOneDriveQuota {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
#>
6+
[CmdletBinding()]
7+
Param (
8+
[Parameter(Mandatory)]
9+
$TenantFilter,
10+
[Alias('input')]
11+
[ValidateRange(0,100)]
12+
[int]$InputValue = 90
13+
)
14+
15+
try {
16+
$Usage = New-GraphGetRequest -tenantid $TenantFilter -uri "https://graph.microsoft.com/beta/reports/getOneDriveUsageAccountDetail(period='D7')?`$format=application/json&`$top=999" -AsApp $true
17+
if (!$Usage) {
18+
Write-AlertMessage -tenant $($TenantFilter) -message "OneDrive quota Alert: Unable to get OneDrive usage: Error occurred: No data returned from API."
19+
return
20+
}
21+
}
22+
catch {
23+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
24+
Write-AlertMessage -tenant $($TenantFilter) -message "OneDrive quota Alert: Unable to get OneDrive usage: Error occurred: $ErrorMessage"
25+
return
26+
}
27+
28+
#Check if the OneDrive quota is over the threshold
29+
$OverQuota = $Usage | ForEach-Object {
30+
if ($_.StorageUsedInBytes -eq 0 -or $_.storageAllocatedInBytes -eq 0) { return }
31+
try {
32+
$UsagePercent = [math]::Round(($_.storageUsedInBytes / $_.storageAllocatedInBytes) * 100)
33+
} catch { $UsagePercent = 100 }
34+
35+
if ($UsagePercent -gt $InputValue) {
36+
$GBLeft = [math]::Round(($_.storageAllocatedInBytes - $_.storageUsedInBytes) / 1GB)
37+
"$($_.ownerPrincipalName): OneDrive is $UsagePercent% full. OneDrive has $($GBLeft)GB storage left"
38+
}
39+
40+
}
41+
42+
#If the quota is over the threshold, send an alert
43+
if ($OverQuota) {
44+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $OverQuota
45+
}
46+
}

Modules/CIPPCore/Public/GraphHelper/Get-Tenants.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function Get-Tenants {
6767
relationshipEnd = $Relationship.endDateTime
6868
}
6969
}
70-
$CurrentTenants = Get-CIPPAzDataTableEntity @TenantsTable -Filter "PartitionKey eq 'Tenants' and Excluded eq false"
70+
$CurrentTenants = Get-CIPPAzDataTableEntity @TenantsTable -Filter "PartitionKey eq 'Tenants' and Excluded eq false and delegatedPrivilegeStatus ne 'directTenant'"
7171
$CurrentTenants | Where-Object { $_.customerId -notin $GDAPList.customerId -and $_.customerId -ne $env:TenantID } | ForEach-Object {
7272
Remove-AzDataTableEntity -Force @TenantsTable -Entity $_
7373
}

cspell.json

Lines changed: 73 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,75 @@
11
{
2-
"version": "0.2",
3-
"ignorePaths": [],
4-
"dictionaryDefinitions": [],
5-
"dictionaries": [],
6-
"words": [
7-
"ADMS",
8-
"AITM",
9-
"Autotask",
10-
"Bluetrait",
11-
"CIPP",
12-
"CIPP-API",
13-
"Connectwise",
14-
"Datto",
15-
"Entra",
16-
"GDAP",
17-
"Intune",
18-
"OBEE",
19-
"Passwordless",
20-
"PSTN",
21-
"Sherweb",
22-
"SSPR",
23-
"Terrl",
24-
"TNEF",
25-
"winmail",
26-
"Yubikey"
27-
],
28-
"ignoreWords": [
29-
"tenantid",
30-
"APINAME",
31-
"CIPPBPA",
32-
"CIPPCA",
33-
"CIPPSPO",
34-
"CIPPAPI",
35-
"Addins",
36-
"Helptext",
37-
"ADDEDCOMPONENT",
38-
"ADDEDDATE",
39-
"POWERSHELLEQUIVALENT",
40-
"RECOMMENDEDBY",
41-
"UPDATECOMMENTBLOCK",
42-
"DISABLEDFEATURES",
43-
"pscustomobject",
44-
"microsoftonline",
45-
"mdo_safeattachments",
46-
"mdo_highconfidencespamaction",
47-
"mdo_highconfidencephishaction",
48-
"mdo_phisspamacation",
49-
"mdo_spam_notifications_only_for_admins",
50-
"mdo_antiphishingpolicies",
51-
"mdo_phishthresholdlevel",
52-
"mdo_autoforwardingmode",
53-
"mdo_blockmailforward",
54-
"mdo_zapspam",
55-
"mdo_zapphish",
56-
"mdo_zapmalware",
57-
"mdo_safedocuments",
58-
"mdo_commonattachmentsfilter",
59-
"mdo_safeattachmentpolicy",
60-
"mdo_safelinksforemail",
61-
"mdo_safelinksforOfficeApps",
62-
"exo_storageproviderrestricted",
63-
"exo_individualsharing",
64-
"exo_outlookaddins",
65-
"exo_mailboxaudit",
66-
"exo_mailtipsenabled",
67-
"mip_search_auditlog"
68-
],
69-
"import": []
2+
"version": "0.2",
3+
"ignorePaths": [],
4+
"dictionaryDefinitions": [],
5+
"dictionaries": [],
6+
"words": [
7+
"ADMS",
8+
"AITM",
9+
"Autotask",
10+
"Bluetrait",
11+
"cipp",
12+
"CIPP",
13+
"CIPP-API",
14+
"Connectwise",
15+
"Datto",
16+
"Entra",
17+
"GDAP",
18+
"Intune",
19+
"OBEE",
20+
"Passwordless",
21+
"passwordless",
22+
"PSTN",
23+
"Sherweb",
24+
"SSPR",
25+
"Standardcal",
26+
"Terrl",
27+
"TNEF",
28+
"winmail",
29+
"Yubikey"
30+
],
31+
"ignoreWords": [
32+
"tenantid",
33+
"jnlp",
34+
"APINAME",
35+
"CIPPBPA",
36+
"CIPPCA",
37+
"CIPPSPO",
38+
"CIPPAPI",
39+
"donotchange",
40+
"Addins",
41+
"Helptext",
42+
"ADDEDCOMPONENT",
43+
"ADDEDDATE",
44+
"POWERSHELLEQUIVALENT",
45+
"RECOMMENDEDBY",
46+
"UPDATECOMMENTBLOCK",
47+
"DISABLEDFEATURES",
48+
"pscustomobject",
49+
"microsoftonline",
50+
"mdo_safeattachments",
51+
"mdo_highconfidencespamaction",
52+
"mdo_highconfidencephishaction",
53+
"mdo_phisspamacation",
54+
"mdo_spam_notifications_only_for_admins",
55+
"mdo_antiphishingpolicies",
56+
"mdo_phishthresholdlevel",
57+
"mdo_autoforwardingmode",
58+
"mdo_blockmailforward",
59+
"mdo_zapspam",
60+
"mdo_zapphish",
61+
"mdo_zapmalware",
62+
"mdo_safedocuments",
63+
"mdo_commonattachmentsfilter",
64+
"mdo_safeattachmentpolicy",
65+
"mdo_safelinksforemail",
66+
"mdo_safelinksforOfficeApps",
67+
"exo_storageproviderrestricted",
68+
"exo_individualsharing",
69+
"exo_outlookaddins",
70+
"exo_mailboxaudit",
71+
"exo_mailtipsenabled",
72+
"mip_search_auditlog"
73+
],
74+
"import": []
7075
}

0 commit comments

Comments
 (0)