Report missing and disabled sponsors

Rick Angel 171 Reputation points
2024-12-27T14:31:42.9666667+00:00

We have a mixture of guest users with cloud-only and hybrid user accounts. For that reason we store the internal sponsor's email address (matches UPN) in extensionAttribute1 rather than the Sponsors attribute. I've been unsuccessful in developing a PowerShell script to search for extensionAttribute1 across all guest users and report whether any of the sponsors have been disabled or deleted.

The main problem seems to be reporting the value stored in extensionAttribute1 because it is an on premise attribute. The script needs to run against Entra ID because that is the only place where all the guest accounts exists. Also note this is a GCC High tenant.

Does anyone have suggestions for the script? Thanks.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,896 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 111.8K Reputation points MVP
    2024-12-27T15:47:41.9466667+00:00

    You should be able to use a filter against the onPremisesExtensionAttributes property (onPremisesExtensionAttributes/extensionAttribute1). I don't have access to a GCC High tenant to test this, but something like this should work:

    Get-MgUser -Filter "onPremisesExtensionAttributes/extensionAttribute1 eq 'blablabla' and userType eq 'Guest'" -ConsistencyLevel eventual -CountVariable count
    

    Replace with the string/value you want to look for. The last two parameters are mandatory, as this is considered an "advanced query".

    If you want a list of all users with non-null values in said attribute, this would do:

    Get-MgUser -Filter "onPremisesExtensionAttributes/extensionAttribute1 ne null and userType eq 'Guest'" -ConsistencyLevel eventual -CountVariable count
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.