mini-computer inventory

Posted: 11-10-2004, 07:42 PM
Good afternoon!

Running WIN2000 Server SP4 Active Directory with WIN2000 Pro SP4 and WINXP
Pro SP1 and SP2 clients. I hope that this is the correct newsgroup. I am
thinking that it is not, based on the name of this newsgroup.

I am a complete newbie when it comes to scripting. So, please be patient.
And please pardon my possible incorrect use of terms.

I am learning WMI and ADSI ( for the purposes of making Systems
Administration a whole lot easier ). What I am trying to find is a simple
way to run a script that will, for this example, compile a list of the
Operating System and Service Pack of all the computers in the domain. I
know that I can easily do this via ldifde ( and do it all the time ) but I
am going to want to do this for RAM, CPU and Hard Drive soon - and ldifde
can not do this. WMI can, though.

Anyway, it seems that all of the examples that I have seen are for running
against the local machine ( strComputer = ".", which is not too bad... ) or
against one, specific remote host ( strComputer = "atl-ws-01" ) . I would
need this to run against all of the computers in the domain. Another
problem is that the 'result' is usually echoed to the screen ( WScript.Echo
objItem.Property ). This does not help when I have hundreds and hundreds of
computers! I would like one single .txt file that contains the information
from all of the computers in the domain. Is this possible?

Thank you all for your suggestions and time!

Cary



Reply With Quote

Responses to "mini-computer inventory"

Peter Falz
Guest
Posts: n/a
 
Re: mini-computer inventory
Posted: 11-10-2004, 09:09 PM
Hi Cary Shultz [A.D. MVP],

"Cary Shultz [A.D. MVP]" <cwshultz@mvps.org> schrieb im Newsbeitrag news:uAko211xEHA.2040@tk2msftngp13.phx.gbl...
> Anyway, it seems that all of the examples that I have seen are for running
> against the local machine ( strComputer = ".", which is not too bad... ) or
> against one, specific remote host ( strComputer = "atl-ws-01" ) . I would
> need this to run against all of the computers in the domain. Another
> problem is that the 'result' is usually echoed to the screen ( WScript.Echo
> objItem.Property ). This does not help when I have hundreds and hundreds of
> computers! I would like one single .txt file that contains the information
> from all of the computers in the domain. Is this possible?
You have a list as type of a textfile of all computer the script should
run against?

It is not a problem, that the result can be written to a textfile.
Therefore, you have to use FileScriptingObject.

Your question: Is this possible? Yes, it is.

Cioa
Peter


Reply With Quote
Cary Shultz [A.D. MVP]
Guest
Posts: n/a
 
Re: mini-computer inventory
Posted: 11-11-2004, 01:29 AM
Peter,

Thank you. Could you give me an example? Let's just say that I had a .txt
file ( probably not a problem to create ) with all of the computer account
objects. How would it look? Sorry, but really a newbie and have spent all
of six hours with this so far.

Thank you,

Cary

"Peter Falz" <pf.ms.news@asp-solutions.de> wrote in message
news:OvKZXm2xEHA.2348@TK2MSFTNGP12.phx.gbl...
> Hi Cary Shultz [A.D. MVP],
>
> "Cary Shultz [A.D. MVP]" <cwshultz@mvps.org> schrieb im Newsbeitrag
news:uAko211xEHA.2040@tk2msftngp13.phx.gbl...
> > Anyway, it seems that all of the examples that I have seen are for
running
> > against the local machine ( strComputer = ".", which is not too bad... )
or
> > against one, specific remote host ( strComputer = "atl-ws-01" ) . I
would
> > need this to run against all of the computers in the domain. Another
> > problem is that the 'result' is usually echoed to the screen (
WScript.Echo
> > objItem.Property ). This does not help when I have hundreds and
hundreds of
> > computers! I would like one single .txt file that contains the
information
> > from all of the computers in the domain. Is this possible?
>
> You have a list as type of a textfile of all computer the script should
> run against?
>
> It is not a problem, that the result can be written to a textfile.
> Therefore, you have to use FileScriptingObject.
>
> Your question: Is this possible? Yes, it is.
>
> Cioa
> Peter
>
>

