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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login Script Question

Status
Not open for further replies.

djcrane

MIS
Nov 1, 2002
17
GB
Hi

I want to run some auditing software using the login script but want to it by the IP address of the machine. Does anyone know of a way to set the login script to query the workstation for its ip address?

Thanks
Dave
 
dj

Microsoft have some good scripts in their technet scripting area.

But here is exactly what you want:

And here is the script in case you can't open the link:
Description
Returns the IP address for each IP-enabled network adapter installed in a computer.

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
 
Excellent thanks for that!

I forgot to mention though that its a kix script. Anyway I've solved it and this is an example of the script:

;##### Audit Software to run on seperat VLAN#####

$IP=@IPADDRESS0 ;get the workstation ip address
$IP=substr($IP, 1, 11) ;chop off the network portion
$vLAN2="172. 29.100" ;VLAN 2
$vLAN3="172. 29.101" ;VLAN 3
$vLAN4="172. 29.110" ;VLAN 4
$vLAN5="172. 29.111" ;VLAN 5
$vLAN6="172. 29.120" ;VLAN 6
$vLAN7="172. 29.121" ;OBP VLAN 7

;##### Execute Auditing Software#####

IF $IP=$vLAN2 ;
shell "\\servername\whatever\whatever\audit.exe"
ENDIF

The first line gets the ip address of the workstation
The second line gets the first three parts of the ip address (the last one not important as I wanted to audit subnets of the network independantly.)

The next lot of lines describe the subnets values

To execute select the subnet you want to audit and hey presto. Done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top