Any suggestions on how to clean up/optimize the following script?
'---INSTRUCTIONS:---------------------------------------------------------------------
'
' 1. Obtain list of computers from AD (IP address will work also)
' 2. Copy list of computers into a text file named "computers.txt"
'
'...
I found a work around...
FUNCTION FindInfo(strComputer)
' Continue with script if error occures.
ON ERROR RESUME NEXT
SET objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
IF objWMIservice IS NOTHING THEN
'WRITE_CSV_LINE strComputer & ",Error: " & err.number & "...
OK, I have three seperate functions that I would like to combine into one. However, I need to find out the most effective way of using a Function to output three different string vaules.
For example, I have a function to find a MAC address, IP address and Dell Serial Number. How can these be...
I must be half asleep - I can't for the life of me figure out why the code is throwing an error. Please help.
SET objFSO = CreateObject("Scripting.fileSystemObject")
SET objFileTEXT = objFSO.OpenTextFile("hosts.txt",2,TRUE)
DO UNTIL objFileTEXT.AtEndOfStream
strComputer =...
Well, depending on what exactly you are trying to do...you may want to do something similar to below:
strInput = Inputbox("Enter text")
DO
SearchFiles(strInput)
LOOP
FUNCTION SearchFiles(strInput)
Your code here...strInput is for file to be searched.
END FUNCTION
Or if you are...
You are awesome...thanks a million.
I made a slight variation to the provided script to get exact information versus having the identifying prefixes. This way - I can compare strings.
strInformation = "john.key ; MAC: 00:18:8B:D6:29:B6 ; IP: 192.168.1.1 ; SN: ####### ; US ARMY ; SPC John Key"...
Whom it may concern: I am trying to find the formula for finding specific sections in a string.
My string format:
<USER> ; <MAC> ; <IP> ; <SN> ; <OFFICE> ; <ADMIN>
Example:
john.key ; MAC: 00:18:8B:D6:29:B6 ; IP: 192.168.1.1 ; SN: ####### ; US ARMY ; SPC John Key
What would be the formula to...
OK, this post is in connection with another post:
http://www.tek-tips.com/viewthread.cfm?qid=1515298&page=1
Let's say I have three specific computer names. And on those three specific computers, I want to change the description field in Active Directory.
What would be the vbscript code for...
Whom it may concern: I am working on a script that reads a text file containing computer names on each. And for each computer in the given text file, the script will find the MAC Address, IP address, Serial Number for that computer.
Now my problem is this issue. I want to then take that read...
Interesting question...
This link may assist in what you are trying to do.
http://forums.teamphoenixrising.net/showthread.php?t=34213
From above link - Posted by Damski:
Dim gfx, colours, horiz, vert
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &...
Thanks tsuji - it worked like a charm.
Final product:
OPTION EXPLICIT
DIM objFSO, objFile, objRootDSE, objShell, objDate, objTargetOU, objComputer, objRootLDAP, objTest
DIM strFilePath, strDNSDomain, strFilter, strQuery, strComputerDN, strTargetOU, strScriptName, strParentFolder...
ALL,
This portion of code is not working for me...why?
adoRecordset.Fields("description").Value
I am trying to extract the "Description" field of computer objects out of Active Directory (AD) utilizing ADO language.
I keep getting an
Line: 94
Char: 5
error: "Item cannot be found in the...
Also...you may want to remove the extra "&" sign right before and after text.
Call WshShell.Run("cmd.exe /c C:\robocopy.exe """ & spath & """ """ & dpath & "-.txt"" " & s0)
V/r,
SPC Key
United States Army
Also to add for future refference.
As far as I know if you are feeding a variable into a command, you need to initlize the variable first prior to the command.
BAD EXAMPLE:
wscript.echo strText
strText = "What I want to echo!"
RESULT WILL BE: "" < A blank echo box.
GOOD EXAMPLE:
strText =...
I haven't messed with Robocopy yet.
However, I suggest taking your command and feeding it into a wscript.echo prior to the Call WshShell.RUN line...and just double check the syntax is the way you want it.
Try:
wscript.echo "cmd.exe /c C:\robocopy.exe " & spath & " " & dpath & "-" & ".txt" &...
Good pointa.
You are both right, I could use an array to fill in the computer names (a self contained list); however, I think option two would be more efficient as it will require less typing.
Thanks for the input guys...really appericate it.
V/r,
SPC Key
United States Army
OK, so I tested the code on my own system. I have user level access rights (when not in admin mode) and the code worked like a charm - no error.
So...
I looked up the error code by going to Google and typing in the error number. The error number seems to be related to permissions.
Maybe try...
Here would be my way of querying AD for computer names...What is your way?
OPTION EXPLICIT
DIM objOU, objComputer, objRootDSE, objLastLogon
DIM strContainer, strDNSDomain
DIM intLastLogonTime, intGuyTime
strContainer = "OU=COMPUTERS,"
SET objRootDSE = GetObject("LDAP://RootDSE")...
So, thinking out loud here. I want to know if there is a way to contain a list within a script running.
For example, I have a script that changes an admin password on all systems in my OU based on a list of computer names. The VBScript changes the password on each machine grabing the machine...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.