Batch Scripting

Using WMIC to remove computer from domain

Using WMIC to remove computer from domain wmic computersystem where name!=null call unjoindomainorworkgroup

How to determine Computer Account Password Age (in Active Directory)

Copy and Paste this script to an empry Computer.Account.vbs file On Error Resume Next Set rs = CreateObject("ADODB.Recordset") Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") rs.Open "<LDAP://" & strDNSDomain & ">;(objectClass=computer);name,distinguishedName", "provider = ADsDSOObject" strMachineList = "" Do Until rs.EOF Set objComputer = GetObject("LDAP://" & rs.Fields("distinguishedName") & "") dtmValue = obj...

Reset Windows Computer Account using Netdom.exe

netdom resetpwd /s:<dns domainname> /ud:<NETBIOS DOMAINNAME>\<username> /pd:<password> This is an example script which you can use to automatically fix a trust with the domain when it's lost. Create a scheduled tasks to run this script every 5 minutes CALL :GO>"C:\FIX_TRUST.log" 2>&1 :GO NLTEST /SC_VERIFY:<dns domainname> | FIND /I "ERROR_ACCESS_DENIED" IF %ERRORLEVEL%==0 GOTO FIXTRUST GOTO END :FIXTRUST ECHO Running FIXTRUST Script ECHO OFF net...

Command do delete files that are older then X days

Command do delete files that are older then X days @ECHO delete log files older then 5 days forfiles /P "<PATH>" /m <partoffilename*.extention> /d -5 /C "cmd /c del @file"

Command to create a logfile with a date and time in the filename

Command to create a logfile with a date and time in the filename Set date and time formatting For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) For /f "tokens=1-2 delims=/:" %%a in ('echo %time%') do (set mytime=%%a%%b) CALL :GO>>"C:\<name>_%mydate%_%mytime%.log 2>&1 :GO