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
AI-Driven Security & AI-Powered Threats: The Cybersecurity Arms Race
Artificial intelligence has become one of the most powerful forces shaping modern cybersecurity. What makes AI uniquely disruptive is its dual role: it strengthens defenses while simultaneously empowering attackers. As…
Deepfakes, Synthetic Media & Human-Centered Threats: The New Frontier of Cyber Risk
Cybersecurity threats are no longer just about malware, firewalls, or stolen passwords. Today, one of the fastest-growing and most dangerous attack vectors targets something far more human: trust. Deepfakes and…
The Evolving Face of Ransomware: Why Prevention and Resilience are Your Only Hope
Ransomware is no longer just a digital annoyance; it has matured into a sophisticated, multi-billion dollar criminal enterprise. Today’s cybercriminals are operating with unprecedented efficiency, driven by two key trends:…