Have you ever tried to find out the number of users of an enterprise application in your Office 365 tenant? For apps with under 100 users it’s easy – just open Azure AD and check the user count. For more popular apps, it’s a lot more difficult, as Azure AD just shows “100+”. However, with some PowerShell magic, we can dig out the real user count!
When you have an “Enterprise Application” in your Azure AD, you can quite easily access its properties from the Azure Portal. However, if you want to find out the number of users using the app, that’s not as straightforward.
Even for less popular apps, you’ll have to be using the right Azure AD instance (there are usually multiple Azure AD instances/directories associated with your Office 365 subscription!) and have permissions to access the Azure portal. If you’re using the app to access data in SharePoint Online, see this page on how to access the right Azure AD instance.
For more popular apps (with more than a hundred users), Azure AD will just show “100+” as the user count. It appears you cannot get the actual user count by using the Azure Portal web UI. An interesting solution by Microsoft, that’s for sure!
Solution: Use PowerShell to get Azure AD user count for a Service Principal
You can luckily achieve this pretty easily with PowerShell!
The following script gets the AAD Service Principal for the Enterprise Application. Since Enterprise Applications are actually registered at another directory (the one their publisher uses), your AAD instance just provisions service principals for them in your directory, adds required permissions to these principals, and then assigns users to these service principals.
By counting the number of these assignments, we can get the actual user count. These next few lines of some PowerShell magic should do the trick.
That’s it. Hope it helps!
Latest posts by Antti K. Koskela (see all)
- How to interpret SharePoint’s view count managed properties (like “ViewsLast1Days”)? - September 18, 2018
- Properly checking if an item in a folder is a Directory or not in PowerShell - September 5, 2018
- Disabling requests to WsaUpload.ashx (Customer Experience Improvement Program) - August 28, 2018
- Create a new Alert to a SharePoint list - August 22, 2018