Reply With Quote
Peter Falz
Guest
Posts: n/a
 
Re: mini-computer inventory
Posted: 11-11-2004, 12:59 PM
Hi Cary,

"Cary Shultz [A.D. MVP]" <cwshultz@mvps.org> schrieb im Newsbeitrag news:%23SCA234xEHA.3844@TK2MSFTNGP09.phx.gbl...
> Thank you. Could you give me an example? Let's just say that I had a .txt
> file ( probably not a problem to create ) with all of the computer account
> objects. How would it look? Sorry, but really a newbie and have spent all
> of six hours with this so far.
i've known, that you ask for this and i've coded just yesterday the
following lines for "you" ;-).

' --- Code: Begin
Const OPENFORREAD = 1

Dim dicComputer
Set dicComputer = CreateObject( "Scripting.Dictionary" )

Dim objFSO
Set objFSO = CreateObject( "Scripting.FileSystemObject" )

Dim objFILE_Input
Set objFILE_Input = objfso.OpenTextFile( "computer.txt" , OPENFORREAD )
Dim objFILE_Result
Set objFILE_Result = objFSO.CreateTextFile( "result.txt" , True )

Dim objWMI
Dim objWMIInstance

Dim strComputer
Dim strResult

Dim intKey
Dim intCount
intCount = 0


' --- Read the file and create a dictionary.
' --- Can be used, if the computerlist must be looped more than one time
Do While Not objFILE_Input.AtEndOfStream
intCount = intCount + 1

strComputer = objFILE_Input.ReadLine
dicComputer.add intCount , strComputer
Loop


Set objFILE_Input = Nothing


For Each intKey In dicComputer
strComputer = dicComputer.Item( intKey )

On Error Resume Next

Set objWMI = GetObject( "winmgmts:\\" & strComputer & "\root\cimv2" )

If ERR = 0 Then
' --- This For/Each runs one time
For Each objWMIInstance In objWMI.InstancesOf( "Win32_ComputerSystem" )
strResult = vbCrLf & "[" & objWMIInstance.Name & "]"
objFILE_Result.WriteLine strResult
Next 'objWMIInstance

For Each objWMIInstance In objWMI.InstancesOf( "Win32_DiskDrive" )
objFILE_Result.WriteLine objWMIInstance.Caption
Next 'objWMIInstance
End If

Set objWMI = Nothing

On Error Goto 0
Next


Set objFILE_Result = Nothing
Set objFSO = Nothing

' --- Code: Ended

The inputfile have to be named as "computer.txt".
The resultfile is named as "result.txt".
I've tested this script with "cscript" and in works fine.
Importent is, that you have the rights on the remote computer
to do these actions, to run WMI.

HTH

Cioa
Peter


Reply With Quote
Cary Shultz [A.D. MVP]
Guest
Posts: n/a
 
Re: mini-computer inventory
Posted: 11-11-2004, 03:38 PM
Guten Morgen Peter,

Ich bedanke mich recht herzlich bei Dir fuer Deine Hilfe! Ich werde mir den
Text ansehen and davon lernen!

I am really not having the time that I would like to have for this. And by
'for this' I mean rolling up my sleeves and really learning WMI so that I
can come up with this sort of thing on my own. The bottom half looks
familiar and very understandable. I would - at this point - not be able to
have come up with the top half.....Not yet! But that will change. I will
learn WMI and ADSI. There are too many things that you can do with both of
them that make my job so much easier!

I hope that everyone in this newsgroup will benefit from this example! And,
when using it, give Peter due credit.

Best regards,

Cary



