Skip to content

Commit cd80f53

Browse files
authored
Merge pull request #8246 from cormacpayne/ad-user-fix
Make MailNickname parameter mandatory for New-AzADUser
2 parents 1001d5a + c065d01 commit cd80f53

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADUserCommand.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class NewAzureADUserCommand : ActiveDirectoryBaseCmdlet
4242
[ValidateNotNullOrEmpty]
4343
public string ImmutableId { get; set; }
4444

45-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The mail alias for the user.")]
45+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The mail alias for the user.")]
4646
public string MailNickname { get; set; }
4747

4848
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "It must be specified if the user should change the password on the next successful login. Default behavior is to not change the password on the next successful login.")]
@@ -56,6 +56,7 @@ public override void ExecuteCmdlet()
5656
{
5757
AccountEnabled = true,
5858
DisplayName = DisplayName,
59+
MailNickname = MailNickname,
5960
PasswordProfile = new PasswordProfile
6061
{
6162
Password = decodedPassword,
@@ -64,11 +65,6 @@ public override void ExecuteCmdlet()
6465
UserPrincipalName = UserPrincipalName
6566
};
6667

67-
if (this.IsParameterBound(c => c.MailNickname))
68-
{
69-
userCreateparameters.MailNickname = MailNickname;
70-
}
71-
7268
if (this.IsParameterBound(c => c.ImmutableId))
7369
{
7470
userCreateparameters.ImmutableId = ImmutableId;

src/Resources/Resources/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
- More information here: https://github.com/Azure/azure-powershell/issues/7875
2323
* Fix handling of the -Custom parameter in New/Set-AzPolicyDefinition
2424
* Fix typo in New-AzDeployment documentation
25+
* Made `-MailNickname` parameter mandatory for `New-AzADUser`
26+
- More information here: https://github.com/Azure/azure-powershell/issues/8220
2527

2628
## Version 1.0.0
2729
* General availability of `Az.Resources` module

src/Resources/Resources/help/New-AzADUser.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml
33
Module Name: Az.Resources
44
ms.assetid: 86D8965D-D999-48A4-A4EE-9E054E5486EE
@@ -15,7 +15,7 @@ Creates a new active directory user.
1515

1616
```
1717
New-AzADUser -DisplayName <String> -UserPrincipalName <String> -Password <SecureString> [-ImmutableId <String>]
18-
[-MailNickname <String>] [-ForceChangePasswordNextLogin] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
18+
-MailNickname <String> [-ForceChangePasswordNextLogin] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
1919
[-Confirm] [<CommonParameters>]
2020
```
2121

@@ -105,7 +105,7 @@ Type: System.String
105105
Parameter Sets: (All)
106106
Aliases:
107107

108-
Required: False
108+
Required: True
109109
Position: Named
110110
Default value: None
111111
Accept pipeline input: True (ByPropertyName)

tools/StaticAnalysis/Exceptions/Az.Resources/BreakingChangeIssues.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,5 @@
108108
"Microsoft.Azure.PowerShell.Cmdlets.ResourceManager.Cmdlets.dll","Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzurePolicyAssignmentCmdlet","Set-AzPolicyAssignment","0","2000","The cmdlet 'Set-AzPolicyAssignment' no longer supports the parameter 'Sku' and no alias was found for the original parameter name.","Add the parameter 'Sku' back to the cmdlet 'Set-AzPolicyAssignment', or add an alias to the original parameter name."
109109
"Microsoft.Azure.PowerShell.Cmdlets.ResourceManager.Cmdlets.dll","Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzurePolicyAssignmentCmdlet","Set-AzPolicyAssignment","0","1050","The parameter set 'NameParameterSet' for cmdlet 'Set-AzPolicyAssignment' has been removed.","Add parameter set 'NameParameterSet' back to cmdlet 'Set-AzPolicyAssignment'."
110110
"Microsoft.Azure.PowerShell.Cmdlets.ResourceManager.Cmdlets.dll","Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzurePolicyAssignmentCmdlet","Set-AzPolicyAssignment","0","1050","The parameter set '__AllParameterSets' for cmdlet 'Set-AzPolicyAssignment' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'Set-AzPolicyAssignment'."
111-
"Microsoft.Azure.PowerShell.Cmdlets.ResourceManager.Cmdlets.dll","Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzurePolicyAssignmentCmdlet","Set-AzPolicyAssignment","0","1050","The parameter set 'IdParameterSet' for cmdlet 'Set-AzPolicyAssignment' has been removed.","Add parameter set 'IdParameterSet' back to cmdlet 'Set-AzPolicyAssignment'."
111+
"Microsoft.Azure.PowerShell.Cmdlets.ResourceManager.Cmdlets.dll","Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzurePolicyAssignmentCmdlet","Set-AzPolicyAssignment","0","1050","The parameter set 'IdParameterSet' for cmdlet 'Set-AzPolicyAssignment' has been removed.","Add parameter set 'IdParameterSet' back to cmdlet 'Set-AzPolicyAssignment'."
112+
"Microsoft.Azure.PowerShell.Cmdlets.Resources.dll","Microsoft.Azure.Commands.ActiveDirectory.NewAzureADUserCommand","New-AzADUser","0","1050","The parameter set '__AllParameterSets' for cmdlet 'New-AzADUser' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'New-AzADUser'."

0 commit comments

Comments
 (0)