skip to Main Content

I’m trying to create new Azure Active Directory application, using this PowerShell command:

$SecurePassword=ConvertTo-SecureString {password} -asplaintext -force
New-AzADApplication -DisplayName {Display name} -HomePage {Home page URL} -IdentifierUris {Application identifier} -Password $SecurePassword

But I get an error that says Cannot convert value "System.Security.SecureString" to type "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordCredential[]".

Here’s the full error:

New-AzADApplication: Cannot process argument transformation on parameter 'PasswordCredentials'. Cannot convert value "System.Security.SecureString" to type "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordCredential[]". Error: "Cannot convert the "System.Security.SecureString" value of type "System.Security.SecureString" to type "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordCredential"."

Yet, I can’t find any information about how to convert another way. I’m relatively new to PowerShell though. Anyone know how to resolve this error? Thank you.

The command came from here:
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-rm-rest

2

Answers


  1. The latest New-AzADApplication cmdlet has not contain the Password parameter. Thats why it is throwing the below error.
    enter image description here

    Workaround to avoid the issue:

    1. First create the Azure AD Application New-AzADApplication as a Service principal New-AzADServicePrincipal.
    #creating AZ AD Application
     $myApp = New-AzADApplication -DisplayName "<Application Display Name>" -IdentifierUris '<Application Identifier Url>'
     # AD application Service principal 
     New-AzADServicePrincipal -ApplicationId $myApp.ApplicationId.Guid -SkipAssignment
    
    1. Use the New-AzADAppCredential cmdlet to add a custom password,
    #In this way we can add our password
     $SecurePassword  =  ConvertTo-SecureString  -String  "<Your custom password>"  -AsPlainText  -Force  
     New-AzADAppCredential  -ObjectId  "<AD Application object Id>"  -Password  $SecurePassword
    
    Login or Signup to reply.
  2. I don’t know how Delliganesh got this to work with a -Password property, as that isn’t a member of New-AzADAppCredential. When you do this you are asking the application to create a new key and secret for you, that you must record in order to work with it. If you pipe New-AzADAppCredential -ObjectId "xxx…." to Get-Member, you will see that there isn’t a -Password property for it. So, in order to get this to work, do the following:

    $myApp = New-AzADApplication -DisplayName "Application Display Name"
    -IdentifierUris "Application Identifier Url"

    New-AzADServicePrincipal -ApplicationId $myApp.AppId

    Then, in the Azure Portal, go to App Registrations and locate your new App. In the Overview for it, you will see the Object ID. Copy that to the clipboard, and then:

    New-AzADAppCredential -ObjectId "xxx….."

    This will generate the key and secret that I mentioned earlier, which you should make a note of. Also note the expiry date and time if you plan to use them long-term.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search