Use GetGroup with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use GetGroup with a CLI

The following code examples show how to use GetGroup.

CLI
AWS CLI

To get an IAM group

This example returns details about the IAM group Admins.

aws iam get-group \ --group-name Admins

Output:

{ "Group": { "Path": "/", "CreateDate": "2015-06-16T19:41:48Z", "GroupId": "AIDGPMS9RO4H3FEXAMPLE", "Arn": "arn:aws:iam::123456789012:group/Admins", "GroupName": "Admins" }, "Users": [] }

For more information, see IAM Identities (users, user groups, and roles) in the AWS IAM User Guide.

  • For API details, see GetGroup in AWS CLI Command Reference.

PowerShell
Tools for PowerShell

Example 1: This example returns details about the IAM group Testers, including a collection of all the IAM users that belong to the group.

$results = Get-IAMGroup -GroupName "Testers" $results

Output:

Group IsTruncated Marker Users ----- ----------- ------ ----- Amazon.IdentityManagement.Model.Group False {Theresa, David}
$results.Group

Output:

Arn : arn:aws:iam::123456789012:group/Testers CreateDate : 12/10/2014 3:39:11 PM GroupId : 3RHNZZGQJ7QHMAEXAMPLE1 GroupName : Testers Path : /
$results.Users

Output:

Arn : arn:aws:iam::123456789012:user/Theresa CreateDate : 12/10/2014 3:39:27 PM PasswordLastUsed : 1/1/0001 12:00:00 AM Path : / UserId : 4OSVDDJJTF4XEEXAMPLE2 UserName : Theresa Arn : arn:aws:iam::123456789012:user/David CreateDate : 12/10/2014 3:39:27 PM PasswordLastUsed : 3/19/2015 8:44:04 AM Path : / UserId : Y4FKWQCXTA52QEXAMPLE3 UserName : David
  • For API details, see GetGroup in AWS Tools for PowerShell Cmdlet Reference.