Omit
(Fresh Scripter)
2006-04-03 09:45 AM
How to get hardware information without WMI

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.


Witto
(MM club member)
2006-04-03 10:07 AM
Re: How to remove null answers

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...


Witto
(MM club member)
2006-04-03 10:19 AM
Re: How to remove null answers

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


Mart
(KiX Supporter)
2006-04-03 10:19 AM
Re: How to remove null answers

@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.





Omit
(Fresh Scripter)
2006-04-03 10:58 AM
Re: How to remove null answers

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.


Mart
(KiX Supporter)
2006-04-03 11:40 AM
Re: How to remove null answers

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


Omit
(Fresh Scripter)
2006-04-03 12:10 PM
Re: How to remove null answers

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.


Omit
(Fresh Scripter)
2006-04-03 01:42 PM
Re: How to remove null answers

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.


Radimus
(KiX Supporter)
2006-04-03 03:18 PM
Re: How to remove null answers

see WMIQuery() in the UDF forum for a simple method of getting WMI Info.

Witto
(MM club member)
2006-04-03 03:46 PM
Re: How to remove null answers

If I understand well, for using WMIQuery(), Omit will still have to download and install WMI on his NT4 servers as Mart says.

Omit
(Fresh Scripter)
2006-04-03 04:57 PM
Re: How to remove null answers

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.

NTDOCAdministrator
(KiX Master)
2006-04-03 07:14 PM
Re: How to remove null answers

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.
 


Mordac85
(Fresh Scripter)
2006-04-03 11:37 PM
Re: How to remove null answers

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.

Omit
(Fresh Scripter)
2006-04-04 11:03 AM
Re: How to remove null answers

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


Björn
(Korg Regular)
2006-04-04 11:20 AM
Re: How to remove null answers

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.


Mart
(KiX Supporter)
2006-04-04 11:32 AM
Re: How to remove null answers

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.

Omit
(Fresh Scripter)
2006-04-04 12:10 PM
Re: How to remove null answers

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.

Witto
(MM club member)
2006-04-04 12:23 PM
Re: How to remove null answers

Schedule a reboot with AT, so you see the result in the morning...

NTDOCAdministrator
(KiX Master)
2006-04-04 06:32 PM
Re: How to remove null answers

Or you come in to work with a few systems at BSOD

Sealeopard
(KiX Master)
2006-04-05 05:58 AM
Re: How to remove null answers

$strComputer = "." is correct syntax if one targets the local computer.