This VBScript allows you to output all the attribute properties for a computer object into a text file. This would be great for creating a report for a single computer with everything that AD knows about that computer.
‘Query a specific computer object
CName = “ComputerNameHere”
‘Query a specific Organizational Unit
AD_Query = “OU=Computers,DC=DomainNameHere,DC=com”
DC = “DomainControllerHere”
”””””””””””””””””””””””””””””””””’
Dim objRootDSE, objCn, objCmd, objRes
Dim strRoot, strfilter, strAttributes, strScope, strTmp, strDescription
strRoot = “CN=” & CName & “,” & AD_Query
strfilter = “(&(objectCategory=Computer)(objectClass=Computer))”
strAttributes = “sAMAccountName,description,cn,operatingsystem,lastlogoff,dscorepropagationdata,name,distinguishedname,usncreated,objectguid,iscriticalsystemobject,serviceprincipalname,whenchanged,localpolicyflags,accountexpires,primarygroupid,badpwdcount,objectclass,instancetype,objectcategory,whencreated,lastlogon,useraccountcontrol,samaccountname,operatingsystemversion,samaccounttype,adspath,serverreferencebl,dnshostname,pwdlastset,ridsetreferences,logoncount,codepage,usnchanged,badpasswordtime,objectsid”
strScope = “subtree”
Set objCn = CreateObject(“ADODB.Connection”)
Set objCmd = CreateObject(“ADODB.Command”)
objCn.Provider = “ADsDSOObject”
objCn.Open “Active Directory Provider”
objCmd.ActiveConnection = objCn
objCmd.Properties(“Page Size”) = 1000
objCmd.commandtext = “<LDAP://” & DC & “/” & strRoot & “>;” & strFilter & “;” & _
strAttributes & “;” & strScope
Set objRes = objCmd.Execute
on error resume next
‘WScript.Echo “Operating System: ” & objRes.Fields(“operatingsystem”)
Set objShell = CreateObject(“WScript.Shell”)
objShell.Run “cmd /c echo Computer Name: ” & CName & “>record.txt”,0,true
objShell.Run “cmd /c echo AD OU: ” & AD_Query & “>>record.txt”,0,true
objShell.Run “cmd /c echo Operating System: ” & objRes.Fields(“operatingsystem”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo Country Code: ” & objRes.Fields(“countrycode”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo CN: ” & objRes.Fields(“cn”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo Last Logoff: ” & objRes.Fields(“lastlogoff”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo dscorepropagationdata: ” & objRes.Fields(“dscorepropagationdata”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo usncreated: ” & objRes.Fields(“usncreated”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo objectguid: ” & objRes.Fields(“objectguid”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo iscriticalsystemobject: ” & objRes.Fields(“iscriticalsystemobject”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo serviceprincipalname: ” & objRes.Fields(“serviceprincipalname”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo whenchanged: ” & objRes.Fields(“whenchanged”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo localpolicyflags: ” & objRes.Fields(“localpolicyflags”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo accountexpires: ” & objRes.Fields(“accountexpires”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo primarygroupid: ” & objRes.Fields(“primarygroupid”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo badpwdcount: ” & objRes.Fields(“badpwdcount”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo objectclass: ” & objRes.Fields(“objectclass”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo instancetype: ” & objRes.Fields(“instancetype”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo objectcategory: ” & objRes.Fields(“objectcategory”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo whencreated: ” & objRes.Fields(“whencreated”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo lastlogon: ” & objRes.Fields(“lastlogon”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo useraccountcontrol: ” & objRes.Fields(“useraccountcontrol”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo samaccountname: ” & objRes.Fields(“samaccountname”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo operatingsystemversion: ” & objRes.Fields(“operatingsystemversion”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo samaccounttype: ” & objRes.Fields(“samaccounttype”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo adspath: ” & objRes.Fields(“adspath”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo serverreferencebl: ” & objRes.Fields(“serverreferencebl”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo dnshostname: ” & objRes.Fields(“dnshostname”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo pwdlastset: ” & objRes.Fields(“pwdlastset”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo ridsetreferences: ” & objRes.Fields(“ridsetreferences”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo logoncount: ” & objRes.Fields(“logoncount”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo codepage: ” & objRes.Fields(“codepage”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo name: ” & objRes.Fields(“name”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo usnchanged: ” & objRes.Fields(“usnchanged”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo badpasswordtime: ” & objRes.Fields(“badpasswordtime”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo objectsid: ” & objRes.Fields(“objectsid”) & “>>record.txt”,0,true
objShell.Run “cmd /c echo distinguishedname: ” & objRes.Fields(“distinguishedname”) & “>>record.txt”,0,true
objRes.close
ObjCn.close