-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-PasswordLastSet.ps1
More file actions
35 lines (31 loc) · 1.33 KB
/
Get-PasswordLastSet.ps1
File metadata and controls
35 lines (31 loc) · 1.33 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
Function Get-PasswordLastSet {
Param(
[Parameter(Mandatory=$false)]
[Alias("user", "account")]
[String]
$userName
)
If (!$userName) {
Write-Host "Please input the username of the user who you would like to check:"
$userName = Read-Host #Stores the username variable
}
Import-Module ActiveDirectory
Get-ADUser -Identity $userName -Properties * | `
Select-Object Enabled, `
GivenName, `
Surname, `
Name, `
SamAccountName, `
Title, `
Department, `
whenCreated, `
@{Name="LastLogon TimeStamp";Expression={[datetime]::FromFileTime($_.'lastLogonTimeStamp')}}, `
@{Name="Last Logon";Expression={[datetime]::FromFileTime($_.'lastLogon')}}, `
PasswordExpired, `
PasswordLastSet, `
badPwdCount, `
LastBadPasswordAttempt, `
@{Name="badPasswordTime";Expression={[datetime]::FromFileTime($_.'badPasswordTime')}}, `
@{Name='Manager';Expression={(Get-ADUser $_.Manager).GivenName + " " + (Get-ADUser $_.Manager).Surname}}
Clear-Variable userName
}