This is to create an accurate inventory of user names to computer names and vice versa
- On a server, create a shared folder.
- Grant the share permission and NTFS permission for the folder to allow Full Control for the group Everyone.
- On your domain controller, create a new GPO at domain level.
- Edit the policy. Locate the entry: User Configuration –> Windows Settings –> Scripts (Logon/Logoff).
- Create the logon script which contain the following command:
@echo off
- Add these scripts to the policy.
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