@@ -48,6 +48,52 @@ Potential-weak-target-accounts.ps1
48
48
49
49
----
50
50
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
+
51
97
## Kerberoasting
52
98
53
99
> PowerShell Script: ` get-kerberoastable-user-info.ps1 `
0 commit comments