Posted On August 2, 2022

PowerShell: Get LastLogon Information of Computer Objects

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Get LastLogon Information of Computer Objects
$computernames=@(
    'COMPUTER1',
'COMPUTER2'
)

$computerLastLogon=foreach($computerName in $computernames){
    get-adcomputer $computerName -Properties LastLogon|select Name,@{Name='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}}
}
$computerLastLogon|sort -Property LastLogon

Leave a Reply

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

Related Post

Expanding System Volume C Drive of Windows Hyper-V Virtual Machine

There are three three steps to expand a disk of a virtual machine: Connect to…

PowerShell: Creating Active Directory Accounts from CSV File

# User-input Variables $csvFile='C:\Users\rambo\Desktop\newUsers-finalized.csv' $newOu='CN=Users,DC=kimconnect,DC=com' $newCompany='KimConnect.com' $logFile="c:\temp\createActiveDirectoryAccounts-$(get-date -f yyyy-mm-dd-hh-mm-ss).txt" function createActiveDirectoryAccounts{ param( $csvFile, $newOu, $newCompany,…

PowerShell: How To Append to Windows Environmental Paths Permanently

Often, when we install applications such as Python, its bin directory may not automatically be…