Users & Computers Inventory

This is to create an accurate inventory of user names to computer names and vice versa

  1. On a server, create a shared folder.
  2. Grant the share permission and NTFS permission for the folder to allow Full Control for the group Everyone.
  3. On your domain controller, create a new GPO at domain level.
  4. Edit the policy. Locate the entry: User Configuration –> Windows Settings –> Scripts (Logon/Logoff).
  5. Create the logon script which contain the following command:

    @echo off

  6. date /t >> "%userprofile%\logonlog.txt"
    time /t >> "%userprofile%\logonlog.txt"
    echo ————— Network Drives >> "%userprofile%\logonlog.txt"
    echo. >> "%userprofile%\logonlog.txt"
    net use | find /i "\\" >> "%userprofile%\logonlog.txt"
    echo ————— Username >> "%userprofile%\logonlog.txt"
    echo %username% >> "%userprofile%\logonlog.txt"
    echo ————— Computer name >> "%userprofile%\logonlog.txt"
    echo %computername% >> "%userprofile%\logonlog.txt"
    echo ————— IP Addresses >> "%userprofile%\logonlog.txt"
    set | find /i "clientname" > nul
    if %errorlevel%==0 echo %clientname% >> "%userprofile%\logonlog.txt"
    ver | find /i "version" >> "%userprofile%\logonlog.txt"
    ipconfig | find /i "ip address" >> "%userprofile%\logonlog.txt"
    ipconfig /all | find /i "dhcp server" >> "%userprofile%\logonlog.txt"
    echo. >> "%userprofile%\logonlog.txt"
    echo ————— Logon Server >> "%userprofile%\logonlog.txt"
    echo %logonserver% >> "%userprofile%\logonlog.txt"
    echo. >> "%userprofile%\logonlog.txt"
    echo. >> "%userprofile%\logonlog.txt"
    echo ***************************************************************************************************** >> "%userprofile%\logonlog.txt"
    echo. >> "%userprofile%\logonlog.txt"
    echo. >> "%userprofile%\logonlog.txt"

    type "%userprofile%\logonlog.txt" >> "\\ServerName\ShareName\%username%.txt"
    type "%userprofile%\logonlog.txt" >> "\\ServerName\ShareName\%computername%.txt"

    del "%userprofile%\logonlog.txt"

    exit

  7. Add these scripts to the policy.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s