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
Phishing Scams: The Sneaky Threat Lurking in Portland’s Small Businesses – How PDX IT Services Can Help
In the bustling small business landscape of Portland, Oregon, every entrepreneur is focused on growth, innovation, and serving their community. But lurking in the shadows, a persistent and increasingly sophisticated…
Read MoreFrom “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 More