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

PowerShell: Remove Hyper-V VM Snapshots

Hyper-V's snapshot feature is a double-edged sword. It's a convenient method to make a quick…

How to Expand a Windows NTFS Volume as a LUN of HPe Nimble Storage

1. Take volume off synchronous mode - Pre-emptively avoid this error: "Failed to update the…

PowerShell: Impersonation to Download Files Through Proxy

Initial Script to without impersonation # Change these values to reflect your desired downloads[string]$fileSource =…