This little script run as a startup script will log the current IP address of a workstation together with the date and time to a log file on the local C:\
With a little bit of tweeking it can be modified to store it on a central server with machine names etc. in seperate log files for each day, or in seperate log files for each machine etc.
It's very badly written, I knocked it up sometime ago from various examples of other scripts on the net for a specific purpose when I was doing some troubleshooting, but it works.
Code:
strcomputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
for each objitem in colitems
strIPAddress = Join(objitem.IPAddress, ",")
next
IP = stripaddress
strFile = "C:\IPaddressLog.txt"
strText = date & " " & time & " " & IP
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFile) Then
Else
Set objFile = objFSO.CreateTextFile(strFile)
End If
Const ForAppending = 8
Set objTextFile = objFSO.OpenTextFile (strFile, ForAppending, True)
objTextFile.WriteLine(strText)
objTextFile.Close
WScript.Quit