Skip to content
Menu
Jumlins TechBlog
  • Home
  • About
Jumlins TechBlog

Inventory script for use with login scripts

Posted on 2010-03-192010-07-17 by Niklas Jumlin

I was recently asked to inventory approx 200 client computers of what programs they had installed, the specifications (cpu/ram/hdd) etc. So I was being lazy as most IT-techs are and wrote a script that I later on implemented into their usual login script.

It creates a simple .txt-file on a pre-mapped network drive and appends new batch runs into the same file.
After a successfull inventory run, the script creates a empty file (flag.txt) in the global var %appdata% where the current logged in user allways has write access. And the next time the script runs, it will check if the file flag.txt exists and exit if it does.

As I wrote, this script can be used together with a login script.

start \\servername\full_unc_path\inventory.bat

@echo off
title Inventory Script
REM Made by Niklas Jumlin - Copyright 2010
REM This script may NOT be redistributed without the permission of the author

:: GLOBAL VARS
@for /f "Tokens=1" %%i in ('time /t') do @set tm=%%i
@for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do  @set dt=%%i%%j%%k%%l
@set tm=%tm::=.%
@set dtt=%dt%_%tm%
@set computer=%computername%
@set computer=%computer:~0,4%

:: SPECIFY WHERE TO SAVE THE INVENTORY LOG
set target=\\server.domain.local\netlogon\inventory\%computername%-%username%.txt
echo "%target%"
echo. > %target%

:: EXIT IF IT IS A SERVER AND/OR IF SCRIPT HAS ALLREADY BEEN EXECUTED
if /i %computer% == site exit
if exist "%appdata%\flag_inv_%computername%.txt" exit

:: START INVENTORING
color b0
mode 52,3
cls
echo. 
echo  Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo ------------ START OF %computername% --------------- >> %target%
echo. >> %target%
echo Date and time of run: %dtt% >> %target%
echo. >> %target%
echo ACTIVE USER: %username% >> %target%
echo PROFILE PATH: %userprofile% >> %target%
echo APP DATA: %appdata% >> %target%
echo. >> %target%
systeminfo >> %target%
cls
echo. 
echo  Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
wmic /append:%target% Desktop Get Name
cls
echo. 
echo  Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
echo INSTALLED APPLICATIONS: >> %target%
echo. >> %target%
wmic /append:%target% product get name,version
cls
echo. 
echo  Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
echo SHARED NETWORK RESOURCES: >> %target%
echo. >> %target%
net share >> %target%
cls
echo. 
echo  Running inventory on computer . . . DO NOT CANCEL! /IT-DEPARTMENT
echo. >> %target%
echo ------------ END OF %computername% ----------------- >> %target%
echo. >> %target%
echo. >> "%appdata%\flag_inv_%computername%.txt"
@exit


Share on Facebook

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Office 365 Groups/Teams powershell reporting script 2019-03-25
  • [Powershell Script] Convert ImmutableID 2018-09-12
  • Script to Schedule Mem and or vCPU up/downgrade 2015-05-13
  • Backing up VMs in Hyper-V 2013-01-09
  • Windows Server 2012 as a Workstation 2012-09-13

Archives

Categories

  • Exchange 2003
  • Exchange 2010
  • HTML/CSS
  • Imagick
  • JavaScript
  • Linux
  • Misc
  • Office 365 / Azure
  • PHP
  • PowerCLI
  • PowerShell
  • Projects
  • Scripts
  • Server
  • System Administration
  • VMware
  • Winbatch
  • Windows
  • Windows Server 2012

Recent Posts

  • Office 365 Groups/Teams powershell reporting script 2019-03-25
  • [Powershell Script] Convert ImmutableID 2018-09-12
  • Script to Schedule Mem and or vCPU up/downgrade 2015-05-13
  • Backing up VMs in Hyper-V 2013-01-09
  • Windows Server 2012 as a Workstation 2012-09-13
©2023 Jumlins TechBlog | Powered by WordPress & Superb Themes