Skip to content

Commit

Permalink
Merge pull request #8246 from cormacpayne/ad-user-fix
Browse files Browse the repository at this point in the history
Make MailNickname parameter mandatory for New-AzADUser
  • Loading branch information
cormacpayne authored Jan 8, 2019
2 parents 1001d5a + c065d01 commit cd80f53
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class NewAzureADUserCommand : ActiveDirectoryBaseCmdlet
[ValidateNotNullOrEmpty]
public string ImmutableId { get; set; }

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

[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.")]
Expand All @@ -56,6 +56,7 @@ public override void ExecuteCmdlet()
{
AccountEnabled = true,
DisplayName = DisplayName,
MailNickname = MailNickname,
PasswordProfile = new PasswordProfile
{
Password = decodedPassword,
Expand All @@ -64,11 +65,6 @@ public override void ExecuteCmdlet()
UserPrincipalName = UserPrincipalName
};

if (this.IsParameterBound(c => c.MailNickname))
{
userCreateparameters.MailNickname = MailNickname;
}

if (this.IsParameterBound(c => c.ImmutableId))
{
userCreateparameters.ImmutableId = ImmutableId;
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
- More information here: https://github.com/Azure/azure-powershell/issues/7875
* Fix handling of the -Custom parameter in New/Set-AzPolicyDefinition
* Fix typo in New-AzDeployment documentation
* Made `-MailNickname` parameter mandatory for `New-AzADUser`
- More information here: https://github.com/Azure/azure-powershell/issues/8220

## Version 1.0.0
* General availability of `Az.Resources` module
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Resources/help/New-AzADUser.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml
Module Name: Az.Resources
ms.assetid: 86D8965D-D999-48A4-A4EE-9E054E5486EE
Expand All @@ -15,7 +15,7 @@ Creates a new active directory user.

```
New-AzADUser -DisplayName <String> -UserPrincipalName <String> -Password <SecureString> [-ImmutableId <String>]
[-MailNickname <String>] [-ForceChangePasswordNextLogin] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
-MailNickname <String> [-ForceChangePasswordNextLogin] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

Expand Down Expand Up @@ -105,7 +105,7 @@ Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@
"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."
"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'."
"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'."
"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'."
"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'."
"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 comments on commit cd80f53

Please sign in to comment.