david-remy
(David Remy)
1
Description
This script uses dsquery to find all disabled users and computers as well as computer accounts that have not been modified in x weeks. This can be targeted at the root of AD or an OU and will open up a text file when it is done showing its findings.
Source Code
:::::::::::: How to use this script file ::::::::::::
:: rootOU is the DN for your site ie. OU=ComputerOU,DC=ad,DC=company,DC=com
:: inactiveTime is the number of weeks that a computer can be inactive before being show in this list
:: No other edits need to be done to this file
@echo off
cls
:::::::::::: Your Settings Here ::::::::::::
set rootOU=DC=ad,DC=company,DC=com
set inactiveTime=52
:::::::::::: Do not edit below this line ::::::::::::
set file=%temp%\info.txt
echo Computers that have been inactive for greater then %inactiveTime% weeks: >%file%
dsquery computer -inactive %inactiveTime% -limit 0 %rootOU% >>%file%
echo.>>%file%
echo.>>%file%
echo.>>%file%
echo Computers that are disabled:>>%file%
dsquery computer -disabled %rootOU%>>%file%
echo.>>%file%
echo.>>%file%
echo.>>%file%
::echo Users that are disabled:>>%file%
::dsquery user %rootOU% -disabled -limit 1000 -o samid>>%file%
start "" "%file%"
3 Spice ups
Good, because works! Everybody can download because it’s very useful.