Skip to content

Commit 2ed7e49

Browse files
authored
✨ Add password remaining info
1 parent 2a69774 commit 2ed7e49

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Get-ADUserStatus.ps1

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Get-ADUser
1414
.EXAMPLE
1515
Get-ADUserStatus.ps1 alans
1616
17+
PasswordExpires : 07/17/2023 12:01:01 AM
18+
BadLogonsRemaining : 5
1719
AccountExpirationDate :
1820
AccountExpires : 9223372036854775807
1921
AccountLockoutTime :
@@ -42,5 +44,8 @@ UserPrincipalName : [email protected]
4244
[CmdletBinding()][OutputType([Microsoft.ActiveDirectory.Management.ADUser])] Param(
4345
[Parameter(Position=0,Mandatory=$true)][Microsoft.ActiveDirectory.Management.ADUser] $Identity
4446
)
45-
Get-ADUser -Identity $Identity -Properties AccountExpirationDate, AccountExpires, AccountLockoutTime, BadLogonCount,
46-
BadPwdCount, LastBadPasswordAttempt, LastLogonDate, LockedOut, PasswordExpired, PasswordLastSet, PwdLastSet
47+
$policy = Get-ADDefaultDomainPasswordPolicy
48+
return Get-ADUser -Identity $Identity -Properties AccountExpirationDate, AccountExpires, AccountLockoutTime, BadLogonCount,
49+
BadPwdCount, LastBadPasswordAttempt, LastLogonDate, LockedOut, PasswordExpired, PasswordLastSet, PwdLastSet |
50+
Add-NoteProperty.ps1 PasswordExpires {$_.PasswordLastSet + $policy.MaxPasswordAge} -Force -PassThru |
51+
Add-NoteProperty.ps1 BadLogonsRemaining {$policy.LockoutThreshold - $_.BadLogonCount} -Force -PassThru

0 commit comments

Comments
 (0)