The below script will disable a list of Active Directory user accounts provided in a text file, the script could easily be modified to change any other properties for the list of users. I have this script scheduled to run every night to disable a list of supplier user accounts used for remote VPN access.

Change the values forĀ  strUserList and strDomain as needed.

On Error Resume Next
 
Const ADS_SCOPE_SUBTREE = 2
Const ForReading = 1
 
strUserList = "c:\userlist.txt"
strDomain = "dc=yourdomain,dc=co,dc=uk"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strUserList, ForReading)
 
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
	arrLine = Split(strLine, ",")
	strAccount = arrLine(0)
	If LCase(strAccount) <> "samaccountname" Then	
		Set objConnection = CreateObject("ADODB.Connection")
		Set objCommand =   CreateObject("ADODB.Command")
		objConnection.Provider = "ADsDSOObject"
		objConnection.Open "Active Directory Provider"
		Set objCommand.ActiveConnection = objConnection
 
		objCommand.Properties("Page Size") = 1000
		objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
		objCommand.CommandText = "SELECT AdsPath FROM 'LDAP://" & strDomain & _
			"' WHERE objectCategory='user' AND samaccountname='" & strAccount & "'"  
 
		Set objRecordSet = objCommand.Execute
 
		objRecordSet.MoveFirst
 
		Do Until objRecordSet.EOF
			strUserPath = objRecordSet.Fields("AdsPath").Value
			Set objUser = GetObject(strUserPath)
			objUser.AccountDisabled = True
			objUser.SetInfo
			objRecordSet.MoveNext
		Loop
	End If
Loop
 
objFile.Close