Discussion Locked

Verify remote pc is on domain via script

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I work in a large office that has several "temp" workstations. The problem is out AD policy is set to remove a workstation that hasn't been logged in at least once every 30 days. Aside from loging into every machine at least once every 30 days I would like to run some type of batch file or script that will do 2 things.

1) Ensure the machine is up and running (like a ping)
2) Ensure that the machine is still a member of the domain and can be logged into.

Any and all suggestions are appreciated.

8 replies

by bfilmfan

Script to verify a computer is responding to pings:

:====8<-----[ FileName.cmd ]-----
@ECHO OFF
TITLE Computer Object Check

REM -----------------------------------
REM

SET MachineList=names.txt
SET ResultsFile=results.txt

REM
REM -----------------------------------

CLS
ECHO.
IF NOT EXIST "%MachineList%" (
ECHO Cannot locate Machine List: %MachineList%
PAUSE>NUL
GOTO :EOF
)

ECHO Processing all machine names in %MachineList% . . .
ECHO.

FOR /f "tokens=*" %%M in (%MachineList%) do CALL :CHECK "%%M"

GOTO :EOF

:CHECK
SET Machine=%~1
SET Machine=%Machine: =%

PING -w 1000 %Machine%>NUL
IF %ERRORLEVEL% NEQ 0 ECHO %Machine% did not respond at %Time%>>%ResultsFile%

EXIT /B

:EOF
:====8<-----[ FileName.cmd ]-----

by capabel

This is a great ping script, but I also and more importantly need to verify that the computer is still a member of the domain since computers that have been dropped will still reply to pings.

by capabel

Thats a great ping script, but how exactly will it ensure the computer being pinged is still a member of the domain? That's my main concearn, because even computer that have been dropped will reply to pings.

by p.j.hutchison

You can use the dsquery command and check that the computer name is still shown in the domain.

You can use dsmodify to re-enable the computer account.

by p.j.hutchison

Example,
dsquery computer -name %Machine% -disabled

Unfortunately it doesn`t seem to return error levels but it will display the dn of the computer if its disabled (not in the domain).

This discussion is closed to new replies.