Registered: 2001-08-21
Posts: 71
Loc: Los Angeles, cA
Hi all,
I am using the following script, but when I write it to a file instead of getting the value for $memory and $model, I get $memory and $model. Can you guys see what am I doing wrong? thanks Anna
$file="c:\batch\mylog.txt" go "C:" SHELL 'CMD /X/C "WINMSD /S /F"' OPEN(1, "@curdir\@WKSTA.TXT")=0 $counter=0 ;************************************** $LINE=READLINE(1) WHILE @ERROR=0 and $counter<>2 IF INSTR($LINE,"Total Physical Memory") $counter=$counter+1 $LINE=READLINE(1) $memory=$LINE ENDIF IF INSTR ($line,"System Model") $counter=$counter+1 $line=readline(1) $model=$line endif
IF INSTR($LINE,"Drives Report") $counter=$counter+1 $LINE=READLINE(1) $LINE=READLINE(1) $total=instr($line,"Total:") $free=instr($line,"KB"+chr(44)+" Free:") $tot=substr($line,$total+7,$free-$total-7)
Registered: 2001-08-21
Posts: 71
Loc: Los Angeles, cA
Yes, all the computers are w2k. Is there something simple that I can do to get the CPU name, speed, manufacturer and RAM? Can we get these information from the registry?
Registered: 2001-08-21
Posts: 71
Loc: Los Angeles, cA
I read the threads for the WMIQuery I don't know how would I use it? I am not getting it. I have WMI service running. Do I need to call the WMIQuery function from my script? Can u guys help?
Hi Anna, how you doin ? Include the WMIQuery function at the bottom of your script, then call it like in the following script. Assuming your running Kixtart 4 and have WMI running, should return the "make" of your workstation.
If you need more information regarding "what" is available from "where", just hollar !
Or download the WMI SDK which comes with a WMI Object Browser. Or search for the KiXomatic tool on the KORG BBS. WMI takes a while to get used to, but then you'll love it. And explore the BBS a little bit, there's been a lot posted with regards to inventories, just use the BBS Search extensively.
_________________________
There are two types of vessels, submarines and targets.
Registered: 2001-08-21
Posts: 71
Loc: Los Angeles, cA
Is there another way I can use WMIquery without upgrading it to 4.x? We won't be doing an upgrade anytime soon and I need to get a hardware inventory out this week. I'd appreciate any advise. thanks all Anna
Registered: 2001-08-21
Posts: 71
Loc: Los Angeles, cA
I was able to get most of the needed information from registry entry, except the RAM. I came across the memory.kix, but haven't figured out how to get the result. Do I call the memory.kix script within my script? How do I get the result? when I run the script where does it write the value? thanks Anna
KdyerKdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
anna,
Provided you have a list of computers, you can do this remotely and all you need is to run KiXtart 4.x from your local workstation, for example.
If you don't have the list of computers, you should be able to generate the list from AD users and computers, Hyena, or I believe that there are a couple of AD Scripts here that can do just that.
Here goes - $logshare='c:\' $logfile=$logshare+'Inventory.TXT' $oXL=Createobject('Excel.application') ;Check to insure that Excel is available IF 0<>@error ?@error ' Excel Application is not found' SLEEP 4 RETURN ENDIF $Rc=$oXL.workbooks.open("C:\Yourexcelfile.xls") $Row=1 WHILE $oXL.cells($Row,1).value<>'' $Row=$Row+1 IF $oXL.cells($Row,1).value='' ;Once it gets to a blank row... $oXL.quit ;quit Excel $oXL=0 ;set the object to 0 ELSE $b=$oXL.cells($Row,1) $b ;Print out results for each $stick in WMIQuery("Capacity","Win32_PhysicalMemory",$b) $MEM= val($stick) / 1048576 $logdata=$b+','+$MEM+@CRLF LOGGER($logshare,$logdata) next ENDIF LOOP
; ref - http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000117 FUNCTION WMIQuery($sWhat, $sFrom, Optional $sComputer, Optional $sWhere, Optional $x) Dim $sQuery, $objEnum, $sValue, $sItem, $lUbound Dim $aTMP[0]
$sQuery = "Select " + $sWhat + " From "+ $sFrom If Not $sComputer $sComputer=@WKSTA EndIf If $sWhere AND $x $sQuery = $sQuery + " Where " + $sWhere + " = '"+$x+"'" EndIf
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//"+$sComputer) If @ERROR Exit VAL("&"+Right(DecToHex(@ERROR),4)) Return EndIf
$objEnum = $SystemSet.ExecQuery($sQuery) If @ERROR Exit VAL("&"+Right(DecToHex(@ERROR),4)) Return EndIf
For Each $objInstance in $objEnum If $objInstance $=Execute("$$sValue = $$objInstance.$sWhat") Select Case VarType($sValue) & 8192 For Each $sItem in $sValue $lUbound = Ubound($aTMP) If $aTMP[$lUbound] >' ' $lUbound = $lUbound +1 Redim Preserve $aTMP[$lUbound] EndIf $aTMP[$lUbound] = Trim($sItem) Next Case 1 $lUbound = Ubound($aTMP) If $aTMP[$lUbound] >' ' $lUbound = $lUbound +1 Redim Preserve $aTMP[$lUbound] EndIf $aTMP[$lUbound] = Trim($sValue) EndSelect EndIf Next $WMIQuery = $aTMP Exit VAL("&"+Right(DecToHex(@ERROR),4)) ENDFUNCTION
;ref - http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000295 FUNCTION LOGGER($logfile,$logdata) DIM $n WHILE Open(1, $logfile, 5) OR $n=5 IF $n '.' ELSE ?'Please wait' ENDIF $n=$n+1 SLEEP 3 LOOP $n=WriteLine(1, $logdata) $n=Close(1) ENDFUNCTION
HTH,
Kent
[ 08. July 2003, 16:21: Message edited by: kdyer ]