Get-ADGroupNames.ps1
19 Sep 2025Description
Purpose
Extracts members of an Active Directory group based on the group name.
Detailed Description
The Get-ADGroupNames function extracts members of an Active Directory group based on the group name. It supports wildcards in the group name.
Usage
Example 1
Get-ADGroupNames -GroupName "Domain Admins"
Extracts members of the “Domain Admins” group.
Example 2
Get-ADGroupNames -GroupName "Sales*"
Extracts members of all groups starting with “Sales”.
Notes
Author: Your Name Date: Today’s date
Script
<#
.SYNOPSIS
Extracts members of an Active Directory group based on the group name.
.DESCRIPTION
The Get-ADGroupNames function extracts members of an Active Directory group based on the group name.
It supports wildcards in the group name.
.PARAMETER GroupName
Specifies the name of the group to search for. This field supports wildcards.
.EXAMPLE
Get-ADGroupNames -GroupName "Domain Admins"
Extracts members of the "Domain Admins" group.
.EXAMPLE
Get-ADGroupNames -GroupName "Sales*"
Extracts members of all groups starting with "Sales".
.INPUTS
None.
.OUTPUTS
Returns a list of members of the specified group.
.NOTES
Author: Your Name
Date: Today's date
#>
function Get-ADGroupNames {
[CmdletBinding(DefaultParameterSetName = 'Default',
PositionalBinding = $true,
SupportsShouldProcess = $true)]
param
(
[Parameter(ParameterSetName = 'Default',
Mandatory = $false,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Position = 1,
HelpMessage = 'Enter the group name that you want to search for. This field supports wildcards.')]
[String]$GroupName = '*'
)
begin {
# Update-FormatData -PrependPath "$PSScriptRoot\Get-ADGroupNames.Format.ps1xml"
}
process {
if ($PSCmdlet.ShouldProcess("$GroupName", "Extract members of group")) {
Get-ADGroup -Filter "Name -like '$GroupName'" -Properties *
}
}
end {
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.