0
votes

I want to create Azure Active Directory Application with PasswordCredentials. The following doc uses Password and not PasswordCredentials https://docs.microsoft.com/en-us/powershell/module/az.resources/new-azadapplication?view=azps-2.4.0

Could anyone suggest how do i create PasswordCredentials object using Az module and pass in the New-AzADApplication

New-AzADApplication -DisplayName "xxx" -IdentifierUris "xxx" -PasswordCredentials 
1
From the type name, I'd guess New-AzureRmADSpCredential - Mathias R. Jessen
@MathiasR.Jessen New-AzADApplication is part of new Az module and not AzureRM and for new scripts i am using Az so this won't help - 3355307
Maybe this answer can help? - Theo
@Theo if you look into the code its using New-AzureRmADApplication and i have mentioned in the question and comments that I need Az example not AzureRM so that link won't help - 3355307
I meant just the part where the PSADPasswordCredential is created. Skip the last 4 lines - Theo

1 Answers

1
votes

Try the following:

$passwordCred = [Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential]@{ 
    "StartDate" = [DateTime]::UtcNow
    "EndDate" = [DateTime]::UtcNow.AddYears(1)
    "Password" = "{password-here}"
}

New-AzADApplication -DisplayName "My_app" `
                    -IdentifierUris "https://example.com/api" ` 
                    -PasswordCredentials @($passwordCred)