-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrabAD-GroupMembers.ps1
More file actions
42 lines (40 loc) · 1.49 KB
/
Copy pathGrabAD-GroupMembers.ps1
File metadata and controls
42 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#For this screipt to work you will need to change lines 18 and 23
#the "-server domainname" should be the name of the domain tha tyou want to search
Function Get-ADGroupMemberJohn {
[CmdletBinding()]
param(
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Position = 0
)]
[string[]]
$Identity
)
process {
foreach ($GroupIdentity in $Identity) {
$Group = $null
$Group = Get-ADGroup -Identity $GroupIdentity -Properties Member -server domainname
if (-not $Group) {
continue
}
Foreach ($Member in $Group.Member) {
Get-ADUser $Member -server domainname |Select-object -ExpandProperty name
}
}
}
}
Write-Host "***************************************************************" -ForegroundColor cyan
Write-Host "Welcome to your Friendly Nieghborhood AD Group Member Extractor" -ForegroundColor cyan
Write-Host "***************************************************************" -ForegroundColor cyan
$x = "go"
do {
$group = read-host "What group do you want?"
Get-ADGroupMemberJohn $group | Out-File C:\temp\MFAUsers.csv
Write-Host "Your Group Member list is stored in c:\Temp\MFAUsers.csv" -ForgroundColor green
$answer = Read-host "another one?"
if ($answer -eq "no" -or $answer -eq "n"){$x = "stop"}
cls
}
while ($x -ne "stop")