Home > Active Directory, Commands, Microsoft, Powershell, Scripts > PowerShell – Search any User on Active Directory–updated

PowerShell – Search any User on Active Directory–updated

November 21, 2016 Leave a comment Go to comments

Below is an updated script that helps you find any user in AD with details like when the User object was created, modified, lockout time, bad password time, last logon etc.

$user = Read-Host "Enter the name of the user"
Get-ADUser -Filter "sAMAccountName -like ‘*$user*’" |
Get-ADObject -Properties * | fl Name,SamAccountName,UserPrincipalName,DistinguishedName,objectSID,Title,Department,telephoneNumber,` Created,Modified,lockoutTime,`
@{n=’accountExpires’;e={[DateTime]::FromFileTime($_.accountExpires)}},`
@{n=’LastLogon’;e={[DateTime]::FromFileTime($_.LastLogon)}},`
@{n=’badPasswordTime’;e={[DateTime]::FromFileTime($_.badPasswordTime)}},`
@{n=’pwdLastSet’;e={[DateTime]::FromFileTime($_.pwdLastSet)}},`
msExchWhenMailboxCreated

-Eric

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: