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
From “Oh No!” to “We Got This!”: Navigating Business Continuity & Disaster Recovery
Business Continuity vs. Disaster Recovery: A Holistic View At its core, Disaster Recovery (DR) is a subset of Business Continuity (BC). Think of BC as the overarching strategy that ensures…
Read More5 Cybersecurity Tips for Small Businesses
In today’s digital age, cyber threats are a constant concern for businesses of all sizes. Small businesses, often with limited resources, can be particularly vulnerable. A single data breach can…
Read MoreUpgrade Your Communication: Why VoIP with Ooma and PDX I.T. Services is Your Next Smart Move
In today’s fast-paced digital landscape, clear, reliable, and flexible communication is non-negotiable for both homes and businesses. If you’re still relying on traditional landlines, you might be missing out on…
Read More