Get List of Inactive Computers

Kaseya Automation Team
Kaseya Automation Team Member, Kaseya Certified CHOCOLATE MILK
edited January 2022 in Solutions

Product Name: Get List of Inactive Computers

Description : RUN THIS ONLY ON ACTIVE DIRECTORY MACHINES
This procedure will get a list of inactive machines on the active directory.

Instructions :

Download attached zip

Import via Agent Procedure Module

Run ONLY against an active directory

Comments

  • Larry Robertson
    edited December 2020

    This procedure seems to want to pull and write a file called Gather-InactiveComputers.ps1.  However, it does not appear to be part of the download.  Where can we get this file? 

  • Dhaval Brahmbhatt
    edited January 2021

    Hey Larry, 

    I also saw that so I made the script myself. 

    Here is what you need in the script since I can't upload a file here. 

    ============================   

    $DaysInactive = 90

    $time = (Get-Date).Adddays(-($DaysInactive))

    (Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -ResultPageSize 2000 -resultSetSize $null -Properties Name, OperatingSystem, SamAccountName, DistinguishedName).Name

    ===========================

    Save it as Gather-InactiveComputers.ps1 in the appropriate location on your VSA, link it to the AP and Bob's your uncle! 


  • Dhaval Brahmbhatt
    edited January 2021

    Oh, since its powershell commands, you can tinker around with it as you want. Include date and time stamps and what not. I just needed a flat list of computer names. You could also append further powershell commands and then disable those computers in AD so that if in future, some employee finds an old laptop and wants to use it, all you do is enable the computer again. If no one complains after like 6 months of you disabling the computers found by this script, go ahead and delete those objects to keep your AD clean.