Cannot process argument transformation on parameter "PasswordProfile"

Gilbert Justin Hernandez 1 Reputation point
2022-12-15T15:29:13.097+00:00

Hello,

I'm trying current creating a AD User Account on Azure via Powershell and here is the command I'm trying to run

Connect-AzAccount

Generate Password Profile

$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = "IT0psT@lk"

New ADUser Parameters

$params = @{
AccountEnabled = $true
DisplayName = "Test User"
PasswordProfile = $PasswordProfile
UserPrincipalName = "******@onmicrosoft.com"
MailNickName = "TestUser"
}

New-AzADUser @params

and getting this error after running the command

New-AzADUser : Cannot process argument transformation on parameter 'PasswordProfile'. Cannot convert the "class PasswordProfile {
Password: Qwerty12356!
ForceChangePasswordNextLogin:
EnforceChangePasswordPolicy:
}
" value of type "Microsoft.Open.AzureAD.Model.PasswordProfile" to type
"Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile".
At C:\Users\Vert\Documents\WindowsPowerShell\Scripts\Create New User.ps1:16 char:14

  • New-AzADUser @params
  • ~~~~~~~
  • CategoryInfo : InvalidData: (:) [New-AzADUser], ParameterBindingArgumentTransformationException
  • FullyQualifiedErrorId : ParameterArgumentTransformationError,New-AzADUser

Hope you could help me figure this out. Thank you

Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,526 Reputation points Moderator
    2022-12-16T18:12:13.897+00:00

    Hello @Gilbert Justin Hernandez , the error is caused by passing an argument of type Microsoft.Open.AzureAD.Model.PasswordProfile. You need to pass one of type IMicrosoftGraphPasswordProfile. Try doing so as a hashtable:

       $params = @{  
       AccountEnabled = $true  
       DisplayName = "Test User"  
       PasswordProfile = @{  
           Password = "string"  
       }  
       UserPrincipalName = "******@onmicrosoft.com"  
       MailNickName = "TestUser"  
       }  
    

    Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.

    0 comments No comments

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.