Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-AzADUser: Following documentation leads to "constructor not found" issue #19265

Closed
CallumCrowley opened this issue Aug 18, 2022 · 4 comments · Fixed by #19308 or #19337
Closed

New-AzADUser: Following documentation leads to "constructor not found" issue #19265

CallumCrowley opened this issue Aug 18, 2022 · 4 comments · Fixed by #19308 or #19337
Assignees
Labels
AAD AzAd cmdlets in Az.Resources Azure PS Team bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Doc - Reference

Comments

@CallumCrowley
Copy link

Description

Issue

The documentation here states that you must construct a password profile object using the type:

Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile

However, despite importing both Az.Accounts and Az.Resources, this will result in an error:

Error: A constructor was not found. Cannot find an appropriate constructor for type Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile.

Issue script & Debug output

$passwordProfile = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile" -Property @{
                Password = $user.Password
                ForceChangePasswordNextSignIn = $false
                ForceChangePasswordNextSignInWithMfa = $false
            }

New-AzADUser -DisplayName $user.Name -PasswordProfile $passwordProfile -AccountEnabled $true -MailNickname $mailNickname -Mail $emailAddress -UserPrincipalName $upn -OtherMail $otherMail

Environment data

Name                           Value                                                                                                                                                          
----                           -----                                                                                                                                                          
PSVersion                      5.1.22000.653                                                                                                                                                  
PSEdition                      Desktop                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                        
BuildVersion                   10.0.22000.653                                                                                                                                                 
CLRVersion                     4.0.30319.42000                                                                                                                                                
WSManStackVersion              3.0                                                                                                                                                            
PSRemotingProtocolVersion      2.3                                                                                                                                                            
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands                                                                                                                    
---------- -------    ----                                ----------------                                                                                                                    
Script     2.9.1      Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}                                                            
Script     6.1.0      Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}

Error output

A constructor was not found. Cannot find an appropriate constructor for type Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile.
@CallumCrowley CallumCrowley added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 18, 2022
@ghost ghost added customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 18, 2022
@dingmeng-xue
Copy link
Member

@CallumCrowley , Thanks for reporting. It is an issue in doc. IMicrosoftGraphPasswordProfile is interface. You should use MicrosoftGraphPasswordProfile. We need to fix this doc soon.

$passwordProfile = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.MicrosoftGraphPasswordProfile" -Property @{
  Password = $user.Password
  ForceChangePasswordNextSignIn = $false
  ForceChangePasswordNextSignInWithMfa = $false
}

@CallumCrowley
Copy link
Author

@dingmeng-xue yes, I actually tried this but I found that the New-AzADUser cmdlet would then ignore the PasswordProfile parameter and demand that the Password parameter be completed.

Can you confirm if there is an issue using the PasswordProfile parameter with this cmdlet?

@VeryEarly
Copy link
Contributor

@dingmeng-xue yes, I actually tried this but I found that the New-AzADUser cmdlet would then ignore the PasswordProfile parameter and demand that the Password parameter be completed.

Can you confirm if there is an issue using the PasswordProfile parameter with this cmdlet?

Hi @CallumCrowley ,

Thanks for pointing out, currently "-Password" will overwrite and ignore "-PasswordProfile", I'll make the fix soon in 2022-09-06-release

@CallumCrowley
Copy link
Author

@VeryEarly thanks for confirming! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AAD AzAd cmdlets in Az.Resources Azure PS Team bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Doc - Reference
Projects
None yet
3 participants