-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAD GroupMember_AccountCreationDate
More file actions
39 lines (30 loc) · 1.49 KB
/
Copy pathAD GroupMember_AccountCreationDate
File metadata and controls
39 lines (30 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
<#
.DESCRIPTION
Created to review group members and account creation dates
.INPUTS
$domain - Prompts for domain to search
$group - Promptes for the group name
.OUTPUTS
Produces a list of All users in the selected group, then searches that user list for AD Creation Dates
.NOTES
Created by John Skinner
.LINK
#>
# PowerShell to extract members of the groups
Write-Host "***************************************************************" -ForegroundColor cyan
Write-Host "Welcome to your Friendly Neighborhood AD Group Member Extractor" -ForegroundColor cyan
Write-Host "***************************************************************" -ForegroundColor cyan
# Group selection variables
$domain = read-host "What Domain do you want to look at?"
$group = read-host "What AD group do you want to extract?"
Get-ADGroupMember -Server $domain -Identity $group | Select samaccountName -ExpandProperty samaccountName | Out-File c:\temp\users.txt
Write-Host "AD Group Extract complete, Searching creation date... this will take some time" -ForegroundColor yellow
# Loop variables
$UserNamesList = get-content -path "C:\temp\users.txt"
$exportPath = "C:\temp\Users_Detailed.csv"
# Run the magic
foreach ($name in $UserNamesList){
Get-ADUser -Server $domain $name -properties * | select Name,samaccountname,whenCreated | Export-CSV $ExportPath -Append -NoTypeInformation
}
Write-Host "Script Complete!" -ForegroundColor green
Write-Host "The export file is stored here --> $ExportPath" -ForegroundColor Cyan