Categories
Microsoft

Powershell : Query for user’s last logon date

I needed to work out some AD accounts’ last logon dates to make a further assessment, in powershell I found this was fairly simple:

To get a list of all user attributes available for query:

$> get-aduser -identity <USERNAME_HERE> -Properties *

To query for last logon date:

$> get-aduser -identity <USERNAME_HERE> -Properties LastLogonDate

 

Categories
Microsoft

Active Directory Powershell Last Login Date

PS C:\> get-adcomputer -Filter 'Name -like "$COMPNAME_HERE*"' -Properties lastlogondate | select name,lastlogondate

Categories
Microsoft

trust relationship failed, windows domain

HKLM\System\CurrentControlSet\services\Netlogon\Parameters

Change the value:

DisablePasswordChange=1

 

2016-07-21 UPDATE:

Discovered this thread which mentions using PowerShell to reset the machine password, if you haven’t completed the registry change:

Open PowerShell as administrator. Run this command sequence:

$credential = Get-Credential

(enter domain admin account when prompted)

Reset-ComputerMachinePassword -Server <<YOUR DC NAME HERE>>

Thanks to: https://community.spiceworks.com/how_to/108912-fix-the-trust-relationship-between-this-workstation-and-the-primary-domain-failed