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: Time Stamp Variable

This is useful in almost any script as it enables the accurate timestamp of log…

Hyper-V: Attach a New Virtual Disk

$vmName='TestVm' $storageLocation='\\FILESERVER06\SHAREXOXO' $newDiskSize='100GB' $dynamic=$true function createNewDisk{ param( $vmName, $storageLocation, $newDiskSize='100GB', $dynamic=$true ) $ErrorActionPreference='stop' try{ write-host…

How To Use Command Line to Configure iDrac Settings

Step 1: Install RacADM $computerlist=@' SERVER1 SERVER2 '@ $computernames=@($computerlist -split "`n")|%{$_.Trim()} $fileURL="https://dl.dell.com/FOLDER08543783M/1/DellEMC-iDRACTools-Web-WINX64-10.3.0.0-4945.exe" $expectedExecutable='racadm.exe' $expectedInstallPath='C:\Program Files\Dell\SysMgt\iDRACTools\racadm'…