Scripting-Collecting computer information

Source: Internet
Author: User

Idle to have nothing to do, want to the company domain computer statistics Some messy information out. But I am lazy, did not change the content of my company's environment as we can use, just put here to give everyone a thought. I really do not understand the code, do things are patchwork only to meet the needs of the CAN, The code is pretty and it doesn't get tangled up.

Note that the bat batch is above, and the following is the VBS script. I don't know how to do it in batches because I get the data from WMI. The first paragraph in the batch is used to get the information that the batch processing can get, The middle calls the VBS to take the data inside WMI. Then adjust the exported txt text at the end of the batch process.

Note: This is just what I am able to share with my own environment can be used, and other places do not necessarily use, but to give everyone a way of thinking. Ask someone with a certain code ability to modify and then use their environment. I'm not responsible for this code.

There are also write batches, VBS or PowerShell can you teach me ...


The following are batch processing

@echo  offecho  Please enter a save location set /p oppath=set t=%time: =0%echo =================== =================================> "%oppath%\%computername%-%username%.txt" echo  computer related information >>%oppath %\%computername%-%username%.txt "echo.>>"%oppath%\%computername%-%username%.txt "echo  last landing time:             %date:~,4% year%date:~5,2% month%date:~8,2% Day  %t: ~0,2%%t:~3,2% min%t:~6,2% sec >> "%oppath%\%computername%-%username%.txt" echo  computer name:                     % Computername%>> "%oppath%\%computername%-%username%.txt" Net config workstation | find   Computer full name  >>%oppath%\%computername%-%username%.txt echo  The name of the computer that is currently logged on:           %computername%>> "%oppath%\%computername%-%username%.txt" Echo   currently logged on user name:   &NBsp;         %username%>> "%oppath%\%computername%-%username %.txt "Echo ====================================================>>"%oppath%\%computername%-%username %.txt "ECHO IP Address related information >>"%oppath%\%computername%-%username%.txt "echo.>>"%oppath%\%computername%- %username%.txt "@echo  off>>%oppath%\%computername%-%username%.txt" ipconfig |find  "IPv4" >> "%oppath%\%computername%-%username%.txt" @echo  off>> "%oppath%\%computername%-%username%.txt" ipconfig |find  "Gateways" >> "%oppath%\%computername%-%username%.txt" @echo  off>> "%oppath%\% Computername%-%username%.txt "ipconfig/all |find " dns  Server ">>"%oppath%\%computername%-% Username%.txt "@echo  off>>"%oppath%\%computername%-%username%.txt "ipconfig/all |find " DHCP   Server ">>"%oppath%\%computername%-%username%.txt "echo ========================================== ==========>> "%o Ppath%\%computername%-%username%.txt "Echo offcscript %oppath%\script\get_information.vbs>>"%o Ppath%\%computername%-%username%.txt "set keyword1=microsoft  (R)  windows script host  version 5.8set keyword2= All rights reserved (C)  microsoft corporation 1996-2001. All rights reserved. FINDSTR /V /C: "%keyword1%"  %oppath%\%computername%-%username%.txt>%oppath%\%computername%-% Username%.tempmove /y %oppath%\%computername%-%username%.temp %oppath%\%computername%-%username %.TXTFINDSTR /V /C: "%keyword2%"  %oppath%\%computername%-%username%.txt>%oppath%\% computername%-%username%.tempmove /y %oppath%\%computername%-%username%.temp %oppath%\% Computername%-%username%.txtsysteminfo >> "%oppath%\%computername%-%username%.txt" pause


