Graphical User interfaces (GUI) are nice but I also prefer working in PowerShell as you can just get so much more info than the GUI.

Recently I was working with groups and it was a bit of a pain to keep having to open the window in Active Directory Users and Computers so I put together a quick script to help get the members of a group.

The script is pretty straight forward and can be run from PowerShell ISE or if you choose PowerShell, it will work as well without having to save it as many environments limit .PS1 scripts.

In the example below, I wanted to check who was part of the group called “Organization Management”, below is the output of this:

Get members of a group with PowerShell

Here is the script below, you can modify as you need to:

# Prompt for the group name
$groupName = Read-Host "Enter the group name"

# Get the users in the specified group
$usersInGroup = Get-ADGroupMember -Identity $groupName

# Display the list of users
Write-Host "Users in group '$groupName':"
foreach ($user in $usersInGroup) {
    Write-Host $user.Name
}

Perhaps the above will help you if you are limited in what you launch on a server or you prefer to use PowerShell.

Hope it helps

Discover more from Everything-PowerShell

Subscribe now to keep reading and get access to the full archive.

Continue reading