Script for getting Azure AD app registration secrets and certificates that expire soon

Just needed to clean up expired app registration secrets from a tenant, and figured I could just make a very quick script to find secrets and certificates that expire soon. Have fun – no explanation needed i guess.

$expiresWithinDays = 31
$expired = Get-AzureADApplication | ForEach-Object {
    $app = $_
    #$keys = Get-AzureADApplicationKeyCredential -ObjectId $_.ObjectId 
        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

Generating demo Access Packages for AAD Entitlement Management through the Microsoft Graph

Some times it can be handy to be able to generate some demo content, and have some reference PowerShell for working with stuff. Here is my script for creating 5 access packages with different properties:

  • A visible package available for any external user
  • A hidden package available for any external user, requiring the user to know the url
  • A package available to external users in connected organizations
  • A package available for members of an internal group
  • A package available to any internal user, with manager approval and self review
Continue reading “Generating demo Access Packages for AAD Entitlement Management through the Microsoft Graph”

Full IGA using Azure AD – Managing access using Entitlement Management

In this blog series on building a full Identity Governance and Administration solution, we have until now covered application roles extensively, and how these can be sent to an application.

For a quick summary, this is how you can define custom application roles, here is how to send these roles using the SCIM protocol, this article shows how to transfer the roles using the OpenID Connect ID Token or SAML claim and here I can show you how to use PowerShell to query the Microsoft Graph for application role assignments for your users and groups.

Continue reading “Full IGA using Azure AD – Managing access using Entitlement Management”

Creating B2C users through the Microsoft Graph

The Microsoft Graph finally should have all functionality that previously only the Azure AD Graph had, such as the ability to create and manage B2C user accounts. Earlier you had to create them through the Azure AD Graph, in order to do certain things such as setting the account type as local and managing username.

Continue reading “Creating B2C users through the Microsoft Graph”

PowerShell cmdlet to get attributes not matching between two objects

This is a very quick cmdlet for getting attributes that does not match between two objects

   Returns a list of all attributes that does not match between two objects
function Get-MismatchedAttributes

        [String[]] $Attributes = $null

    if($Attributes -eq $null) {
        $Attributes = @(
            $ReferenceObject | gm -MemberType NoteProperty | select -exp Name
            $DifferenceObject | gm -MemberType NoteProperty | select -exp Name
        ) | Sort -Unique
    $Attributes | Where {$ReferenceObject.$($_) -ne $DifferenceObject.$($_)}

$obj1 = [PSCustomObject] @{
    Attr1 = "abc"
    Attr2 = "def"
    Attr3 = "klm"

$obj2 = [PSCustomObject] @{
    Attr1 = "abc"
    Attr2 = "okj"

Write-Host "Attributes that does not match, limited to Attr1 and Attr2" -ForegroundColor Red
Get-MismatchedAttributes $obj1 $obj2 -Attributes "Attr1","Attr2"

Write-Host "All attributes that does not match" -ForegroundColor Red
Get-MismatchedAttributes $obj1 $obj2