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 Tariff Tango: How Import Taxes Can Impact Your Computer Gear

April 22, 2025

In today’s interconnected world, the price tag on your laptop, monitor, or even that trusty keyboard often reflects a global journey of components and assembly. But what happens when governments…

Read More

From Stumptown to Secure Town: Tech Protection for Portland Small Businesses

April 22, 2025

As a small business owner in the vibrant Portland metro area, you’re likely juggling a million things. From serving your customers to managing your team and keeping a close eye…

Read More

The Perils of Public Wi-Fi: Are You Browsing Dangerously? (And How a VPN Can Be Your Digital Shield)

April 18, 2025

That free Wi-Fi at the coffee shop, the airport, or even your hotel might seem like a convenient way to stay connected. But beneath that welcoming signal lies a potential…

Read More