The following is the VBS

        Wscript.Echo  "Computer hardware Information"          Wscript.Echo strComputer =  "."  set objwmiservice = getobject ("winmgmts:\\"  & strComputer &  " \root\cimv2 ")  set colitems = objwmiservice.execquery ( _    " Select * from win32_bios ",,)      Wscript.Echo " * Computer brand "   For Each objItem in colItems     Wscript.Echo  objitem.manufacturerwscript.echo  "--------------------------" wscript.echo      wscript.echo  "* Serial number"       Wscript.Echo objItem.SerialNumberNext         Wscript.Echo  "--------------------------" wscript.echo  strcomputer =  "."  set objwmiservice = getobject ("WinMgmtS: " _    & " {impersonationlevel=impersonate}!\\ " & strcomputer  &  "\root\cimv2") set colchassis = objwmiservice.execquery _      ("Select * from win32_systemenclosure")     Wscript.Echo  "* Computer Type "  For Each objChassis in colChassis    For   each strchassistype in objchassis.chassistypes         select case strchassistype             case 1                 wscript.echo  "Other"             case 2                 wscript.echo   "Unknown"             case 3                 Wscript.Echo  "Desktop"              Case 4                 Wscript.Echo  "Low profile desktop"              Case 5                 Wscript.Echo  "Pizza box"              Case 6                 Wscript.Echo  "Mini tower"              Case 7                 Wscript.Echo  "Tower"              Case 8                 Wscript.Echo  "Portable"              Case 9                 Wscript.Echo  "Laptop"              case 10                 wscript.echo  "Notebook"             Case  11                wscript.echo   "Handheld"             Case 12                 wscript.echo  "Docking Station"              Case 13                 Wscript.Echo  "All-in-one"              Case 14                 Wscript.Echo  "Sub-notebook"              Case 15                 Wscript.Echo  "Space saving"              Case 16                 Wscript.Echo  "Lunch box"              case 17                 Wscript.Echo  "Main system chassis"              Case 18                 Wscript.Echo  "Expansion chassis"              Case 19                 Wscript.Echo  "Sub-chassis"              Case 20                 Wscript.Echo  "Bus expansion chassis"              Case 21                 wscript.echo  "Peripheral chassis"              Case 22                 Wscript.Echo  "Storage chassis"              Case 23                 Wscript.Echo  "Rack mount chassis"              Case 24                 Wscript.Echo  "SEALED-CASE PC"              Case Else                 Wscript.Echo  "Unknown"              end select    nextnext         Wscript.Echo  "--------------------------" Nicnum=1set objwmiservice = getobject (" winmgmts:\\ " & strComputer & " \root\cimv2 ")  Set colItems =  objWMIService.ExecQuery ( _     "Select * from win32_processor",, 48)  For Each objItem in colItems     Wscript.Echo      Wscript.Echo  "*CPU model"     Wscript.Echo objItem.NameNext         Wscript.Echo  "--------------------------" on error  Resume next dim memoryset objwmiservice = getobject ("winmgmts:"  _      &  "{impersonationlevel=impersonate}!\\"  & strComputer  &  "\root\cimv2")   set colitems = objwmiservice.execquery _      ("Select *  from win32_physicalmemory ")   For Each objItem in colItems     Memory =  objItem.Capacity/1024/1024/1024    Wscript.Echo      Wscript.Echo  "* Memory Capacity"       wscript.echo ("memory=")  & Memory &  "G") next     wscript.echo  "------------- -------------"    wscript.echo set colitems = objwmiservice.execquery (  _     "Select * from win32_networkadapterconfiguration", ( for)  each objitem in colitems     if isnull (objItem.IPAddress)  Then         ' wscript.echo  ' ipaddress:       else        wscript.echo  "* Network card" &nicnumWscript.Echo  "NIC Name:"  & objitem.caption        wscript.echo  "IPV4:"  & Join ( OBJITEM.IPADDRESS,CHR (Ten) & "IPV6:") wscript.echo  "MAC Address:"  &OBJITEM.MACADDRESS&CHR (10) nicnum=nicnum+1    end ifnext         wscript.echo  "--------------------------"


This article is from the "Puma Pot" blog, please make sure to keep this source http://38088444.blog.51cto.com/7547614/1665066

Scripting-Collecting computer information

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.