Azure AD App + PowerShell

Create Azure AD Application with Configurations Using PowerShell

Sibeesh Venu
4 min readFeb 8, 2021

--

There are different ways that you can create an Azure AD application aka Azure AD app registration. Sometimes, you may have to create it using the portal or by using PowerShell modules. When you use PowerShell to do this, you can save the script and reuse the same in the future, one of the many advantages of using this approach is that it will help you remove human errors. Let’s see how we can do this.

Azure AD application using PowerShell

Before we run the command to create the application, make sure that you have installed the AzureAD module. Open your PowerShell ISE with administrator access, and then type the preceding command.

PS C:\WINDOWS\system32> Install-Module AzureAD

This will install the module for you. You can see this in the modules list in the ISE. Click on the refresh button if you don’t see it.

Install AzureAD Module

Now run the command “Connect-AzureAD” to connect to your Azure Account. If you have multiple directories with your account, then you must connect it with the tenant parameter. You can get the tenant id from the Tenant Properties window. Switch to the directory in the Azure Portal and search for the Tenant Properties in the search bar. Copy the Tenant ID from there and run it with the preceding command.

Connect-AzureAD -TenantId YourTenantIDHere

Login again if you are asked again. And you are ready to run the command to create the AD application.

Here the parameter “-Oauth2AllowImplicitFlow” is to enable the OAuth flow and the -AvailableToOtherTenants is to make sure that my app is available to other tenants. You can see more options here.

If you are getting an error as “Message: Hostname in ‘http://’ in property identifierUris is not on any verified domain of the company or…

--

--

Sibeesh Venu

An engineer by profession and writer by passion. Author at Sibeesh Passion, Microsoft MVP (2016–2022). Software Engineer @ Microsoft