break on
$remotepc="@WKSTA"
for each $nc in Enumnetworkconnections(3,$remotepc)
$ConnectionName=split($nc,",")[0]
$MACAddress=split($nc,",")[1]
$AdapterName=split($nc,",")[2]
? " Connection Name: " + $connectionname
? " MACAddress: " + $MACAddress
? " Adapter Name: " + $AdapterName
? " Mac Address: " + getipoptions("Macaddress",$remotepc,$macaddress)
? " Static Address: " + getipoptions("StaticIP",$remotepc,$macaddress)
? " DHCP Enabled: " + getipoptions("DHCPEnabled",$remotepc,$macaddress)
? " IPaddress/SM: " + getipoptions("IPAddress",$remotepc,$macaddress)
? " IPaddress0/SM: " + getipoptions("IPAddress0",$remotepc,$macaddress)
? " IPaddress1/SM: " + getipoptions("IPAddress1",$remotepc,$macaddress)
? " IPaddress2/SM: " + getipoptions("IPAddress2",$remotepc,$macaddress)
? " IPaddress3/SM: " + getipoptions("IPAddress3",$remotepc,$macaddress)
? " DefaultGW: " + getipoptions("DefaultGW",$remotepc,$macaddress)
? " DNS Servers: " + getipoptions("DNSServers",$remotepc,$macaddress)
? " WINS Servers: " + getipoptions("WINSServers",$remotepc,$macaddress)
? " DNSSuffix: " + getipoptions("DNSDomain",$remotepc,$macaddress)
? " DNS Search Order: " + getipoptions("DNSDomainSuffixSearchOrder",$remotepc,$macaddress)
? " DHCP Server: " + getipoptions("DHCPServer",$remotepc,$macaddress)
? "DHCP Lease Obtained: " + getipoptions("DHCPLeaseObtained",$remotepc,$macaddress)
? " DHCP Lease Expires: " + getipoptions("DHCPLeaseExpires",$remotepc,$macaddress)
? "---------------"
;Function:
; GetIPOptions()
;
;Author:
; Allen Powell
;
;Version:
; 1.0 2006/03/15
;
;Action:
; Display/Get IP Settings
;
;Syntax:
; GetIPOptions($Setting,optional $remotepc, optional $macaddress)
;
;Parameters:
; $setting - Any valid property from Win32_NetworkAdapterConfiguration class, See examples below and
;
;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_networkadapterconfiguration.asp
; $remotepc - (Optional) Remote Computer Name
; $macaddress - (Optional) In Computers with more than Network Adapter, provide the MACAddress to target it settings
;
;Returns:
; String containing setting
;
;Dependencies
; WMI with Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0 SP4 and later
; Tested with Kixtart 4.52 Beta
;
;Notes
; If a computer has more than one Network Adapter and the macaddress is not provided it will return the last adapter's ;
information
;
;Example1:
;
;? " Mac Address: " + getipoptions("Macaddress")
;? " Static Address: " + getipoptions("StaticIP")
;? " DHCP Enabled: " + getipoptions("DHCPEnabled")
;? " IPaddress/SM: " + getipoptions("IPAddress")
;? " IPaddress0/SM: " + getipoptions("IPAddress0")
;? " IPaddress1/SM: " + getipoptions("IPAddress1")
;? " IPaddress2/SM: " + getipoptions("IPAddress2")
;? " IPaddress3/SM: " + getipoptions("IPAddress3")
;? " DefaultGW: " + getipoptions("DefaultGW")
;? " DNS Servers: " + getipoptions("DNSServers")
;? " WINS Servers: " + getipoptions("WINSServers")
;? " DNSSuffix: " + getipoptions("DNSDomain")
;? " DNS Search Order: " + getipoptions("DNSDomainSuffixSearchOrder")
;? " DHCP Server: " + getipoptions("DHCPServer")
;? "DHCP Lease Obtained: " + getipoptions("DHCPLeaseObtained")
;? " DHCP Lease Expires: " + getipoptions("DHCPLeaseExpires")
;
;Example2: List settings for Remote Computers including those with more than one Network Adapter.
; Requires EnumNetworkConnections() - http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=138769&an=0&page=0#138769
;
;break on
;$remotepc="computername"
;for each $nc in Enumnetworkconnections(3,$remotepc)
; $ConnectionName=split($nc,",")[0]
; $MACAddress=split($nc,",")[1]
; $AdapterName=split($nc,",")[2]
; ? " Connection Name: " + $connectionname
; ? " MACAddress: " + $MACAddress
; ? " Adapter Name: " + $AdapterName
; ? " Mac Address: " + getipoptions("Macaddress",$remotepc,$macaddress)
; ? " Static Address: " + getipoptions("StaticIP",$remotepc,$macaddress)
; ? " DHCP Enabled: " + getipoptions("DHCPEnabled",$remotepc,$macaddress)
; ? " IPaddress/SM: " + getipoptions("IPAddress",$remotepc,$macaddress)
; ? " IPaddress0/SM: " + getipoptions("IPAddress0",$remotepc,$macaddress)
; ? " IPaddress1/SM: " + getipoptions("IPAddress1",$remotepc,$macaddress)
; ? " IPaddress2/SM: " + getipoptions("IPAddress2",$remotepc,$macaddress)
; ? " IPaddress3/SM: " + getipoptions("IPAddress3",$remotepc,$macaddress)
; ? " DefaultGW: " + getipoptions("DefaultGW",$remotepc,$macaddress)
; ? " DNS Servers: " + getipoptions("DNSServers",$remotepc,$macaddress)
; ? " WINS Servers: " + getipoptions("WINSServers",$remotepc,$macaddress)
; ? " DNSSuffix: " + getipoptions("DNSDomain",$remotepc,$macaddress)
; ? " DNS Search Order: " + getipoptions("DNSDomainSuffixSearchOrder",$remotepc,$macaddress)
; ? " DHCP Server: " + getipoptions("DHCPServer",$remotepc,$macaddress)
; ? "DHCP Lease Obtained: " + getipoptions("DHCPLeaseObtained",$remotepc,$macaddress)
; ? " DHCP Lease Expires: " + getipoptions("DHCPLeaseExpires",$remotepc,$macaddress)
; ? "---------------"
;next
;
;
function GetIPOptions($Setting,optional $remotepc, optional $macaddress)
dim $objWMIService, $colitems, $objnetadapter,$targetadapter,$,$allnics,$counter,$Mask,$SN, $IP, $IPAddress,$toggle
if $remotepc=""
$remotepc="."
endif
if $macaddress=""
$allnics=1
endif
$objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2")
if @error
exit @error
endif
$colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=-1")
For Each $objNetAdapter In $colItems
if $macaddress=$objNetAdapter.macaddress or $allnics
select
case instr($setting,"IPAddress")>0
if right($setting,1)="s" or val(right($setting,1))>3 or len($setting)>10
$targetadapter=0
else
$targetadapter=right($setting,1)
endif
$counter=0
for each $IP in $objNetAdapter.IPAddress
if "" + $counter=$targetadapter
$IPAddress=$IP
endif
$counter=$counter+1
next
$counter=0
for each $SN in $objNetAdapter.IPSubnet
if "" + $counter=$targetadapter
$Mask=$SN
endif
$counter=$counter+1
next
$GetIPOptions=$IPAddress
if $mask
$GetIPOptions=$GetIPOptions + "," + $Mask
endif
case $setting="WINSServers"
$GetIPOptions=$objNetAdapter.WINSPrimaryServer
if $objNetAdapter.WINSSecondaryServer<>""
$GetIPOptions=$GetIPOptions + "," + $objNetAdapter.WINSSecondaryServer
endif
case 1
select
case $setting="DefaultGW" or $setting="DefaultGateway" or $setting="Gateway"
$setting="DefaultIPGateway"
case $setting="DNSServers"
$setting="DNSServerSearchOrder"
case $setting="StaticIP" or $setting="Static"
$setting="DHCPEnabled"
$toggle=1
endselect
$=execute("$" + "GetIPOptions=" + "$" + "objNetAdapter." + $setting)
select
case vartype($GetIPOptions)>=8192 ;array
$GetIPOptions=join($GetIPOptions,",")
case vartype($GetIPOptions)=11 ;boolean
if $GetIPOptions=0 - $toggle
$GetIPOptions="False"
else
$GetIPOptions="True"
endif
endselect
endselect
endif
Next
endfunction
;Function:
; EnumNetworkConnections()
;
;Author:
; Allen Powell
;
;Version:
; 2.0 2006/03/15 Complete Re-write (backward compatible)
; 1.0 2005/05/11 Original Version - Returned just the "Connection Name"
;
;Action:
; Enumerates/Lists the Network Connections names
;
;Syntax:
; EnumNetworkConnections(optional $mode, optional $remotepc)
;
;Parameters:
; $mode - (Optional) Numeric expression that is the sum of values below
; - 0 Connection Name (default)
; - 1 MACAddress
; - 2 Network Adapter Name
;
; $remotepc - (Optional) Remote Computer Name
;
;Returns:
; Array of Network Connection Names, optionally with MACAddress and/or Name of the Network Card
;
;Dependencies
; WMI with Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0 SP4 and later
; Tested with Kixtart 4.52 Beta
;Example:
;
;for each $nc in Enumnetworkconnections()
; ? $NC
;next
;
function EnumNetworkConnections(optional $mode,optional $remotepc)
dim $NCs[0],$objWMIService,$colItems,$objItem,$counter
if $remotepc=""
$remotepc="."
endif
$objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2")
if @error
exit @error
endif
$colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter where (MACAddress is not null) and
(NetConnectionID is not null)")
For each $objItem in $colItems
redim preserve $NCs[$counter]
$NCs[$counter]=$objItem.NetConnectionID
if $mode & 1
$NCs[$counter]=$NCs[$counter] + "," + $objItem.MACAddress
endif
if $mode & 2
$NCs[$counter]=$NCs[$counter] + "," + $objItem.Name
endif
$counter=$counter + 1
Next
$EnumNetworkConnections=$NCs
endfunction