PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?

Réponse
 
LinkBack Outils de la discussion
Vieux 07/10/2008, 21h31   #1
Spin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?

Gurus,

Is there a script which will report which OU a server resides in, given an
Active Directory 2003 domain?

--
Spin


  Réponse avec citation
Vieux 07/10/2008, 21h44   #2
Jorge Silva
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?

Hi
Doing a simple find using ADUC will show you where the server is.
--
I hope that the information above s you.
Have a Nice day.

Jorge Silva
MCSE, MVP Directory Services

Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.


"Spin" <Spin@invalid.com> wrote in message
news:6l1rooFa4fsnU1@mid.individual.net...
> Gurus,
>
> Is there a script which will report which OU a server resides in, given an
> Active Directory 2003 domain?
>
> --
> Spin
>


  Réponse avec citation
Vieux 07/10/2008, 22h13   #3
Spin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?

"Jorge Silva" <jorgesilva_pt@hotmail.com> wrote in message
news:0E2E0AEB-3A25-4CC2-877B-FE7BE4F7036C@microsoft.com...
> Hi
> Doing a simple find using ADUC will show you where the server is.
> --
> I hope that the information above s you.
> Have a Nice day.
>
> Jorge Silva
> MCSE, MVP Directory Services


I need a report dumping the OU membership of all servers, in a spreadsheet
sorted by server name alphabetically.


  Réponse avec citation
Vieux 07/10/2008, 22h40   #4
Adrian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Is there a script which will report which OU a server resides in,

You can use [ DSQUERY Computer -limit 0 ] put that into excel and modify that
data to suit your needs.

"Spin" wrote:

> Gurus,
>
> Is there a script which will report which OU a server resides in, given an
> Active Directory 2003 domain?
>
> --
> Spin
>
>
>

  Réponse avec citation
Vieux 08/10/2008, 00h47   #5
John Policelli [MVP - DS]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Is there a script which will report which OU a server resides

I find ADFind.exe to be more efficient and produce better output.

If you use the following, you will get a list of the DN of each computer
object outputted to CSV format:
adfind -b dc=domain,dc=com -f "objectcategory=computer" -dn -csv
-nocsvheader >Results.txt

If you are looking for computers in a specific OU, called Servers for
example, then the following will work too:
adfind -b dc=domain,dc=com -f "objectcategory=computer" -incldn Servers -dn
>Results.txt



--
John Policelli

Blog: http://johnpolicelli.wordpress.com

This posting is provided "AS IS" with no warranties and confers no rights!
Always test before proceeding.


"Adrian" wrote:

> You can use [ DSQUERY Computer -limit 0 ] put that into excel and modify that
> data to suit your needs.
>
> "Spin" wrote:
>
> > Gurus,
> >
> > Is there a script which will report which OU a server resides in, given an
> > Active Directory 2003 domain?
> >
> > --
> > Spin
> >
> >
> >

  Réponse avec citation
Vieux 08/10/2008, 04h09   #6
Al Dunbar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?


"Spin" <Spin@invalid.com> wrote in message
news:6l1rooFa4fsnU1@mid.individual.net...
> Gurus,
>
> Is there a script which will report which OU a server resides in, given an
> Active Directory 2003 domain?
>


type this command:

dsquery user -samid username

/Al


  Réponse avec citation
Vieux 08/10/2008, 04h55   #7
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?


"Spin" <Spin@invalid.com> wrote in message
news:6l1u7fFa3r1tU1@mid.individual.net...
> "Jorge Silva" <jorgesilva_pt@hotmail.com> wrote in message
> news:0E2E0AEB-3A25-4CC2-877B-FE7BE4F7036C@microsoft.com...
>> Hi
>> Doing a simple find using ADUC will show you where the server is.
>> --
>> I hope that the information above s you.
>> Have a Nice day.
>>
>> Jorge Silva
>> MCSE, MVP Directory Services

>
> I need a report dumping the OU membership of all servers, in a spreadsheet
> sorted by server name alphabetically.
>
>


I have an example VBScript program to document all servers in the domain
linked here:

http://www.rlmueller.net/Enumerate%20Servers.htm

The program outputs the Distinguished Name of each machine, which indicates
the OU/container the computer resides in. If you run the script at a command
prompt with the cscript host, the output can be redirected to a text file.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


  Réponse avec citation
Vieux 08/10/2008, 05h43   #8
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?


"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:uvOkoFPKJHA.5336@TK2MSFTNGP05.phx.gbl...
>
> "Spin" <Spin@invalid.com> wrote in message
> news:6l1u7fFa3r1tU1@mid.individual.net...
>> "Jorge Silva" <jorgesilva_pt@hotmail.com> wrote in message
>> news:0E2E0AEB-3A25-4CC2-877B-FE7BE4F7036C@microsoft.com...
>>> Hi
>>> Doing a simple find using ADUC will show you where the server is.
>>> --
>>> I hope that the information above s you.
>>> Have a Nice day.
>>>
>>> Jorge Silva
>>> MCSE, MVP Directory Services

