![]() |
Rightio people's, I have a problem.
My scripting knowledge is very limited (And I intend to keep it that way) however I need to add to a script at work to fix a problem we have. Long story short, we use Microsoft SMS to roll out our SOE images and once the OS has been built, we run a script which does all the configuration. A little while ago we found that some computers were being built and added to the domain with the name “Telstra” and a random number sequence instead of “NML” followed by the Dell service tag, after some problem analysis we found that a certain part of the script (The part that renames the machine and rejoins the domain, was failing if the computer already exists in AD, seeing as how netdom cannot remove objects from AD I need to add something to the script before that step which searches AD for the machine and deletes it if something is found. So basically, my script can find the Dell Service tag (called “sAssetTag” in the script) and I can search through AD and delete an object based on the location details that are found by the search, however I can’t figure out how to tell the search to find a computer object with the name ‘sAssetTag’, if I specifically state what the name is I am looking for, such as “8DFGN1S” the whole thing works, but I want the search to find a computer in AD based on the result of “sAssetTag”. Effectively making it a one script fits all sort of thing. Hope that explains it…. Anyways, below is the script I am using: I’m sure it’s not the perfect script, and I can probably take some things out and shorten it, however it (sort of) works and I don’t know enough about scripting to make it more efficient! Quote:
I removed the Domain name intentionally… And don’t worry about the “cool” and “not cool” parts [img]tongue.gif[/img] That’s just to tell me what part it’s getting to! Any help would be great! [ 06-26-2007, 03:33 AM: Message edited by: Hivetyrant ] |
Since you're on the inside of a string (objCommand.CommandText takes a string) you need to concatenate the computer name inside it, so something like:
Quote:
|
Yeah, that was one of the first things I tried, but the script fails on line 32:
Quote:
Appreciate the help though [img]smile.gif[/img] |
Phew, problem solved....
It was actually quite simple [img]tongue.gif[/img] Dplax, you pretty much had it, but I needed to put single quotes outside the double quotes [img]smile.gif[/img] Thanks for your help! |
You're welcome!
|
Mate you should be more worried about this VB script problem Hives [img]graemlins/cheers.gif[/img]
The alcohol content of Victoria Bitter beer is to be reduced by 0.1 percent as part of brewer Foster's plan to save millions of dollars. Foster's is also set to increase the wholesale price of all its packaged beers — including VB, Carlton, Crown Lager and Pure Blonde — by two percent next month. The VB alcohol content will drop from 4.9 percent to 4.8 percent, which according to experts is enough to save Foster's $20 million in annual beer tax. Story ninemsn Wednesday July 4 |
<font face="Verdana" size="3" color="#009999">quotes are so annoying.</font>
[ 07-04-2007, 12:11 PM: Message edited by: pritchke ] |
Quote:
Good thing I don't drink VB or Carlton! (XXXX Gold man here :D ) |
All times are GMT -4. The time now is 02:33 PM. |
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved