|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VBScript HelpHow can I have the output come out on a text file. Thanks D On Error Resume Next Const ADS_SCOPE_SUBTREE = 2 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://dc=lgihome,dc=com' WHERE objectCategory='user'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF Set objUser = GetObject(objRecordSet.Fields("AdsPath").Value) If objUser.AccountExpirationDate = "1/1/1970" Or Err.Number = -2147467259 Then Wscript.Echo objUser.Name End If objRecordSet.MoveNext Loop Lookup the FileSystemObject
As an FYI, this should have been posted to; microsoft.public.scripting.vbscript .... and not the VB newsgroup ;o) Show quoteHide quote "Diogenes Dilone" <Diogenes Dil***@discussions.microsoft.com> wrote in message news:A6A985E4-EFA1-4EC4-905D-E51224C1A7B9@microsoft.com... > Folks, > > How can I have the output come out on a text file. > > Thanks > D > > > > On Error Resume Next > > Const ADS_SCOPE_SUBTREE = 2 > > 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://dc=lgihome,dc=com' WHERE > objectCategory='user'" > Set objRecordSet = objCommand.Execute > > objRecordSet.MoveFirst > Do Until objRecordSet.EOF > Set objUser = GetObject(objRecordSet.Fields("AdsPath").Value) > > If objUser.AccountExpirationDate = "1/1/1970" Or Err.Number = > -2147467259 Then > Wscript.Echo objUser.Name > End If > > objRecordSet.MoveNext > Loop > > > You need to use the FileSystemObject to write out data using vbscript. This
is the wrong group for that though. Try these: microsoft.public.scripting.wsh microsoft.public.scripting.vbscript HTH Matt Show quoteHide quote "Diogenes Dilone" <Diogenes Dil***@discussions.microsoft.com> wrote in message news:A6A985E4-EFA1-4EC4-905D-E51224C1A7B9@microsoft.com... > Folks, > > How can I have the output come out on a text file. > > Thanks > D > > > > On Error Resume Next > > Const ADS_SCOPE_SUBTREE = 2 > > 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://dc=lgihome,dc=com' WHERE > objectCategory='user'" > Set objRecordSet = objCommand.Execute > > objRecordSet.MoveFirst > Do Until objRecordSet.EOF > Set objUser = GetObject(objRecordSet.Fields("AdsPath").Value) > > If objUser.AccountExpirationDate = "1/1/1970" Or Err.Number = > -2147467259 Then > Wscript.Echo objUser.Name > End If > > objRecordSet.MoveNext > Loop > > >
Personal function library
Normalizing data for quick extraction - ideas? Question about thread safety... Multiple exe instances by version Winsock API callback events Autosizing ListView columns Properties Dialog box GONE MISSING Minimised Application Not Restoring or Maximising outlook-like application Should I learn this? |
|||||||||||||||||||||||