@Gregor Anton Grinč Thank you for reaching out to us, As I understand you want to use Authentication parameter within New-Mguser cmdlet, I have tested this requirement in my lab and below is the script which you can use to achieve your ask.
##Import the Microsoft Graph Users module
Import-Module Microsoft.Graph.Users
##Connect to Microsoft Graph with the user read/write permission
Connect-MgGraph -scope "User.ReadWrite.All,UserAuthenticationMethod.ReadWrite.All"
##Define the password profile settings within a hash table
$PasswordProfile = @{
Password = "Helo123!"
ForceChangePasswordNextSignIn = $true
ForceChangePasswordNextSignInWithMfa = $true
}
$params = @{
emailAddress = "******@text.com"
}
$userid = New-MgUser -DisplayName "New User2" -PasswordProfile $PasswordProfile -AccountEnabled -MailNickName "nuser2" -UserPrincipalName "******@M365xXXXXXXX.onmicrosoft.com"
Get-mguser -UserId $userid.id
New-MgUserAuthenticationEmailMethod -UserId $userid.id -BodyParameter $params
However I did tried to use Authentication switch along with New-Mguser as mentioned here - https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/new-mguser?view=graph-powershell-1.0 when ran the same encountered with the below error
Which says, during the initial post, authentication switch cannot be used and set the same in subsequent patch request, I will check with my team on this internally about this behavior and update the documentation accordingly.
Also make sure you have one of the roles assigned to the user Authentication Administrator or Privileged Authentication Administrator who is performing this task.
Let me know if you have any further questions, feel free to post back.
Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.