>>
>> I need a report dumping the OU membership of all servers, in a
>> spreadsheet sorted by server name alphabetically.
>>
>>

>
> I have an example VBScript program to document all servers in the domain
> linked here:
>
> http://www.rlmueller.net/Enumerate%20Servers.htm
>
> The program outputs the Distinguished Name of each machine, which
> indicates the OU/container the computer resides in. If you run the script
> at a command prompt with the cscript host, the output can be redirected to
> a text file.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>


More code is required to sort the server names and write the output to an
Excel spreadsheet. You can use a disconnected recordset to sort the names.
The following VBScript program worked in my domain (Excel must be installed
on the client where this runs):
==========
Option Explicit

Dim objRootDSE, strDNSDomain, adoConnection, adoCommand, strQuery
Dim adoRecordset, strComputerDN, strOS
Dim adoResults, strOU, strName, intIndex
Dim objExcel, objSheet, intRow, strExcelPath

Const adVarChar = 200
Const MaxCharacters = 255

' Specify spreadsheet.
strExcelPath = "c:\Scripts\Servers.xls"

' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

' Use ADO to search Active Directory for all computers.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

strQuery = "<LDAP://" & strDNSDomain _
& ">;(objectCategory=computer);" _
& "sAMAccountName,distinguishedName,operatingSystem; subtree"

adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

Set adoRecordset = adoCommand.Execute

Set adoResults = CreateObject("ADODB.Recordset")
adoResults.Fields.Append "Name", adVarChar, MaxCharacters
adoResults.Fields.Append "OU", adVarChar, MaxCharacters
adoResults.Open

' Enumerate computer objects with server operating systems.
Do Until adoRecordset.EOF
strOS = adoRecordset.Fields("operatingSystem").Value
If (InStr(UCase(strOS), "SERVER") > 0) Then
strComputerDN = adoRecordset.Fields("distinguishedName").Value
strName = adoRecordset.Fields("sAMAccountName").Value
' Remove trailing "$".
strName = Left(strName, Len(strName) - 1)
intIndex = InStr(LCase(strComputerDN), ",ou=")
If (intIndex = 0) Then
intIndex = InStr(LCase(strComputerDN), ",cn=")
End If
If (intIndex = 0) Then
intIndex = InStr(strComputerDN, ",")
End If
strOU = Mid(strComputerDN, intIndex + 1)
strOU = Left(strOU, InStr(LCase(strOU), ",dc=") - 1)
adoResults.AddNew
adoResults.Fields("Name").Value = strName
adoResults.Fields("OU").Value = strOU
adoResults.Update
End If
adoRecordset.MoveNext
Loop
adoRecordset.Close

adoResults.Sort = "Name"
adoResults.MoveFirst

Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

intRow = 2
objSheet.Cells(1, 1).Value = "Server Name"
objSheet.Cells(1, 2).Value = "OU/Container"
Do Until adoResults.EOF
objSheet.Cells(intRow, 1).Value = adoResults.Fields("Name").Value
objSheet.Cells(intRow, 2).Value = adoResults.Fields("OU").Value
intRow = intRow + 1
adoResults.MoveNext
Loop
adoResults.Close

objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close

' Clean up.
objExcel.Application.Quit
adoConnection.Close

Wscript.Echo "Done"

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


  Réponse avec citation
Vieux 08/10/2008, 06h31   #9
Al Dunbar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is there a script which will report which OU a server resides in, given an Active Directory 2003 domain?


"Al Dunbar" <AlanDrub@hotmail.com.nospaam> wrote in message
news:O9kHRzOKJHA.6004@TK2MSFTNGP06.phx.gbl...
>
> "Spin" <Spin@invalid.com> wrote in message
> news:6l1rooFa4fsnU1@mid.individual.net...
>> Gurus,
>>
>> Is there a script which will report which OU a server resides in, given
>> an Active Directory 2003 domain?
>>

>
> type this command:
>
> dsquery user -samid username
>
> /Al


aargh, my apologies - I responded before I noticed you were looking for
computers...

/Al


  Réponse avec citation
Vieux 08/10/2008, 13h37   #10
James Yeomans BSc, MCSE
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Is there a script which will report which OU a server resides in,

On the dc from a command prompt:

dsquery computer -name "computername"

Replace "Computername" as appropriate. This should give you the DN of the
server.
--
James Yeomans, BSc, MCSE


"Spin" wrote:

> Gurus,
>
> Is there a script which will report which OU a server resides in, given an
> Active Directory 2003 domain?
>
> --
> Spin
>
>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h27.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,22218 seconds with 18 queries