Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Active Directory with PowerShell

You're reading from   Active Directory with PowerShell Learn to configure and manage Active Directory using PowerShell in an efficient and smart way

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher Packt
ISBN-13 9781782175995
Length 230 pages
Edition 1st Edition
Concepts
Arrow right icon
Authors (2):
Arrow left icon
YELLAPRAGADA U PADMAVATHI YELLAPRAGADA U PADMAVATHI
Author Profile Icon YELLAPRAGADA U PADMAVATHI
YELLAPRAGADA U PADMAVATHI
Pamarthi Venkata Sitaram Pamarthi Venkata Sitaram
Author Profile Icon Pamarthi Venkata Sitaram
Pamarthi Venkata Sitaram
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Let's Get Started FREE CHAPTER 2. Managing User and Computer Objects 3. Working with Active Directory Groups and Memberships 4. Configuring Group Policies 5. Managing Domains, Organizational Units, Sites, and Subnets 6. Advanced AD Operations Using PowerShell 7. Managing DFS-N and DFS-R Using PowerShell 8. Managing Active Directory DNS Using PowerShell 9. Miscellaneous Scripts and Resources for Further Learning Index

Finding inactive computers in Active Directory


A computer's inactivity is decided based on when that computer account had its password changed last time. A computer account changes its password in Active Directory every 30 days by default. So, any computer that had its password last set longer than 30 days ago, it will mean that the computer is not connected to the network for some reason. It could be either decommissioned, crashed, or made offline for troubleshooting. The following function will help you query computers older than the given number of days:

Function Find-InactiveComputers {
[CmdletBinding()]
Param(
  [int]$DaysOlderThan
)
$older = (Get-Date).AddDays(-$DaysOlderThan)
Get-ADComputer -Filter { PasswordLastSet -lt $older } | select  Name, DistinguishedName
}

Usage

Query computers that are inactive for more than 40 days using following command:

Find-InactiveComputers -DaysOlderThan 40

This displays the name and distinguished name of the computer accounts that are older than 40 days...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime