Posted On March 29, 2019

Last Logon Dates of List of AD Accounts

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> Last Logon Dates of List of AD Accounts
import-module activedirectory
$output=""

Get-Content C:\Users\kimconnect\Desktop\targetAccounts.txt | Foreach-Object -Process{
#  cast an array object as string before using string operations
  $output+=$_+": "+([string](Get-ADUser $_ -Properties * | Select lastLogonDate) -replace "@{lastLogonDate=*" -replace "}") + "`n"
}
$output

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Install FreePBX

Add port UDP 5060 NAT entry in firewallSet up new user (extension)Applications >> Extensions >>…

HTML: Tagging and Jumping to Sections of Page

Each element of an HTML document could be set with a unique ID so that…

Install AWS Command Line Interface on Windoze

Obtain AWS Access Key: Log into AWS > click on your User Name > My…