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

Tech Glitch Grounds Flights and Disrupts Services Worldwide

July 19, 2024

Common Antivirus Update Blamed for Widespread IT Outage A major tech malfunction caused travel nightmares around the globe today, impacting everything from flights to banking and healthcare. The culprit? A…

Read More

Data Breaches at Ticketmaster and CDK Technologies: What You Need to Know

July 18, 2024

Customer data security has been in the spotlight recently with two concerning incidents involving major companies: Ticketmaster and CDK Technologies. Let’s break down what happened and why it matters. Listen…

Read More

Heritage Foundation Breach Highlights Cybersecurity Concerns

July 18, 2024

The Heritage Foundation, a prominent conservative think tank, recently faced a data breach. The self-styled “Gay Furry Hackers” group, SiegedSec, claimed responsibility for the attack. Motivations and Confusion: SiegedSec cited…

Read More