A lot of people are confused about the PowerShell get user group membership operation. Are you also troubled by it? Now, this post of MiniTool will show you how to get user group membership PowerShell on Windows 10/11.

As it’s well known to us all, PowerShell is a practical Windows built-in command-line shell and scripting environment tool. It’s widely used by people to deal with various works such as  PowerShell get disk space, PowerShell run exe, PowerShell copy filesPowerShell gets folder sizeinstalling SSH PowerShellPowerShell unzip/zip files, etc.

However, a great many users and even experienced professionals are unclear about how to do these works in PowerShell. These PowerShell cmdlets are heatedly discussed among different forums, but most of them don’t provide detailed steps. That’s why we wrote this post. If you are also confused about PowerShell get user group membership, you can find the answer in the following part.

CMD Rename Files: How to Rename Files in Command Prompt
CMD Rename Files: How to Rename Files in Command Prompt

How to rename file CMD on Windows 10/11? Now, you come to the right place. This post will explain the CMD rename file operation in detail.

Read More

What Cmdlet Can Be Used to Get User Group Membership PowerShell

First of all, it’s important to figure out what cmdlet can be used to get users group membership PowerShell. After investigating extensive user reports and references, we find the following 3 cmdlets can help you get members of a group PowerShell.

  • Get-ADPrincipalGroupMembership: This cmdlet can be used to get all groups a user is a member of a group sing PowerShell. It can get the Active Directory groups’ membership that a specified user, group, computer, or server account as a member.
  • Get-ADUser: This cmdlet can help you get all groups the current user is a member of without importing the AD module. It can get a specified user group membership or perform a search to get multiple user objects.
  • Get-ADGroupMember: This cmdlet is mainly used to get the members of a specified group or an Active Directory group. Members can be users, groups, and even computers.

Now, you should have an overall understanding of the PowerShell get members of group cmdlets. Let’s see how to get members of group PowerShell on Windows 10/11.

How to Make PowerShell Get User Group Membership on Windows 10/11

According to the above information, we summarize 3 ways to get group membership PowerShell on Windows 10/11.

# 1. PowerShell Get Group Membership via Get-ADPrincipalGroupMembership

The first and most common way for PowerShell get members of group is to use the Get-ADPrincipalGroupMembership. Here’s how to use it.

Step 1. Press the Win + R keys to open the Run box, and then type powershell in it and press Ctrl + Shift + Enter keys to open the elevated PowerShell window.

Step 2. In the pop-up window, type the following command and hit Enter to get all group memberships for the Administrator. Here you can replace Administrator with the user name that you want to get its membership.

Get-ADPrincipalGroupMembership -Identity Administrator

get all group memberships for Administer using PowerShell

Step 3. If you want to get the members of an active directory group name and description for a specified user like Ariel, run the following command.

Get-ADPrincipalGroupMembership -Identity Ariel | Get-ADGroup -Properties Description | Select Name, Description

Step 4. If you want to get all of the group memberships for the administrator in the resource domain, you can try the following command. For example, we want to locate the resource domain. Make sure to replace the domain name according to your actual situation.

Get-ADPrincipalGroupMembership -Identity Administrator -ResourceContextServer MiniTool.Partition.Com -ResourceContextPartition “DC=Partition,DC=com”

# 2. PowerShell Get Group Membership via Get-ADUser

Another feasible way for PowerShell get members of a group is to use the Get-AdUser cmdlet. Here are detailed steps:

Step 1. Open the elevated PowerShell window again as we explain above.

Step 2. Type the following command and hit Enter to get the groups in Active Directory. Here you need to replace the username with the user name that you want to list its members.

Get-ADUser Username –Properties MemberOf).memberof | Get-ADGroup | Select-Object name

Step 3. Also, you can run the following command to get the ad groups of a specified username such as Ariel.

Get-ADUser Ariel –Properties MemberOf).MemberOf

# 3. PowerShell Get Group Membership via Get-ADGroupMember

If you want to get all members of a specified group, you can type the following commands in order and hit Enter after each one in the elevated PowerShell window. Similarly, you need to replace the account name with the name you want to list its membership.

Import-Module ActiveDirectory

Get-ADGroupMember -Identity $group | foreach-object {Write-Host $_.ArielAccountName}

CMD Ping Test: How to Ping from Command Prompt Windows 10/11
CMD Ping Test: How to Ping from Command Prompt Windows 10/11

What can you do with the CMD ping test? How to ping from Command Prompt Windows 10/11? How to read the ping test results? Now, you can get the answers here.

Read More

Further reading: If you enter some issues like file system corruption and low disk space on Windows 10/11, don’t worry. MiniTool Partition Wizard can help you fix them easily by checking file system errors, extending/resizing partitions, analyzing disk space, upgrading to a larger hard disk, etc.

  • linkedin
  • reddit