Exports "Members of" to "Notes" in AD

Hi Experts,

Could i get help for exporting content of "Members of"(screenshot 1) from AD user to "Notes"(screenshot 2) in AD.

Need VB script or batch file to perform this, where script should pull the user names from the notepad.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sushil SonawaneCommented:
You can achieve this through AD manager plus provide by manageengine. It is free for 30 days trail version.

For info and download refer below link :

Hi, this VBScript should work for you.  It will read users.txt for samAccountName's, and write the memberOf values to the info attribute (the Notes field).  It writes a log file to users_processed.csv as well.



strInputFile = "Users.txt"
strOutputfile = "Users_Processed.csv"

If Right(LCase(WScript.FullName), 11) = "wscript.exe" Then
	Set objShell = CreateObject("WScript.Shell")
	objShell.Run "cscript """ & WScript.ScriptFullName & """", 1, False
	Set objShell = Nothing
End If

Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1

Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

 ' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")

strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"

strDetails = """Login Name"",""Old Notes"",""New Notes"""

While Not objInputFile.AtEndOfStream
	strUser = objInputFile.ReadLine
	WScript.Echo "Processing " & strUser
	strFilter = "(&(objectCategory=person)(objectClass=user)(samAccountName=" & strUser & "))"
	' Comma delimited list of attribute values to retrieve.
	strAttributes = "cn,ADsPath"
	' Construct the LDAP syntax query.
	strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
	adoCommand.CommandText = strQuery
	adoCommand.Properties("Page Size") = 100
	adoCommand.Properties("Timeout") = 30
	adoCommand.Properties("Cache Results") = False
	' Run the query.
	Set adoRecordset = adoCommand.Execute
	' Enumerate the resulting recordset.
	Do Until adoRecordset.EOF
	    ' Retrieve values and display.
		strUserName = Replace(adoRecordset.Fields("cn").Value, "CN=", "")
		'WScript.Echo "Processing " & strUser
		Set objUser = Nothing
		Set objUser = GetObject(adoRecordset.Fields("ADsPath").Value)
		strOldNotes = objUser.Info
		If TypeName(objUser.memberof) = "Empty" Then
			strMemberOf = ""
		ElseIf TypeName(objUser.memberof) = "String" Then
			strMemberOf = objUser.memberof
			strMemberOf = Join(objUser.memberof, vbCrLf)
		End If
		If strMemberOf = "" Then
			objUser.PutEx ADS_PROPERTY_CLEAR, "info", 0
			objUser.Info = strMemberOf
		End If
		strNewNotes = objUser.Info
		strDetails = strDetails & VbCrLf & """" & strUserName & """,""" & strOldNotes & """,""" & strNewNotes & """"
	    ' Move to the next record in the recordset.
	' Clean up.
	Set adoRecordset = Nothing


Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True)
objOutputFile.Write strDetails
Set objOutputFile = Nothing

WScript.Echo "Done"
MsgBox "Done"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rajkiggalAuthor Commented:
Thank you Rob and Larry.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.