'How to fetch data from app registrations in Azure with status which says expiring soon

I would like to fetch data of apps from app registrations of which certificates with status are expiring soon.

If anyone could help with PowerShell script or any other way of fetching the data please help



Solution 1:[1]

We have tried with the above requirement and able to fetch the details of certificate and secrets which will expire soon.

PowerShell script:-

Connect-AzureAD
$expiresWithinDays = 31
$expired = Get-AzureADApplication -All:$true | ForEach-Object {
$app = $_
@(
Get-AzureADApplicationPasswordCredential -ObjectId $_.ObjectId
Get-AzureADApplicationKeyCredential -ObjectId $_.ObjectId
) | Where-Object {
$_.EndDate -lt (Get-Date).AddDays($expiresWithinDays)
} | ForEach-Object {
$id = "Not set"
if($_.CustomKeyIdentifier) {
$id = [System.Text.Encoding]::UTF8.GetString($_.CustomKeyIdentifier)
}
[PSCustomObject] @{
App = $app.DisplayName
ObjectID = $app.ObjectId
AppId = $app.AppId
Type = $_.GetType().name
KeyIdentifier = $id
EndDate = $_.EndDate
}
}
}

$expired | Out-GridView

SAMPLE OUTPUT:- enter image description here enter image description here enter image description here

For more information please refer this Blog.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AjayKumarGhose-MT