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: Use Selenium Drivers to Automate Logins

Set Variables: $username='testrobot' $password='password' $url='https://blog.kimconnect.com' # Version 0.0.2 - return true or false, while keeping…

Basic JavaScript: Manipulate Arrays With unshift()

// Setupvar myArray = [["John", 23], ["dog", 3]];myArray.shift();// Only change code below this line.myArray.unshift( ["Paul",35]);

PowerShell: Disable Virtual Machine Queuing on Hyper-V Hosts

What is VMQ? Virtual Machine Queuing is a shortcut to deliver packet data from the…