Habeeb's profileHABEEB ALI SHAIK PhotosBlogListsMore Tools Help

Blog


    System Inventory script that outputs to Excel format (CSV)

     

    Looking for a free software inventory solution?

    This VBscript pulls HOST NAME, OS, Edition, SP, Vendor, Model, Service Tag, Total Memory, Number of Processors, PROCESSOR, PROCESSOR TYPE, HD0 Size,HD0 free space. It also outputs the data into a Excel spreadsheet.

    1. Open notepad
    2. Copy and paste below text to notepad
    3. Save the file with .vbs  extension.
    4. To run the script, Example: cscript queryRemoteServers.vbs servername username password
    5. Once you run the script, you will find the output data in output.csv of the script directory,

    inventoryscript

    '------------ SCRIPT STARTS HERE--------------
    '---------------------------------------------------------
    'script to query remote computers
    'for device inventory purposes
    '---------------------------------------------------------
    set args = Wscript.Arguments
    If args.Count <> 3 then
    Wscript.Echo "Usage: cscript queryRemoteServers.vbs server_name username password"
    Wscript.Quit 1
    END IF
    strComputer = args(0)
    strUser = args(1)
    strPass = args(2)

    Set objFS = CreateObject("Scripting.FileSystemObject")
    Set objNewFile = objFS.openTextFile("output.csv",8,True)
    'objNewFile.WriteLine "HOST NAME,OS,Edition,SP,Vendor,Model,Service Tag,Total Memory,Number of Processors, PROCESSOR,PROCESSOR TYPE,HD0 Size,HD0 freespace,HD1 Size,HD1 freespace"
    Set objLocator = CreateObject("WbemScripting.SwbemLocator")
    Set objSvc = objLocator.ConnectServer(strComputer, "root\cimv2", strUser, strPass)
    objNewFile.write strcomputer & ","
    Set colSWbemObjectSet = objSvc.InstancesOf("win32_operatingsystem")
    For Each objSWbemObject In colSWbemObjectSet
    objNewFile.Write objSWbemObject.caption & ","
    objNewFile.Write objSWbemObject.csdversion & ","
    Next
    Set colSWbemObjectSet = objSvc.InstancesOf("win32_computersystemproduct")
    For Each objSWbemObject In colSWbemObjectSet
    objNewFile.Write objSWbemObject.vendor & ","
    objNewFile.Write objSWbemObject.name & ","
    objNewFile.Write objSWbemObject.identifyingnumber & ","
    Next
    Set colSWbemObjectSet = objSvc.InstancesOf("Win32_computersystem")
    For Each objSWbemObject In colSWbemObjectSet
    objNewFile.Write objSWbemObject.totalphysicalmemory & ","
    objNewFile.Write objSWbemObject.numberofprocessors & ","
    Next
    Set colSWbemObjectSet = objSvc.ExecQuery("select * from Win32_processor where deviceID='CPU0'")
    For Each objSWbemObject In colSWbemObjectSet
    objNewFile.Write objSWbemObject.Name & ","
    objNewFile.Write objSWbemObject.caption & ","
    Next
    Set colSWbemObjectSet = objSvc.ExecQuery("select * from win32_logicaldisk where drivetype='3'")
    For Each objSWbemObject In colSWbemObjectSet
    objNewFile.Write objSWbemObject.size & ","
    objNewFile.Write objSWbemObject.freespace & ","
    Next
    objNewFile.WriteLine ""

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://habeebshaikali.spaces.live.com/blog/cns!AC13A3C850A713DF!428.trak
    Weblogs that reference this entry
    • None