Skip to content

Make MailNickname parameter mandatory for New-AzADUser #8246

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

Merged
merged 5 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'."