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

PowerShell: Get Active Directory Domain Controller Replication Status

$domaincontroller=(Get-ADForest |Select-Object -ExpandProperty RootDomain |Get-ADDomain |Select-Object -Property PDCEmulator).PDCEmulator; ## Define Objects ## $report = New-Object…

Kerberos “Second Hop” Problem

Issue Sometimes, there's a need to run WinRM into a "Jump Box" (trusted host in…

Resolving LDAPS Connection Errors

Errors: Can not connect to remote server: 5059 ERROR_CERTIFICATE_ERROR (unable to read server certificates from…