Skip to content

Commit f94ce24

Browse files
Merge pull request #1236 from rvdwegen/patch-13
Add app reg certificate expiry alert
2 parents 95d2571 + 826d880 commit f94ce24

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function Get-CIPPAlertAppCertificateExpiry {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
#>
6+
[CmdletBinding()]
7+
Param (
8+
[Parameter(Mandatory = $false)]
9+
[Alias('input')]
10+
$InputValue,
11+
$TenantFilter
12+
)
13+
14+
try {
15+
Write-Host "Checking app expire for $($TenantFilter)"
16+
$appList = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/applications?`$select=appId,displayName,keyCredentials" -tenantid $TenantFilter
17+
} catch {
18+
return
19+
}
20+
21+
$AlertData = foreach ($App in $applist) {
22+
Write-Host "checking $($App.displayName)"
23+
if ($App.keyCredentials) {
24+
foreach ($Credential in $App.keyCredentials) {
25+
if ($Credential.endDateTime -lt (Get-Date).AddDays(30) -and $Credential.endDateTime -gt (Get-Date).AddDays(-7)) {
26+
Write-Host ("Application '{0}' has certificates expiring on {1}" -f $App.displayName, $Credential.endDateTime)
27+
@{ DisplayName = $App.displayName; Expires = $Credential.endDateTime }
28+
}
29+
}
30+
}
31+
}
32+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
33+
}

0 commit comments

Comments
 (0)