-
Notifications
You must be signed in to change notification settings - Fork 0
/
Group membership inspector.ps1
69 lines (43 loc) · 2.06 KB
/
Group membership inspector.ps1
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#Group membership inspector
# Copyright 2020 Steven Soward | MIT License
$ErrorActionPreference = "Stop"
$date = get-date
function groupdelve{
$group = Get-ADGroup -filter * -Properties groupcategory | Out-GridView -title "Steven's Group membership inspector - use the filter to search - select the desired group and click 'ok' to see group members" -PassThru | format-wide
$group = $group | Out-String
$group = $group.trim()
$number = get-ADGroupmember -identity $group
$number = $number.count
if ($number -eq 0){$userresponse=[System.Windows.MessageBox]::Show('The selected item has no members. ')
groupdelve}
$userresponse=[System.Windows.MessageBox]::Show("The $Group group has $number members")
$Selected = get-ADGroupmember -identity $group | Out-GridView -title "Showing members of $group, select member(s) and use ctrl+c to copy. Take note of any nested groups || $date" -PassThru | format-wide
Write-Host $selected
$selected= $Selected | out-string
$Selected = $Selected.Trim()
Write-Host $Selected
#$group=$selected
nestedviewer
}
groupdelve
function nestedviewer{
#$check = $Nestedview
$Nestedview = get-ADGroupmember -identity $Selected | Out-GridView -title "Showing members of $selected, select member(s) and use ctrl+c to copy. Take note of any nested groups || $date" -PassThru | format-wide
#
$Nestedview = $Nestedview | Out-String
if ($nestedview -eq $null) {exit}
$Nestedview = $Nestedview.Trim()
$selected = $Nestedview
$number2 = get-ADGroupmember -identity $nestedview
$number2 = $number2.count
if ($number2 -eq 0){$userresponse=[System.Windows.MessageBox]::Show('The Selected item has no members. ')
nestedview}
$userresponse=[System.Windows.MessageBox]::Show("The $Nestedview group has $number2 members")
do {
nestedviewer
}
until ($check -eq $selected)
}
# $userresponse=[System.Windows.MessageBox]::Show('The Selected group members have been copied to your clipboard.
# Be sure to check for nested groups and run again if needed')
exit