Forum Search:
Forum.Brain-Cluster.com: Brain Cluster Technical Forum
Ultimate forum for Technical Discussions

Home » Microsoft » Windows Server » Active Directory » any command to do this?
any command to do this? [message #155387] Thu, 28 May 2009 14:26 Go to next message
John  is currently offline John
Messages: 1125
Registered: July 2009
Senior Member
Hi all,

I need to retrieve all windows 2003 standard and enterprise servers from
active directory 2003 in csv format. From the ADUC console, the OS shows
windows server 2003 for both OS. Is there a way to do this?

thank you!
Re: any command to do this? [message #155391 is a reply to message #155387] Thu, 28 May 2009 14:55 Go to previous messageGo to next message
florian  is currently offline florian  Germany
Messages: 484
Registered: July 2009
Senior Member
John,

John schrieb:
> I need to retrieve all windows 2003 standard and enterprise servers from
> active directory 2003 in csv format. From the ADUC console, the OS shows
> windows server 2003 for both OS. Is there a way to do this?

Not being a scripting guy at all, I don't think that for 2003 this
information (standard vs. enterprise) is stored anywhere in the
directory. Operating system: yes, service pack level/build level: yes --
not the edition. It basically is a string that gets written to the
computer account on domain join.

I'd try to give WMI scripting a try.

Cheers,
Florian
--
Microsoft MVP - Group Policy
eMail: prename [at] frickelsoft [dot] net.
blog: http://www.frickelsoft.net/blog.
Maillist (german): http://frickelsoft.net/cms/index.php?page=mailingliste
Re: any command to do this? [message #155394 is a reply to message #155391] Thu, 28 May 2009 15:10 Go to previous messageGo to next message
John  is currently offline John
Messages: 1125
Registered: July 2009
Senior Member
thank you.

Not sure how to do WMI scripting; Can you share if you have one?

"Florian Frommherz [MVP]" wrote:

> John,
>
> John schrieb:
> > I need to retrieve all windows 2003 standard and enterprise servers from
> > active directory 2003 in csv format. From the ADUC console, the OS shows
> > windows server 2003 for both OS. Is there a way to do this?
>
> Not being a scripting guy at all, I don't think that for 2003 this
> information (standard vs. enterprise) is stored anywhere in the
> directory. Operating system: yes, service pack level/build level: yes --
> not the edition. It basically is a string that gets written to the
> computer account on domain join.
>
> I'd try to give WMI scripting a try.
>
> Cheers,
> Florian
> --
> Microsoft MVP - Group Policy
> eMail: prename [at] frickelsoft [dot] net.
> blog: http://www.frickelsoft.net/blog.
> Maillist (german): http://frickelsoft.net/cms/index.php?page=mailingliste
>
Re: any command to do this? [message #155395 is a reply to message #155394] Thu, 28 May 2009 15:24 Go to previous messageGo to next message
aceman  is currently offline aceman  United States
Messages: 5816
Registered: July 2009
Senior Member
"John" <John@discussions.microsoft.com> wrote in message news:380A4083-67E5-44C6-9D82-793EB3C5A46A@microsoft.com...
> thank you.
>
> Not sure how to do WMI scripting; Can you share if you have one?

Niether am I, but the following link and main site has numerous pre-canned scripts from contributors that may work for you:
http://cwashington.netreach.net/depo/default.asp?topic=resul ts

You can also check Microsoft's Script Center for additional guidelines and snippets:
http://www.microsoft.com/technet/scriptcenter/default.mspx
http://www.microsoft.com/technet/scriptcenter/scripts/defaul t.mspx?mfr=true


--
Ace

This posting is provided "AS-IS" with no warranties or guarantees and
confers no rights.

Ace Fekay, MCSE 2003 & 2000, MCSA 2003 & 2000, MCSA Messaging, MCT
Microsoft Certified Trainer
aceman@mvps.RemoveThisPart.org

For urgent issues, you may want to contact Microsoft PSS directly. Please
check http://support.microsoft.com for regional support phone numbers.

"Efficiency is doing things right; effectiveness is doing the right things." - Peter F. Drucker
http://twitter.com/acefekay
Re: any command to do this? [message #155401 is a reply to message #155387] Thu, 28 May 2009 16:35 Go to previous messageGo to next message
Jorge Silva  is currently offline Jorge Silva
Messages: 398
Registered: July 2009
Senior Member
Hi
Get scriptomatic from Scriptcenter, that allows you to easily create a
script to run agains all your servers and get the info the you need.

For simple WMI get check from cmd
wmic os get caption, csdversion

--
I hope that the information above helps you.
Have a Nice day.

Jorge Silva
MVP Directory Services
"John" <John@discussions.microsoft.com> wrote in message
news:4E0505AE-B9B9-42C4-AA91-C0D331A89A63@microsoft.com...
> Hi all,
>
> I need to retrieve all windows 2003 standard and enterprise servers from
> active directory 2003 in csv format. From the ADUC console, the OS shows
> windows server 2003 for both OS. Is there a way to do this?
>
> thank you!
>
Re: any command to do this? [message #155407 is a reply to message #155387] Thu, 28 May 2009 17:00 Go to previous messageGo to next message
rlmueller-nospam  is currently offline rlmueller-nospam  United States
Messages: 292
Registered: July 2009
Senior Member
"John" <John@discussions.microsoft.com> wrote in message
news:4E0505AE-B9B9-42C4-AA91-C0D331A89A63@microsoft.com...
> Hi all,
>
> I need to retrieve all windows 2003 standard and enterprise servers from
> active directory 2003 in csv format. From the ADUC console, the OS shows
> windows server 2003 for both OS. Is there a way to do this?
>
> thank you!
>

From the Script Center you can use this script, or similar:

http://www.microsoft.com/technet/scriptcenter/scripts/os/ver sion/ostveb01.mspx

The Caption property is the one you want. You can assign the NetBIOS name of
a computer to the strComputer attribute and get this information for a
remote computer. You can code a script that uses the FileSystemObject to
read NetBIOS names from a text file and retrieves the Caption property from
each, as long as they are accessible. Another FileSystemObject File Object
can be used to write the computer name and OS, comma delimited, to a text
file, or the script could echo this information and you would redirect the
output to a text file.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Re: any command to do this? [message #155419 is a reply to message #155407] Thu, 28 May 2009 17:34 Go to previous messageGo to next message
rlmueller-nospam  is currently offline rlmueller-nospam  United States
Messages: 292
Registered: July 2009
Senior Member
"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:u4RBsd93JHA.4116@TK2MSFTNGP04.phx.gbl...
>
> "John" <John@discussions.microsoft.com> wrote in message
> news:4E0505AE-B9B9-42C4-AA91-C0D331A89A63@microsoft.com...
>> Hi all,
>>
>> I need to retrieve all windows 2003 standard and enterprise servers from
>> active directory 2003 in csv format. From the ADUC console, the OS shows
>> windows server 2003 for both OS. Is there a way to do this?
>>
>> thank you!
>>
>
> From the Script Center you can use this script, or similar:
>
> http://www.microsoft.com/technet/scriptcenter/scripts/os/ver sion/ostveb01.mspx
>
> The Caption property is the one you want. You can assign the NetBIOS name
> of a computer to the strComputer attribute and get this information for a
> remote computer. You can code a script that uses the FileSystemObject to
> read NetBIOS names from a text file and retrieves the Caption property
> from each, as long as they are accessible. Another FileSystemObject File
> Object can be used to write the computer name and OS, comma delimited, to
> a text file, or the script could echo this information and you would
> redirect the output to a text file.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>

After re-reading your question, I decided you don't want to create a list of
machine names. The list can be read from AD. In my example below I retrieve
all computers where the operatingSystem attribute includes the string
"server". You could modify this so it must include both "server" and "2003".
The program then connects to each with WMI, retrieves the operating system
information, and echos the information to the command console:
======
Option Explicit

Dim objRootDSE, strDNSDomain, adoConnection
Dim strBase, strFilter, strAttributes, strQuery, adoRecordset
Dim strComputer
Dim objWMIService, colOperatingSystems, objOperatingSystem

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

' Use ADO to search Active Directory.
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"

Set adoRecordset = CreateObject("ADODB.Recordset")
adoRecordset.ActiveConnection = adoConnection

' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"

' Filter on all computers with a server operating system.
strFilter = "(&(objectCategory=computer)(operatingSystem=*server*))"

' Comma delimited list of attribute values to retrieve.
strAttributes = "sAMAccountName"

' Construct the LDAP query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"

' Run the query.
adoRecordset.Source = strQuery
adoRecordset.Open

' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
' Retrieve values.
strComputer = adoRecordset.Fields("sAMAccountName").Value
' Strip off trailing "$".
strComputer = Left(strComputer, Len(strComputer) - 1)
' Connect to remote computer with WMI.
' Trap error if computer not available.
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\ " _
& strComputer & "\root\cimv2")
If (Err.Number = 0) Then
On Error GoTo 0
' Retrieve operating system information.
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
Wscript.Echo strComputer & ",""" & objOperatingSystem.Caption &
""""
Next
Else
On Error GoTo 0
' Computer not available.
Wscript.Echo strComputer & ",""<not available>"""
End If
adoRecordset.MoveNext
Loop

' Clean up.
adoRecordset.Close
adoConnection.Close
======
I enclose the value of the Caption property in quotes, because it can
contain commas. Quotes embedded in a quoted string must be doubled. You
should run this script at a command prompt and redirect the output to a text
file. For example, if the VBScript is called FindServers.vbs:

cscript //nologo FindServers.vbs > Servers.csv

This example traps the error if the computer is not available. However, you
will experience a timeout of perhaps 30 seconds in each such case. In a
large network, you should add a function to ping each computer first and
only attempt to connect with WMI if there is a reply. See this link for
example ping functions:

http://www.rlmueller.net/PingComputers.htm

And this link for an example program that pings each computer before
connecting with WMI to retrieve information:

http://www.rlmueller.net/Inventory.htm

This last example also demonstrates how to document to an Excel Spreadsheet.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Re: any command to do this? [message #155443 is a reply to message #155387] Fri, 29 May 2009 08:31 Go to previous message
pbbergs  is currently offline pbbergs  United States
Messages: 1024
Registered: July 2009
Senior Member
I think this is what you are looking for

http://www.microsoft.com/technet/scriptcenter/scripts/defaul t.mspx?mfr=true

--
Paul Bergson
MVP - Directory Services
MCTS, MCT, MCSE, MCSA, Security+, BS CSci
2008, 2003, 2000 (Early Achiever), NT4

http://www.pbbergs.com

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.

"John" <John@discussions.microsoft.com> wrote in message
news:4E0505AE-B9B9-42C4-AA91-C0D331A89A63@microsoft.com...
> Hi all,
>
> I need to retrieve all windows 2003 standard and enterprise servers from
> active directory 2003 in csv format. From the ADUC console, the OS shows
> windows server 2003 for both OS. Is there a way to do this?
>
> thank you!
>
Previous Topic:Re: AD 2003 and a clone domain
Next Topic:Remote Site & Restricted DNS
Goto Forum:
  


Current Time: Sat Oct 21 19:05:13 EDT 2017

Total time taken to generate the page: 0.05997 seconds
.:: Contact :: Home ::Sitemap::.

Powered by: FUDforum 3.0.0RC2.
Copyright ©2001-2009 FUDforum Bulletin Board Software