Skip to content

Commit bdf2f9d

Browse files
committed
Groups
1 parent 9ea3685 commit bdf2f9d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,52 @@ Potential-weak-target-accounts.ps1
4848
4949
----
5050

51+
## Status of AD Group Members
52+
53+
>Get the status of group members in group for their last logon, enabled, description, password last set dates:
54+
55+
```PowerShell
56+
# Define the Active Directory group name
57+
$GroupName = "Group Finance Users SG"
58+
59+
# Define the output CSV file path
60+
$OutputCSV = "D:\Temp\FinanceSG_Members.csv"
61+
62+
# Import the Active Directory module (ensure RSAT is installed)
63+
Import-Module ActiveDirectory
64+
65+
# Get members of the AD group
66+
$Members = Get-ADGroupMember -Identity $GroupName -Recursive | Where-Object { $_.objectClass -eq "user" }
67+
68+
# Retrieve user properties
69+
$UserDetails = $Members | ForEach-Object {
70+
$User = Get-ADUser -Identity $_.SamAccountName -Properties SamAccountName, Description, Enabled, LastLogonDate, PasswordLastSet, PasswordNeverExpires, LastLogon, LastLogonTimestamp
71+
72+
# Convert LastLogon and LastLogonTimestamp to readable date format
73+
$LastLogonReadable = if ($User.LastLogon -gt 0) { [datetime]::FromFileTime($User.LastLogon) } else { $null }
74+
$LastLogonTimestampReadable = if ($User.LastLogonTimestamp -gt 0) { [datetime]::FromFileTime($User.LastLogonTimestamp) } else { $null }
75+
76+
# Construct output object
77+
[PSCustomObject]@{
78+
SamAccountName = $User.SamAccountName
79+
Description = $User.Description
80+
Enabled = $User.Enabled
81+
LastLogonDate = $User.LastLogonDate
82+
PasswordLastSet = $User.PasswordLastSet
83+
PasswordNeverExpires= $User.PasswordNeverExpires
84+
LastLogon = $LastLogonReadable
85+
LastLogonTimestamp = $LastLogonTimestampReadable
86+
}
87+
}
88+
89+
# Export to CSV
90+
$UserDetails | Export-Csv -Path $OutputCSV -NoTypeInformation
91+
92+
Write-Output "Export completed: $OutputCSV"
93+
```
94+
95+
----
96+
5197
## Kerberoasting
5298

5399
>PowerShell Script: `get-kerberoastable-user-info.ps1`

0 commit comments

Comments
 (0)