"Peter Falz" <pf.ms.news@asp-solutions.de> wrote in message
news:%236dLE5%23xEHA.3840@tk2msftngp13.phx.gbl...
> Hi Cary,
>
> "Cary Shultz [A.D. MVP]" <cwshultz@mvps.org> schrieb im Newsbeitrag
news:%23SCA234xEHA.3844@TK2MSFTNGP09.phx.gbl...
> > Thank you. Could you give me an example? Let's just say that I had a
..txt
> > file ( probably not a problem to create ) with all of the computer
account
> > objects. How would it look? Sorry, but really a newbie and have spent
all
> > of six hours with this so far.
>
> i've known, that you ask for this and i've coded just yesterday the
> following lines for "you" ;-).
>
> ' --- Code: Begin
> Const OPENFORREAD = 1
>
> Dim dicComputer
> Set dicComputer = CreateObject( "Scripting.Dictionary" )
>
> Dim objFSO
> Set objFSO = CreateObject( "Scripting.FileSystemObject" )
>
> Dim objFILE_Input
> Set objFILE_Input = objfso.OpenTextFile( "computer.txt" , OPENFORREAD )
> Dim objFILE_Result
> Set objFILE_Result = objFSO.CreateTextFile( "result.txt" , True )
>
> Dim objWMI
> Dim objWMIInstance
>
> Dim strComputer
> Dim strResult
>
> Dim intKey
> Dim intCount
> intCount = 0
>
>
> ' --- Read the file and create a dictionary.
> ' --- Can be used, if the computerlist must be looped more than one
time
> Do While Not objFILE_Input.AtEndOfStream
> intCount = intCount + 1
>
> strComputer = objFILE_Input.ReadLine
> dicComputer.add intCount , strComputer
> Loop
>
>
> Set objFILE_Input = Nothing
>
>
> For Each intKey In dicComputer
> strComputer = dicComputer.Item( intKey )
>
> On Error Resume Next
>
> Set objWMI = GetObject( "winmgmts:\\" & strComputer &
"\root\cimv2" )
>
> If ERR = 0 Then
> ' --- This For/Each runs one time
> For Each objWMIInstance In objWMI.InstancesOf(
"Win32_ComputerSystem" )
> strResult = vbCrLf & "[" & objWMIInstance.Name & "]"
> objFILE_Result.WriteLine strResult
> Next 'objWMIInstance
>
> For Each objWMIInstance In objWMI.InstancesOf(
"Win32_DiskDrive" )
> objFILE_Result.WriteLine objWMIInstance.Caption
> Next 'objWMIInstance
> End If
>
> Set objWMI = Nothing
>
> On Error Goto 0
> Next
>
>
> Set objFILE_Result = Nothing
> Set objFSO = Nothing
>
> ' --- Code: Ended
>
> The inputfile have to be named as "computer.txt".
> The resultfile is named as "result.txt".
> I've tested this script with "cscript" and in works fine.
> Importent is, that you have the rights on the remote computer
> to do these actions, to run WMI.
>
> HTH
>
> Cioa
> Peter
>
>

Reply With Quote
Peter Falz
Guest
Posts: n/a
 
Re: mini-computer inventory
Posted: 11-11-2004, 04:02 PM
Hi Cary,

"Cary Shultz [A.D. MVP]" <cwshultz@mvps.org> schrieb im Newsbeitrag news:ugHgGSAyEHA.2200@TK2MSFTNGP09.phx.gbl...
> Guten Morgen Peter,
> Ich bedanke mich recht herzlich bei Dir fuer Deine Hilfe! Ich werde mir den
> Text ansehen and davon lernen!
Wow, in German, top!
> I am really not having the time that I would like to have for this. And by
> 'for this' I mean rolling up my sleeves and really learning WMI so that I
> can come up with this sort of thing on my own. The bottom half looks
> familiar and very understandable. I would - at this point - not be able to
> have come up with the top half.....Not yet! But that will change. I will
What's the problem? Much code with not so much benefit? Of course,
it is not necessary to do it so as i've done here, but that's way, we are
programming, and that's to use a very "clean way". (i hope you understand
what i want to say, my english is not the best).
> learn WMI and ADSI. There are too many things that you can do with both of
> them that make my job so much easier!
Yes, you have right, also ADSI makes the job easiar. But with this i have no
expirience, not yet ;-).
> I hope that everyone in this newsgroup will benefit from this example! And,
> when using it, give Peter due credit.
Thx.

