Skip to content

Added ability to set 'Description' field when calling New-AzADGroup (Issue #9004) #9183

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 14 commits into from
May 26, 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 @@ -31,13 +31,22 @@ public class NewAzureADGroupCommand : ActiveDirectoryBaseCmdlet
[ValidateNotNullOrEmpty]
public string MailNickname { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description for the group.")]
public string Description { get; set; }

public override void ExecuteCmdlet()
{
var groupCreateParams = new GroupCreateParameters()
{
DisplayName = DisplayName,
MailNickname = MailNickname
MailNickname = MailNickname,
AdditionalProperties = new System.Collections.Generic.Dictionary<string, object>()
};

if (!string.IsNullOrEmpty(Description))
{
groupCreateParams.AdditionalProperties.Add("description", Description);
}

ExecutionBlock(() =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -60,7 +60,8 @@ public static PSADObject ToPSADObject(this AADObject obj)
Id = obj.ObjectId,
Type = obj.ObjectType,
SecurityEnabled = obj.SecurityEnabled,
MailNickname = obj.Mail
MailNickname = !string.IsNullOrEmpty(obj.Mail) ? obj.Mail : obj.AdditionalProperties.ContainsKey("mailNickname") ? obj.AdditionalProperties["mailNickname"]?.ToString() : null,
Description = obj.AdditionalProperties.ContainsKey("description") ? obj.AdditionalProperties["description"]?.ToString() : null
};
}
else if (obj.ObjectType == typeof(ServicePrincipal).Name)
Expand Down Expand Up @@ -110,7 +111,8 @@ public static PSADGroup ToPSADGroup(this ADGroup group)
DisplayName = group.DisplayName,
Id = group.ObjectId,
SecurityEnabled = group.SecurityEnabled,
MailNickname = group.Mail
MailNickname = !string.IsNullOrEmpty(group.Mail) ? group.Mail : group.AdditionalProperties.ContainsKey("mailNickname") ? group.AdditionalProperties["mailNickname"]?.ToString() : null,
Description = group.AdditionalProperties.ContainsKey("description") ? group.AdditionalProperties["description"]?.ToString() : null
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Resources/ActiveDirectory/Models/PSADGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ public class PSADGroup : PSADObject
public string MailNickname { get; set; }

public string ObjectType => "Group";

public string Description { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Resources/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
-->
## Upcoming Release
* Add new cmdlet Get-AzureRmDenyAssignment for retrieving deny assignments
* Added 'Description' parameter when working with Azure AD Groups:
- Added a parameter to New-AzAdGroup
- Added as output on Get-AzAdGroup

## Version 1.3.1
* Fix documentation for wildcards
Expand Down
17 changes: 16 additions & 1 deletion src/Resources/Resources/help/New-AzADGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Creates a new active directory group.
## SYNTAX

```
New-AzADGroup -DisplayName <String> -MailNickname <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
New-AzADGroup -DisplayName <String> -MailNickname <String> [-Description <string>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

Expand Down Expand Up @@ -47,6 +47,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Description
The description for the group.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -DisplayName
The display name for the group.

Expand Down