Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS Logon Script 1

Status
Not open for further replies.

CFUS

IS-IT--Management
Sep 2, 2003
6
US
I have a small problem, we use a simple user auditing script that was written in vbs, basically it gathers user information when they logon to our domain and saves it to a log file on our servers for later use. It does what we need but there is something else and I cant seem to find anything about it. We need the script to find the IP address of the user loging on. Its basically to find out were our IP address are getting allocated and to what users. Thanks for any help.
 
This gets the ip address of the user:

Dim ipconfigSet, ipconfig, oshell
set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select IPAddress, Caption from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

for each IPConfig in IPConfigSet
WScript.Echo( "Your IP Address is "&ipconfig.IPAddress(I))
Next
WScript.quit
 
You can capture and inspect the output of ipconfig.

Hope This Help
PH.
 
thanks for your help, but what Im looking at is trying to get it to write the ip address to the file, here is a snippet of the script we use to you can see how we are writing it
-------------------

On Error Resume Next
Dim WshNetwork, oFileSys, fh
Dim WshShell

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = Wscript.CreateObject("Wscript.Shell")

LogFile="s:\useraudit\" & WshNetwork.Username & "_" & WshNetwork.ComputerName & ".log"

Set oFileSys = CreateObject("Scripting.FileSystemObject")
set fh=oFileSys.CreateTextFile("s:\useraudit\" & WshNetwork.Username & "_" & WshNetwork.ComputerName & ".log",TRUE)

Wscript.echo "Running User Audit"
fh.WriteLine "User Audit Log - " & Now & VBCRLF

wscript.echo "Gathering user information..."
strTemp="User Domain:" & vbTab & WshNetwork.UserDomain & vbCRLF & "User Name:" & vbTab & vbTab & WshNetwork.UserName & vbCRLF & "Computer Name:" & vbTab & WshNetwork.ComputerName

------

and thats part of the log file, i just need to know how to get the IP address to be written with the other information..sorry for the inconvience but Im still learning. Thanks again
 
from my code above use this:
for each IPConfig in IPConfigSet
wscript.echo("Your IP Address is "&ipconfig.IPAddress(I))
fh.WriteLine("Your IP Address is "&ipconfig.IPAddress(I))
Next
 
Excellent, that worked just the way I needed it. Thanks for your helpful answer and everyones time, it is much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top