Page 1 of 1 1
Topic Options
#160218 - 2006-04-03 09:45 AM How to get hardware information without WMI
Omit Offline
Fresh Scripter

Registered: 2006-04-03
Posts: 7
I'm completely new with scripting and i could use some help. Following script gets IP addresses from lan adapters but what command removes the 0 answers?

?"IP"@IPADDRESS0
?"IP,"@IPADDRESS1
?"IP,"@IPADDRESS2
?"IP,"@IPADDRESS3
?"IP,"@IPADDRESS4
?"IP,"@IPADDRESS5
?"IP,"@IPADDRESS6
?"IP,"@IPADDRESS7
?"IP,"@IPADDRESS8
?"IP,"@IPADDRESS9

I tryed something like this if @IPADDRESS <> "" but it doesn't help. Couldn't find any help using search on this board or google.


Edited by Omit (2006-04-03 01:39 PM)

Top
#160219 - 2006-04-03 10:07 AM Re: How to remove null answers
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
What about
Code:

Dim $NIC, $IPAddress
$NIC = 0
While EnumIPInfo($NIC,0,0)
$IPAddress = EnumIPInfo($NIC,0,0)
? $IPAddress
$NIC = $NIC + 1
Loop


FYI: EnumIPInfo does not work for p.e. Windows NT4...

Top
#160220 - 2006-04-03 10:19 AM Re: How to remove null answers
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Code:

If @LOGONMODE
Break on
EndIf

Dim $Junk
$Junk = SetOption("NoMacrosInStrings","On")
$Junk = SetOption("NoVarsInStrings","On")

Dim $N°, $IPAddress
$N° = 0
$Junk = Execute("$IPAddress = @IPADDRESS" + $N°)

While $IPAddress

$Junk = Execute("$IPAddress = @IPADDRESS" + $N°)
If NOT $IPAddress
Quit 0
EndIf

? $N° ". "$IPAddress

$N° = $N° + 1
If $N° > 3
Quit 0
EndIf

Loop


I think this also works for NT4
Sorry, the code I posted here before was not usuable


Edited by Witto (2006-04-03 11:29 AM)

Top
#160221 - 2006-04-03 10:19 AM Re: How to remove null answers
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4648
Loc: The Netherlands
@IPADDRESS only goes from 0 to 3.

Quote:


@IPADDRESSx

TCP/IP address (possible values for x are 0 - 3).
Note Addresses are padded so that the resulting string always consists of four sets of three characters separated by periods. For example, if your IP address is 123.45.6.7, @IPADDRESS0 is 123. 45. 6. 7.



_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#160222 - 2006-04-03 10:58 AM Re: How to remove null answers
Omit Offline
Fresh Scripter

Registered: 2006-04-03
Posts: 7
I allso need to get these information from NT4 servers, but this script doesn't work. However it works in w2k and w2k3 servers.

$strComputer = "."
$objWMIService = GetObject("winmgmts:\\"+ $strComputer + "\root\cimv2")

$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each $objItem in $colItems
? "" + $objItem.Name
Next

$colItems = $objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each $objItem in $colItems
For Each $x in $objItem.ConfigOptions
? "Config Options:" + $x
Next
? "," + $objItem.SerialNumber
Next


$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each $objItem in $colItems
? "," + $objItem.Manufacturer
? "," + $objItem.Model
Next

$colItems = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each $objItem in $colItems
? "," + $objItem.Caption
? "," + $objItem.Version
? "," + $objItem.ServicePackMajorVersion
Next


$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each $objItem in $colItems
? "," + $objItem.NumberOfProcessors
? "," + $objItem.TotalPhysicalMemory
Next

The script needs to print the information to command prompt where the data is collected using tivoli.

Top
#160223 - 2006-04-03 11:40 AM Re: How to remove null answers
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4648
Loc: The Netherlands
WMI is not included in a default NT4 installation.
It is available as a download at MS.

http://www.microsoft.com/downloads/detai...5B-FBF236E0E875
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#160224 - 2006-04-03 12:10 PM Re: How to remove null answers
Omit Offline
Fresh Scripter

Registered: 2006-04-03
Posts: 7
I'm able to get these information:
?"HOST name = "@HOSTNAME
?"IP address = "@IPADDRESS0
?"OS = "@PRODUCTTYPE
?"ver = "@DOS"." @BUILD
?"SP = "@CSD
?"Memory = "MemorySize(0)" MB"

...but still i could use some help finding out NT4 servers serial no., manufacturer (IBM, Dell, HP), model number and the amount of CPU's. I don't want to install any software or addons to them because they are production servers.

