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

Cybersecurity Nightmare: Cisco Data Breach and the Implications for Businesses

October 25, 2024

A threat actor known as IntelBroker has claimed to have breached Cisco’s systems on October 6th, 2024, stealing a vast amount of sensitive data. The stolen data allegedly includes source…

Read More

How PDX IT Services Can Protect Your Business from Data Breaches

October 23, 2024

Given the recent data breach at Globe Life and the increasing threat of cyberattacks, businesses must prioritize robust cybersecurity measures. PDX IT Services can offer a comprehensive suite of solutions…

Read More

Data Breach at Globe Life: A Growing Threat

October 23, 2024

Insurance Giant Faces Extortion and Data Exposure In a significant cybersecurity breach, Globe Life, a major life and health insurance provider, has confirmed that it is being extorted by a…

Read More