#42444 - 2003-07-08 02:51 PM
Re: hardware inventory
|
Kdyer
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 ]
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|