Link to home
Start Free TrialLog in
Avatar of azstbzimms
azstbzimms

asked on

VBscript to Disable a Computer Account in W2k3 Active Directory and Add Details to the "Description" Field

Need a VBscript that when double-clicked from an admin's desktop:

-Will ask for a computer name to be disabled

then

-Ask for a reason that it is being disabled and take that entry and place it in the description field for the corresponding computer account in Active Directory and disable the computer account.

Is this easily doable?
Avatar of Henrik Johansson
Henrik Johansson
Flag of Sweden image

This can be done by using dsquery/dsmod from adminpak.msi (\\server\admin$) in a CMD-script.
/Henrik
@ECHO OFF
 
IF "%1"=="" GOTO _help
 
:_reason
SET /P REASON=Enter reason (press ctrl-c to cancel):
IF "%REASON%"=="" GOTO _reason
 
dsquery computer -name %1|dsmod computer -disabled yes -desc %REASON%
GOTO _eof
 
:_help
ECHO. Syntax:
ECHO.   %0 computername
echo.
 
:_eof

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of azstbzimms
azstbzimms

ASKER

Perfect...Thank you!
No problem. Thanks for the grade.

Regards,

Rob.