A PowerShell script to help manage user and machine accounts.

Get inactive / old computer in your domain as a simple CSV.


# Gets time stamps for all computers in the domain that have NOT logged in since after specified date

import-module activedirectory

$domain = “domain.mydom.com

$DaysInactive = 90

$time = (Get-Date).Adddays(-($DaysInactive))


# Get all AD computers with lastLogonTimestamp less than our time

Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -Properties LastLogonTimeStamp |


# Output hostname and lastLogonTimestamp into CSV

select-object Name,@{Name=”Stamp”;

Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}} | export-csv OLD_Computer.csv -notypeinformation


Source:

https://gallery.technet.microsoft.com/Get-Inactive-Computer-in-54feafde

Get In Touch

Share On Social Media

Other Recent Blog Articles

The Exchange Server 2016 & 2019 Deadline is Looming: Don’t Get Left Behind

February 13, 2025

The writing is on the wall: October 14, 2025, marks the official end of support for Exchange Server 2016 and older versions of 2019. This means no more critical security…

Read More

Grubhub Data Breach: A Wake-Up Call for Businesses

February 12, 2025

The recent Grubhub data breach, exposing customer information like names, emails, and partial credit card details, serves as a stark reminder of the ever-present threat of cyberattacks. This incident underscores…

Read More

Level Up Your Gaming Knowledge This Friday!

February 7, 2025

**On ‘Breaking Down I.T. with Steve,’ we’re diving headfirst into the world of graphics cards. 💥 Learn why a high-end GPU is a game-changer for an epic gaming experience. We’ll…

Read More