Ciao
Peter


Reply With Quote
Cary Shultz [A.D. MVP]
Guest
Posts: n/a
 
Re: mini-computer inventory
Posted: 11-11-2004, 04:58 PM
Peter,

Lived in Ruesselsheim for a couple of years and worked in Floersheim during
that time. Also spent several months in the Bonn / Koeln area learning
German. It has been some 10 years since I came back to the US ( March
1995 ) but have not forgotten too much. Actually spoke with some Germans
here in Roanoke, VA the other day and was pleasantly surprised that
everything still flows. It took a second initially but that was the only
delay.

And, to comment on your code - just not familiar with it. The style is a
bit different from what I have seen ( pretty much -ONLY- the Scripting Guys
webcasts ) but that is not the problem. Just not familiar with this. Not
yet! But I am sure that in a couple of days or weeks it will seem perfectly
familiar! And I always prefer to do it the clean, correct way rather than
use a bunch of shortcuts.

And so far I have had no problems whatsoever in any of your posts with your
English.....it is quite good, infact!

Thank you, again!

Cary

"Peter Falz" <pf.ms.news@asp-solutions.de> wrote in message
news:OWQHlfAyEHA.3212@TK2MSFTNGP09.phx.gbl...
> Hi Cary,
>
> "Cary Shultz [A.D. MVP]" <cwshultz@mvps.org> schrieb im Newsbeitrag
news:ugHgGSAyEHA.2200@TK2MSFTNGP09.phx.gbl...
> > Guten Morgen Peter,
> > Ich bedanke mich recht herzlich bei Dir fuer Deine Hilfe! Ich werde mir
den
> > Text ansehen and davon lernen!
> Wow, in German, top!
>
> > I am really not having the time that I would like to have for this. And
by
> > 'for this' I mean rolling up my sleeves and really learning WMI so that
I
> > can come up with this sort of thing on my own. The bottom half looks
> > familiar and very understandable. I would - at this point - not be able
to
> > have come up with the top half.....Not yet! But that will change. I
will
> What's the problem? Much code with not so much benefit? Of course,
> it is not necessary to do it so as i've done here, but that's way, we are
> programming, and that's to use a very "clean way". (i hope you understand
> what i want to say, my english is not the best).
>
> > learn WMI and ADSI. There are too many things that you can do with both
of
> > them that make my job so much easier!
> Yes, you have right, also ADSI makes the job easiar. But with this i have
no
> expirience, not yet ;-).
>
> > I hope that everyone in this newsgroup will benefit from this example!
And,
> > when using it, give Peter due credit.
> Thx.
>
> Ciao
> Peter
>
>

Reply With Quote
 
LinkBack Thread Tools Display Modes
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot access C: root directory on Vista computer from xp computer fs0002 Windows Vista Networking & Sharing 7 06-16-2007 05:14 PM
High rate wireless LAN Mini PCI m. balint Windows Vista Networking & Sharing 0 10-29-2006 02:10 PM
Cannot access C: root directory of Vista computer from XP computer fs0002 Windows Vista Networking & Sharing 11 06-16-2006 02:15 AM
Transferring Files from Home Computer to Office Computer Bill Windows XP Work Remotely 1 07-13-2003 12:48 PM
Connect from home computer to office computer jirkoo Windows XP Work Remotely 1 07-10-2003 05:32 PM


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90