Auslesen des Attributes terminalserverprofilepath mittels VBS
über den Aufruf cscrip dateiname.vbs > datei.txt wird die Ausgabe in eine Textdatei umgelenkt. Nun kann man diese manipulieren und wieder in das Active Directory schreiben.
In diesem Skript geht es um das Auslesen des Attribut “terminalserverprofilepath”
Option Explicit
Dim objCommand, objConnection, strBase, strFilter, strAttributes, objUser
Dim strQuery, objRecordset, strdistinguishedName, strTSPath, strCN
Set objCommand = CreateObject(“ADODB.Command”)
Set objConnection = CreateObject(“ADODB.Connection”)
objConnection.Provider = “ADsDSOObject”
objConnection.Open “Active Directory Provider”
objCommand.ActiveConnection = objConnection
‘…set the base DN
strBase = “<LDAP://DC=contoso,DC=com>”
strFilter = “(&(objectCategory=person)(objectClass=user))”
strAttributes = “sAMAccountName,cn,distinguishedName”
strQuery = strBase & “;” & strFilter & “;” & strAttributes & “;subtree”
objCommand.CommandText = strQuery
objCommand.Properties(“Page Size”) = 100
objCommand.Properties(“Timeout”) = 30
objCommand.Properties(“Cache Results”) = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strdistinguishedName = objRecordSet.Fields(“distinguishedName”).Value
Set objUser = GetObject(“LDAP://” & strdistinguishedName)
On error resume next
Wscript.Echo objUser.sAMAccountName & “,” & objUser.TerminalServicesProfilePath
objRecordSet.MoveNext
Loop
objConnection.Close