Thanks much I really appreciate your help....!

Thanks again,

Jitendra Kalyankar

On 10/24/05, AD <[EMAIL PROTECTED]> wrote:
>
>
> Assuming file containing computer names is Computers.txt located in the same
> folder as vbs. This creates an outputfile called "Computers – Results.txt".
> You can add any attributes to your outputfile as needed.
>
>
>
> ' Start of Script
>
> Option Explicit
>
>
>
> ' Objects
>
> Dim oFS
>
> Dim oInputFile
>
> Dim oOutputFile
>
> Dim rootDSE
>
> Dim objConnection
>
> Dim objCommand
>
> Dim objRecordSet
>
> Dim rsComputers
>
>
>
> ' Arrays
>
> Dim aComputers
>
>
>
> ' Strings
>
> Dim sComputer
>
> Dim sDomain
>
> Dim sStatus
>
>
>
> Set oFS = CreateObject("Scripting.FileSystemObject")
>
> Set oInputFile = oFS.OpenTextFile("Computers.txt", 1)
>
> Set oOutputFile = oFS.CreateTextFile("Computers - Result.txt", True)
>
>
>
> ' Doing AD Stuff
>
> Set rootDSE = GetObject("LDAP://RootDSE")
>
> sDomain = rootDSE.Get("defaultNamingContext")
>
> 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("Cache Results") = True
>
>
>
> ' Reading Text File
>
> aComputers = Split(oInputFile.ReadAll, VbCrLf)
>
>
>
> ' looping every computer
>
> For Each sComputer In aComputers
>
>
>
>             objCommand.CommandText = "<LDAP://" & sDomain &
> ">;(&(objectcategory=computer)(cn=" & sComputer & "));Name,
> userAccountControl;Subtree"
>
>             Set rsComputers = objCommand.Execute
>
>
>
>             If rsComputers.EOF Then
>
>                         oOutputFile.WriteLine sComputer            & vbTab &
> "Can't find computer"
>
>             Else
>
>                         Do Until rsComputers.EOF
>
>
>
>                             If
> rsComputers.Fields("userAccountControl").value And 2 Then
>
>                                     sStatus = "Disabled"
>
>                             Else
>
>                                     sStatus = "Enabled"
>
>                             End if
>
>
>
>                             oOutputFile.WriteLine sComputer & vbTab &
> sStatus
>
>
>
>                             rsComputers.MoveNext
>
>                         Loop
>
>             End if
>
> Next
>
>
>
> ' Closing Text file
>
> oInputFile.Close
>
> oOutputFile.Close
>
> objConnection.Close
>
>
>
> ' End of Script
> ________________________________
>
>
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Kamlesh Parmar
> Sent: Friday, October 21, 2005 5:10 PM
> To: ActiveDir@mail.activedir.org
> Subject: Re: [ActiveDir] Need ADSI Scripting help.
>
>
>
>
> I was hoping someone will direct him to dsquery  :o)
>
> Assuming file containing computernames is Comps.txt
>
> put this in the batch file and keep it in same folder as comps.txt
>
> for /f %%A in (comps.txt) do (
> dsquery computer -samid %%A$ | dsget computer -samid -disabled
> )
>
> You should get the two column listing computername with YES or NO for
> disabled.
>
> -
> Kamlesh
>
>
> On 10/21/05, Jitendra Kalyankar <[EMAIL PROTECTED] > wrote:
>
> I know about the Oldcmp.exe, but the thing is the tool is really
> powerful and I don't want Jr. Sys. Admins doing something or
> deleting something that they are not suppose to. And again
> I will have to go through the security department route to use
> it. Too much hassel....
>
> Hope that explains my situation.
>
> Sincerely,
> Jitendra Kalyankar
>
> On 10/20/05, Creamer, Mark <[EMAIL PROTECTED]> wrote:
> > Before you do this, see oldcmp at www.joeware.net
> >
> > http://www.joeware.net/win/free/index.htm
> >
> >
> >
> > <mc>
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> > Jitendra Kalyankar
> > Sent: Thursday, October 20, 2005 4:14 PM
> > To: ActiveDir@mail.activedir.org
> > Subject: [ActiveDir] Need ADSI Scripting help.
> >
> > I am looking for some example script and/or help for the script I am
> writing for
> > my company. What I want to achieve is if I run the script against the
> machine
> > list which will be in the text file, it should give me the output in
> > the text file
> > saying which machine account is enabled, disabled or not found.
> >
> > I know how to manipulate the text files using fso object but I am not sure
> > what do I need to use to get the attributes of computer container in AD.
> Any
> > help in this regard is highly appreciated and valued.
> >
> > Please let me know if you need more information abou this.
> >
> > --
> > Thanks,
> > Jitendra Kalyankar
> > List info   : http://www.activedir.org/List.aspx
> > List FAQ    : http://www.activedir.org/ListFAQ.aspx
> > List archive:
> http://www.mail-archive.com/activedir%40mail.activedir.org/
> >
> > This e-mail transmission contains information that is intended to be
> confidential and privileged.  If you receive this e-mail and you are not a
> named addressee you are hereby notified that you are not authorized to read,
> print, retain, copy or disseminate this communication without the consent of
> the sender and that doing so is prohibited and may be unlawful.  Please
> reply to the message immediately by informing the sender that the message
> was misdirected.  After replying, please delete and otherwise erase it and
> any attachments from your computer system.  Your assistance in correcting
> this error is appreciated.
> > List info   : http://www.activedir.org/List.aspx
> > List FAQ    : http://www.activedir.org/ListFAQ.aspx
> > List archive:
> http://www.mail-archive.com/activedir%40mail.activedir.org/
> >
>
>
> --
> Thanks,
> Jitendra Kalyankar
> List info   : http://www.activedir.org/List.aspx
> List FAQ    : http://www.activedir.org/ListFAQ.aspx
> List archive:
> http://www.mail-archive.com/activedir%40mail.activedir.org/
>
>
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> "Fortune and Love befriend the bold"
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~


--
Thanks,
Jitendra Kalyankar

Reply via email to