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 Voice on the Phone Isn’t Who You Think It Is: AI Scams Are Coming for Portland Small Businesses
A few years ago, “phishing email” was the scariest phrase in small business IT. Bad spelling, a sketchy link, a fake invoice from “Microsoft Support.” Most of us got pretty…
Your Cybersecurity Is Only as Strong as Your Weakest Vendor
The Nintendo TinyPulse Breach Is a Wake-Up Call for Every Business Nintendo is one of the most recognized brands on the planet. They guard their intellectual property fiercely, have weathered…
Fake IT Workers Are Showing Up at Offices — And They’re After Your Data
Cybercrime has never been more brazen. Ransomware gangs have long relied on phishing emails and malicious software to compromise businesses — but a group known as the Silent Ransom Group has taken…