IP address logging durin startup

P

Pete

I've set a script to run via a group policy at user logon which writes the
user's computername, username, date, time and logon server to a log file.
The script is below:

-----------------------------------------
echo %computername%,%username%,%date%,%time%,%logonserver% >> userlogons.log
-----------------------------------------


Can somebody tell me how to get the users's machine's IP address in there
too?

Thanks
Pete
 
J

Jerold Schulman

I've set a script to run via a group policy at user logon which writes the
user's computername, username, date, time and logon server to a log file.
The script is below:

-----------------------------------------
echo %computername%,%username%,%date%,%time%,%logonserver% >> userlogons.log
-----------------------------------------


Can somebody tell me how to get the users's machine's IP address in there
too?

Thanks
Pete

for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 %computername%') do set IP=%%i

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
M

Matthias Tacke

Jerold Schulman wrote:
....
for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 %computername%') do set IP=%%i
That's a nice short one Jerold, went as GetPing2SetIP.cmd to my toolbox.

Thank you
MAtthias
 
P

Pete

Guys, am I being thick? I type that into a command prompt and all it gives
me is:

%%i was unexpected at this time


What am I doing wrong?

Thanks
Pete


Matthias Tacke said:
Jerold Schulman wrote:
...
for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 %computername%') do set IP=%%i
That's a nice short one Jerold, went as GetPing2SetIP.cmd to my toolbox.

Thank you
MAtthias
 
T

Torgeir Bakken (MVP)

Pete said:
Matthias said:
...
for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 %computername%') do set
IP=%%i
That's a nice short one Jerold, went as GetPing2SetIP.cmd to my toolbox.

Guys, am I being thick? I type that into a command prompt and all it gives
me is:

%%i was unexpected at this time

What am I doing wrong?

Hi

When running from command prompt and not a batch file, you need to change %%i
to %i
 
P

Pete

Got it, thanks guys. Now I see that it was creating the %IP% which I could
add to the rest of the little script. It all works a treat.

Thanks Jerold

Pete
Torgeir Bakken (MVP) said:
Pete said:
Matthias said:
...

for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 %computername%') do set
IP=%%i

That's a nice short one Jerold, went as GetPing2SetIP.cmd to my
toolbox.

Guys, am I being thick? I type that into a command prompt and all it gives
me is:

%%i was unexpected at this time

What am I doing wrong?

Hi

When running from command prompt and not a batch file, you need to change %%i
to %i


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
 
G

Guest

-----Original Message-----
I've set a script to run via a group policy at user logon which writes the
user's computername, username, date, time and logon server to a log file.
The script is below:

-----------------------------------------
echo %computername%,%username%,%date%,%time%,% logonserver% >> userlogons.log
-----------------------------------------


Can somebody tell me how to get the users's machine's IP address in there
too?

Thanks
Pete
=========================================================
Either of the following 2 methods will also quickly return
a PC/User's IP Address:
--------
(1 line)
C:\WINNT\System32\IPconfig.exe | FIND /i "IP Address" >>
userlogons.log
---or---
(2 lines)
C:\WinNT\WNTIPcfg.exe /Batch C:\IPcfg.txt
TYPE C:\IPcfg.txt | FIND /i "IP Address" >> userlogons.log
 
J

Jerold Schulman

If the user has multiple interfaces, this will return them all, not what was
asked for.



=========================================================
Either of the following 2 methods will also quickly return
a PC/User's IP Address:
--------
(1 line)
C:\WINNT\System32\IPconfig.exe | FIND /i "IP Address" >>
userlogons.log
---or---
(2 lines)
C:\WinNT\WNTIPcfg.exe /Batch C:\IPcfg.txt
TYPE C:\IPcfg.txt | FIND /i "IP Address" >> userlogons.log


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
M

Mark V

In said:
=========================================================
Either of the following 2 methods will also quickly return
a PC/User's IP Address:
--------
(1 line)
C:\WINNT\System32\IPconfig.exe | FIND /i "IP Address" >>
userlogons.log
---or---
(2 lines)
C:\WinNT\WNTIPcfg.exe /Batch C:\IPcfg.txt
TYPE C:\IPcfg.txt | FIND /i "IP Address" >> userlogons.log

Just to mention that the exact output text of ipconfig.exe does vary
in some cases and for some lines from OS version to version. I do
not recall the particulars though. "IP Address" is suitable in W2k
at least though.
 
J

Jerold Schulman

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top