Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run a script 1

Status
Not open for further replies.

patrysib

Programmer
Oct 21, 2007
23
RO
what can I do to run a vb script in active directory only once, not at every logon or logoff ?
 
Set the script to put a empty .txt file on the system when it's ran. Ensure that the script checks to see if the .txt exists before starting....?

Steve.

"They have the internet on computers now!" - Homer Simpson
 
Or create a unique registry key and value that would be updated every time a new version of the script is released. When the script runs it can detect the presense/absense of the key and whether it is up to date.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
the problem is that I don`t know haw to compile and run it. thereis a comand in comnad prompt who can do that?
 
vbscript files are plain text (ASCII), they don't need to be compiled.

To run a script either double-click on it within windows (the .VBS extension should be associated with WSCRIPT.EXE) or from the commandline type "cscript.exe Your-script.vbs"

What is it you're trying to achieve anyway?

Are you trying to run a script for all your users just once? Are you trying to run a query against AD? Modify something on all worksations?
 
I am trying to export all users and computers with the passwords. I found a scrip and I don`t know if is goog or not. I tryed with csvde aden at the import gave me an error that the user exist but when I look for it, I don`t find it. anyway that is important to me are the computers from active directory
 
Code:
Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\workstations.txt",2,true)

objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://[b]DC=testdomain,DC=local[/b]' " _
        & "Where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    objTextFile.WriteLine objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop
objTextFile.Close

The section in bold you need to change to match your domain. So if your domain is called MY.COMPANY.COM it would become DC=MY,DC=COMPANY,DC=COM.

Save that as a text file with a .vbs extension - double-click it, wait a moment or 2 then open the file C:\workstations.txt. It'll have a list of all workstations on your domain. Getting the list of users is just as easy.

If you're uncomfortable with scripting/vbscript get familiar with the DSQUERY and DSGET commands to list all users and/or computer.

Don't think there's a tool for the passwords though. Not exactly a good idea from a privacy standpoint.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top