#160218 - 2006-04-03 09:45 AM
How to get hardware information without WMI
|
Omit
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
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
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
|
|
|
|
#160222 - 2006-04-03 10:58 AM
Re: How to remove null answers
|
Omit
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
|
|
|
|
#160224 - 2006-04-03 12:10 PM
Re: How to remove null answers
|
Omit
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
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
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
see WMIQuery() in the UDF forum for a simple method of getting WMI Info.
|
Top
|
|
|
|
#160228 - 2006-04-03 04:57 PM
Re: How to remove null answers
|
Omit
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
|
|
|
|
#160231 - 2006-04-04 11:03 AM
Re: How to remove null answers
|
Omit
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
|
|
|
|
#160234 - 2006-04-04 12:10 PM
Re: How to remove null answers
|
Omit
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 329 anonymous users online.
|
|
|