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
Apple Addresses Critical Zero-Day Vulnerabilities Affecting Intel-Based Macs
Apple has addressed two critical zero-day vulnerabilities that were actively exploited by attackers to target Intel-based Macs. The flaws resided in macOS Sequoia’s JavaScriptCore (CVE-2024-44308) and WebKit (CVE-2024-44309) components. The…
Read MoreElevating Small Businesses, One Tech Solution at a Time
PDX IT Services, led by industry veteran Steve Shaff, is dedicated to rescuing small businesses from IT chaos. With over 25 years of experience working with Fortune 500 companies and…
Read MorePart 2 with our special guest Victoria Dean – Story Time with Victoria Dean
Join us for Part 2 of our Breaking Down I.T. podcast as we sit down with Victoria Dean, a seasoned IT professional from TAK Consulting. In this episode, we dive…
Read More