Hunter I made the changes you suggested but I'm getting an error on line
13,1

Which is Set objComputer = GetObject
(adoRecordset.Fields.Item("ADSPath")

Do you see anything wrong?

'*****************************************************************
Const ForReading = 1, ForWriting = 2, ForAppending = 8

wscript.echo "The script has started"
strhost= "dhjc28l21"

'Create the output file
set fileSys = CreateObject("Scripting.FileSystemObject")
Set fileTxt = fileSys.OpenTextFile("machine_Path.txt", ForWriting, True)

fileTxt.Writeline("Computer Name" & vbTab & "DN")

'Set objDSE = GetObject("LDAP://rootDSE";) 
Set objComputer = GetObject (adoRecordset.Fields.Item("ADSPath"))

strLDAPPath = objDSE.Get("defaultNamingContext")

Set objCommand = CreateObject("ADODB.Command") 

Set objConnection = CreateObject("ADODB.Connection") 
objConnection.Provider = "ADSDSOObject"

objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection 
strBase = "<LDAP://"; & strLDAPPath & ">"

strFilter = "(&(objectClass=user)(objectCategory=computer)(name=" &
strhost & "))"
strAttributes = "name,ADsPath"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False 
objCommand.Properties("Size Limit") = 1000
Set adoRecordset = objCommand.Execute
        
While NOT adoRecordset.EOF
fileTxt.WriteLine(adoRecordset.Fields.Item("name") & vbTab &
adoRecordset.Fields.Item("ADSPath"))
 adoRecordset.MoveNext
Wend

wscript.echo "End of Script"

'****************************************************************** 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Coleman, Hunter
Sent: Friday, October 22, 2004 11:57 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

OK, modify the strFilter so that it looks like strFilter =
"(&(objectClass=user)(objectCategory=computer)(name=" & strhost & "))"

And then change your getObject line to
Set objComputer = GetObject _ 
    (adoRecordset.Fields.Item("ADSPath")

Hunter

-----Original Message-----
From: Stauffer, Christopher [mailto:[EMAIL PROTECTED]
Sent: Friday, October 22, 2004 9:45 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

Ok what I'm doing is taking the description info from a machine and
adding it to AD.

The script that I was looking for earlier I now have. (the Description
script) which was in an earlier email I sent

What I have the script doing is this

First take a machine from the text file machines.txt (one at a time)
This gets inputted to 
Strhost=      '(name from list)

Next ping the machine.
If I get a response I go to the next step. If not it goes to the next pc
in the list.
Next I check WMI and get the pc's description.
Next add the pc's description to AD

        to do this I'm inputting the following line.

*******************************************************
Strhost =               '(name from list)
StrOU=                  'a pre defined ou from a list.

        
Set objComputer = GetObject _ 
    ("LDAP://CN= "& strhost & " , " & strOU & "")

objComputer.Put "Description" , " " & strdesc & " "
objComputer.SetInfo

*****************************************************
Strhost = (name from list)
StrOU= a pre defined ou from a list.


What I want to do is replace the StrOU Pre defined list with the pc's
actual OU that is picked up just before the description is added.
This way I could do the whole domain at once instead of one OU at a
time.



Does this make more sense?

Also the script Hunter sent is great but it is giving me a list of pc's
from all of the domains (yes plural).
I needed the list from just my Child domain.
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mulnick, Al
Sent: Friday, October 22, 2004 11:18 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

Do you have a list of computer names or do you want a pop-up to ask for
it?

Once you have the computer name, do you want to specify what the
description is or do you want to pull it from the machine itself?

It matters what you want because depending on that answer you may have
to get it from the computer itself.  If you would rather just pull it
from a txt file list that includes computer name and the description,
say in CSV format, that would be pretty easy too. 

The full description of what you want to do would be helpful.  I thought
Hunter's script was what you wanted with the modification that you
wanted to pull all computer accounts and then do something with them.
I'm now unclear as to what you're after.

Al

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stauffer,
Christopher
Sent: Friday, October 22, 2004 11:12 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

Ok this worked but what I'm looking for is a script that I can feed in
the computer name (one at a time from a variable)

That way it only give me the computer I'm after. 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Coleman, Hunter
Sent: Friday, October 22, 2004 9:48 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

Chris-

The script below will pull the computers from the specified OU and dump
the computer name and path. If you want all of the computers in your
domain, edit the strLDAPPath line so that it's just strLDAPPath =
objDSE.Get("defaultNamingContext"). That cuts out having to first
generate the list of computers in the domain and then feed it to the
script.

Note that if you have a large number of computers in your domain, you'll
need to increase objCommand.Properties("Size Limit")



========================================================================
=========

Const ForReading = 1, ForWriting = 2, ForAppending = 8

wscript.echo "The script has started"



'Create the output file
set fileSys = CreateObject("Scripting.FileSystemObject")
Set fileTxt = fileSys.OpenTextFile("machinePath.txt", ForWriting, True)
fileTxt.Writeline("Computer Name" & vbTab & "DN")

Set objDSE = GetObject("LDAP://rootDSE";) strLDAPPath =
"ou=workstations,ou=itsd,ou=doa," &
objDSE.Get("defaultNamingContext")


Set objCommand = CreateObject("ADODB.Command") Set objConnection =
CreateObject("ADODB.Connection") objConnection.Provider = "ADSDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection strBase = "<LDAP://"; &
strLDAPPath & ">"
strFilter = "(&(objectClass=user)(objectCategory=computer))"
strAttributes = "name,ADsPath"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
objCommand.Properties("Size
Limit") = 1000 Set adoRecordset = objCommand.Execute
        
While NOT adoRecordset.EOF
 fileTxt.WriteLine(adoRecordset.Fields.Item("name") & vbTab &
adoRecordset.Fields.Item("ADSPath"))
 adoRecordset.MoveNext
Wend

wscript.echo "End of Script"
========================================================================
========================

-----Original Message-----
From: Stauffer, Christopher [mailto:[EMAIL PROTECTED]
Sent: Friday, October 22, 2004 6:20 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

enter a computer name and have it dump the path That way I could just
feed it all of the domain computers and have it resolve the OU.
The way I have it now you can only run one OU at a time. It would be
great to automate it even further.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Coleman, Hunter
Sent: Thursday, October 21, 2004 9:31 PM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

Did you want to enter a computer name and have it dump the path, or have
the script dump the path for all computers in a given OU? 

-----Original Message-----
From: Stauffer, Christopher [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 21, 2004 5:56 PM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

Just rename .zip 

Directions are inside

Does anybody have a script that will display a computers full OU path?

Likethis

Cn=computername,OU=blabla,DC=com



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rodney Gardiner
Sent: Thursday, October 21, 2004 7:37 PM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD

A copy of the script could come in handy if you are willing to send me a
copy.
 
Thanks

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stauffer,
Christopher
Sent: Friday, 22 October 2004 7:50 AM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] New to AD


Just wanted to thank everybody who added there two cents.
I have a working script that does exactly what my boss wanted.
 
It could be a little better but I'm not a coder.
 
If anybody wants a copy let me know.

  _____  

From: Stauffer, Christopher
Sent: Thursday, October 21, 2004 9:02 AM
To: '[EMAIL PROTECTED]'
Subject: New to AD


I'm new to AD. Our network is Finally migrating to Active Directory
2000.
(yeah I know 2003 is better but is isn't our call)

anyway during the migration when joining new Windows XP or Windows 2000
computers to the Windows 2000 domain, the computer name appears in
Active Directory but the computer description that is on the computer
does not show up in AD. Why does this happen? In network places I can
see the computer description, but in AD it is just blank unless I
manually add it. Is there a way to pull the computer description from
the local box into AD when the computer joins the domain

 

I was told this by guys on another news group

Its two separate fields.
 
When you give a description to a computer object in AD users and
computers, you are applying the description to the object, and not the
computer itself.
 
When you logon to a workstation and add a description to it, you are
adding the description to the machine itself, and not the object in AD.
That is why you see the different behaviors. Unfortunately the 2 fields
aren't tied together.
 
As for how to fix it, I think if a script ran that read the description
from the local machine, and then connected to AD to update the computer
object with the same name, you would be good to go. 
 
So i guess my question is does anybody have a script that can do this.
 

Thanks, 
 CHRIS STAUFFER   <><    
   Distributive Systems Specialist II
 Bureau of Information Technology
 '  :   1(717)783-9049   ext 244
 / :  [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  




 
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to