Top
#160225 - 2006-04-03 01:42 PM Re: How to remove null answers
Omit Offline
Fresh Scripter

Registered: 2006-04-03
Posts: 7
I'm able to get the amount of processors with:
$EnvNUMBER_OF_PROCESSORS = "%NUMBER_OF_PROCESSORS%"
? "cpu = " + $EnvNUMBER_OF_PROCESSORS
..but the most important information that i need (hardware serial number) seems to be available only if i use WMI. If anyone knows any other way to get that information i would really appreciate it.

Top
#160226 - 2006-04-03 03:18 PM Re: How to remove null answers
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
see WMIQuery() in the UDF forum for a simple method of getting WMI Info.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#160227 - 2006-04-03 03:46 PM Re: How to remove null answers
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
If I understand well, for using WMIQuery(), Omit will still have to download and install WMI on his NT4 servers as Mart says.
Top
#160228 - 2006-04-03 04:57 PM Re: How to remove null answers
Omit Offline
Fresh Scripter

Registered: 2006-04-03
Posts: 7
I realize that but as i mentioned earlyer "I don't want to install any software or addons to them because they are production servers." That's why i asked that if theres any other way to solve serial no., manufacturer (IBM, Dell, HP)and model number besides WMIQuery. I have used allmost all day searching and googling and i'm gettin quite desperate.
Top
#160229 - 2006-04-03 07:14 PM Re: How to remove null answers
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Not unless there is a native application on the Servers in question that would probably have come from the MFG.

Without WMI it requires a specially written application that would normally come from MFG.

Without installing some type of software like WMI or SiSoftSandra or similar then you're probably out of luck.
 

Top
#160230 - 2006-04-03 11:37 PM Re: How to remove null answers
Mordac85 Offline
Fresh Scripter

Registered: 2000-02-16
Posts: 34
Loc: Urbana, OH, USA
There is a util for Dell called asset.com and avail here (3-4 different versions). To my knowledge, it only works on the local system and you'd have to pipe it to a text file, then parse that for the info you want. As for HP & IBM I would assume there is a similar utility.
_________________________
~Glenn

==============================
Deadlines take their toll.
Please have exact change.

Top
#160231 - 2006-04-04 11:03 AM Re: How to remove null answers
Omit Offline
Fresh Scripter

Registered: 2006-04-03
Posts: 7
Can someone tell me why this script displays empty answers in NT4 computers but works in w2k and w2k3 servers. I have installed the WMI from microsoft pages.

$strComputer = "."
$objWMIService = GetObject("winmgmts:\\"+ $strComputer + "\root\cimv2")

$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each $objItem in $colItems
? "" + $objItem.Name
Next

$colItems = $objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each $objItem in $colItems
For Each $x in $objItem.ConfigOptions
? "Config Options:" + $x
Next
? "," + $objItem.SerialNumber
Next


$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each $objItem in $colItems
? "," + $objItem.Manufacturer
? "," + $objItem.Model
Next

Top
#160232 - 2006-04-04 11:20 AM Re: How to remove null answers
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
I just tested it, and it works fine after installing the wmi on a nt4 box.
And just to sound stupid - you need to replace $strComputer = "." with $strComputer = "Thecomputeryouwishtocheck".
Edit: After reading Mart's comment, perhaps you should try to get something you know exists and see if a value is returned.


Edited by ewook (2006-04-04 11:35 AM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#160233 - 2006-04-04 11:32 AM Re: How to remove null answers
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4648
Loc: The Netherlands
It could also be an option that the info you want to retrieve is not stored in for example the BIOS of the specific machine by the manufacturer. If is the case then you are screwed.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#160234 - 2006-04-04 12:10 PM Re: How to remove null answers
Omit Offline
Fresh Scripter

Registered: 2006-04-03
Posts: 7
The whole thing actually crashes to the point where after WMI installation the computer needs to be rebooted -> can't boot ower 30 servers that are on production network. Thank you all who helped with this! I may return some day with more starter questions.
Top
#160235 - 2006-04-04 12:23 PM Re: How to remove null answers
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Schedule a reboot with AT, so you see the result in the morning...
Top
#160236 - 2006-04-04 06:32 PM Re: How to remove null answers
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Or you come in to work with a few systems at BSOD
Top
#160237 - 2006-04-05 05:58 AM Re: How to remove null answers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
$strComputer = "." is correct syntax if one targets the local computer.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 152 anonymous users online.
Newest Members
Jodey, Hiker, GTRoberts, KatieQuinn, Brennnnn
17684 Registered Users

Generated in 0.044 seconds in which 0.013 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org