Scripts to manage Client-Side Networking
Configuring ARP Queries to Use EtherSNAPConfiguring ARP Queries to Use Source RoutingDetermining a Computer's IP AddressConfiguring Dynamic DNS Registration for a Network AdapterConfiguring the DNS Domain for a Network AdapterConfiguring the DNS Server Search Order for a Network AdapterConfiguring the DNS Suffix Search Order for All Network AdaptersConfiguring the Forward Buffer Memory for All Network AdaptersConfiguring the Gateways for a Network AdapterConfiguring the IGMP Level for All Network AdaptersConfiguring the IP Connection Metric for a Network AdapterConfiguring the IPX Frame TypeConfiguring the IPX Virtual Network NumberConfiguring the Keep Alive Interval for all Network AdaptersConfiguring the MTU for all Network AdaptersConfiguring NetBIOS Use on a Network AdapterConfiguring the Number of Allowed Forward PacketsConfiguring a Static IP AddressConfiguring the WINS Server for a Network AdapterConfiguring Zero-Broadcast Use for All Network AdaptersEnabling Dead Gateway Detection for All Network AdaptersEnabling DHCPEnabling DNS on All Network AdaptersEnabling IPFilter Security on All Network AdaptersEnabling IPSec on a Network AdapterEnabling PMTU Discovery on all Network AdaptersEnabling WINS for All Network AdaptersEnumerating Network Adapter Configuration PropertiesEnumerating Network Adapter PropertiesEnumerating Network Client InformationEnumerating Network Login ProfilesEnumerating the Network Protocols on a ComputerPinging Multiple ComputersReleasing All DHCP LeasesReleasing the DHCP Lease for a Network AdapterRenewing the DHCP Lease for a Network AdapterRenewing All DHCP LeasesRetrieving IP4 Route Table InformationRetrieving Proxy Server InformationReturning IP Configuration DataSetting the Allowed Number of TCP ConnectionsSetting the Database Path for all Network AdaptersSetting the Default Time-to-Live for All Network AdaptersSetting Keep Alive Time for All Network AdaptersSetting the Maximum Allowed TCP Data RetransmissionsSetting PMTUBH Detection on All Network AdaptersSetting the TCP Window Size for All Network AdaptersSetting Urgent Pointer Use for All Network Adapters
Configures the network adapters on a computer to use 802.3 SNAP encoding for Ethernet packets.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetArpUseEtherSNAP(True)
Configures TCP/IP to always use source routing on all Token Ring networks.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetArpAlwaysSourceRoute(True)
Returns the IP address for each IP-enabled network adapter installed in a computer.
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
Configures dynamic DNS registration for a network adapter.
On Error Resume Next
Const FULL_DNS_REGISTRATION = True
Const DOMAIN_DNS_REGISTRATION = False
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
objNetCard.SetDynamicDNSRegistration _
FULL_DNS_REGISTRATION, DOMAIN_DNS_REGISTRATION
Next
Sets the DNS domain for a TCP/IP-bound network adapter.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
Wscript.Echo objNetCard.SetDNSDomain("fabrikam.com")
Next
Configures a TCP/IP-bound network adapter to use two DNS servers: 192.168.1.100 and 192.168.1.200. Note that even if a computer only uses one DNS server, the IP address of that server must still be passed to the SetDNSServerSearchOrder method as an array (in that case, an array with only one element).
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrDNSServers = Array("192.168.1.100", "192.168.1.200")
objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next
Configure a computer to use two DNS suffixes -- hr.fabrikam.com and research.fabrikam.com -- when performing DNS searches. Note that even if a computer uses only a single DNS suffix, this value must still be passed to the SetDNSSuffixSearchOrder method as an array (in that case, an array with a single element).
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes)
Configures the forward buffer memory for all network adapters on a computer. Values should be supplied in multiples of 256.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetForwardBufferMemory(74240)
Configures two gateways -- 102.168.1.100 and 192.168.1.200 -- for a network adapter. Note that even if only one gateway is specified, the IP address for that gateway must be passed as part of an array (in that case, an array with only a single element).
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrGateways = Array("192.168.1.100", "192.168.1.200")
objNetCard.SetGateways(arrGateways)
Next
Disables IGMP multicasting on a computer. To enable IP multicasting, pass the value 1 to the SetIGMPLevel method. Pass the value 2 to allow both IP and IGMP multicasting.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIGMPLevel(0)
Sets the IP connection metric for a network adapter to 100. Connection metrics can range from 1 to 9,999, with a default value of 1.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
objNetCard.SetIPConnectionMetric(100)
Next
Configures the IPX network number and frame type for a network adapter. In this case, the frame type is set to AUTO (value of 255). Because the frame type is set to AUTO, the network number must be set to 0. Note that both the network number and the frame types must be passed as arrays, even if there is only a single element (for example, one frame type).
On Error Resume Next
Const AUTO = 255
Const NETWORK_NUMBER = 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrNetworkNumber = Array(NETWORK_NUMBER)
arrFrameTypes = Array(AUTO)
objNetCard.SetIPXFrameTypeNetworkPairs arrNetworkNumber, arrFrameTypes
Next
Sets the IPX internal network number of a computer to network number 5.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPXVirtualNetworkNumber(5)
Configures the keep alive interval for all network adapters on a computer to 300,00 milliseconds (5 minutes).
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetKeepAliveInterval(300000)
Configures the maximum transmission unit for all network adapters installed in a computer. Valid values range from a minimum of 68 bytes to the maximum number of bytes supported by the network.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetMTU(68)
Enables NetBIOS for a network adapter. To enable NetBIOS via DHCP, pass the value 0 to the SetTCPIPNetBIOS method (rather than the value 1). Pass the value 2 to disable NetBIOS.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
objNetCard.SetTCPIPNetBIOS(1)
Next
Configures the number of forward packets allocated to the router packet queue. Valid values range from 1 to 0xFFFFFFFE.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetNumForwardPackets(1)
Sets the IP address of a computer to 192.168.1.141, and sets the IP gateway to 192.168.1.100.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next
Sets the primary and secondary WINS server for a TCP/IP-bound network adapter.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
strPrimaryServer = "192.168.1.100"
strSecondaryServer = "192.168.1.200"
objNetCard.SetWINSServer strPrimaryServer, strSecondaryServer
Next
Configures a computer to use zero-broadcasts (0.0.0.0) rather than one-broadcasts (255.255.255.255). Zero-broadcasts are the default used on systems derived from BSD implementations.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPUseZeroBroadcast(True)
Configures all network adapters on a computer to automatically detect dead gateways.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDeadGWDetect(True)
Enables the DHCP client service on a computer. The computer will then use DHCP to obtain an IP address rather than use a static IP address.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Next
Enables DNS for all network adapters on a computer, configuring the host name to fabrikam1 and designating hr.fabrikam.com and research.fabrikam.com as DNS search order suffixes.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
strHostName = "fabrikam1"
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.EnableDNS strHostName, , , arrDNSSuffixes
Enables IP filter security for all the network adapters installed in a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.EnableIPFilterSec(True)
Enables IP security for a network adapter. In this script, all TCP and UDP ports as well as all IP protocols are allowed; hence the value 0 is passed to the EnableIPSec method in each case. If only specific ports or protocols are allowed, these should be passed in the form of arrays.
On Error Resume Next
Const ALLOW_ALL = 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrPermittedTCPPorts = Array(ALLOW_ALL)
arrPermittedUDPPorts = Array(ALLOW_ALL)
arrPermittedIPProtocols = Array(ALLOW_ALL)
objNetCard.EnableIPSec _
arrPermittedTCPPorts, arrPermittedUDPPorts, arrPermittedIPProtocols
Next
Enables a computer to automatically discover the maximum transmission unit on a network. To disable auto-discovery of the maximum transmission unit, pass the value False to the SetPMTUDiscovery method.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetPMTUDiscovery(True)
Enables WINS on all the network adapters installed in a computer.
On Error Resume Next
Const DNS_ENABLED_FOR_WINS_RESOLUTION = True
Const USE_LMHOST_FILE = False
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
errResult = objNetworkSettings.EnableWINS _
(DNS_ENABLED_FOR_WINS_RESOLUTION, USE_LMHOST_FILE)
Enumerates configuration information for all the network adapters installed on a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration")
For Each objItem in colItems
Wscript.Echo "ARP Always Source Route: " & objItem.ArpAlwaysSourceRoute
Wscript.Echo "ARP Use EtherSNAP: " & objItem.ArpUseEtherSNAP
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Database Path: " & objItem.DatabasePath
Wscript.Echo "Dead GW Detection Enabled: " & objItem.DeadGWDetectEnabled
Wscript.Echo "Default IP Gateway: " & objItem.DefaultIPGateway
Wscript.Echo "Default TOS: " & objItem.DefaultTOS
Wscript.Echo "Default TTL: " & objItem.DefaultTTL
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "DHCP Enabled: " & objItem.DHCPEnabled
Wscript.Echo "DHCP Lease Expires: " & objItem.DHCPLeaseExpires
Wscript.Echo "DHCP Lease Obtained: " & objItem.DHCPLeaseObtained
Wscript.Echo "DHCP Server: " & objItem.DHCPServer
Wscript.Echo "DNS Domain: " & objItem.DNSDomain
Wscript.Echo "DNS Domain Suffix Search Order: " & _
objItem.DNSDomainSuffixSearchOrder
Wscript.Echo "DNS Enabled For WINS Resolution: " & _
objItem.DNSEnabledForWINSResolution
Wscript.Echo "DNS Host Name: " & objItem.DNSHostName
Wscript.Echo "DNS Server Search Order: " & objItem.DNSServerSearchOrder
Wscript.Echo "Domain DNS Registration Enabled: " & _
objItem.DomainDNSRegistrationEnabled
Wscript.Echo "Forward Buffer Memory: " & objItem.ForwardBufferMemory
Wscript.Echo "Full DNS Registration Enabled: " & _
objItem.FullDNSRegistrationEnabled
Wscript.Echo "Gateway Cost Metric: " & objItem.GatewayCostMetric
Wscript.Echo "IGMP Level: " & objItem.IGMPLevel
Wscript.Echo "Index: " & objItem.Index
Wscript.Echo "IP Address: " & objItem.IPAddress
Wscript.Echo "IP Connection Metric: " & objItem.IPConnectionMetric
Wscript.Echo "IP Enabled: " & objItem.IPEnabled
Wscript.Echo "IP Filter Security Enabled: " & _
objItem.IPFilterSecurityEnabled
Wscript.Echo "IP Port Security Enabled: " & _
objItem.IPPortSecurityEnabled
Wscript.Echo "IPSec Permit IP Protocols: " & _
objItem.IPSecPermitIPProtocols
Wscript.Echo "IPSec Permit TCP Ports: " & objItem.IPSecPermitTCPPorts
Wscript.Echo "IPSec Permit UDP Ports: " & objItem.IPSecPermitUDPPorts
Wscript.Echo "IP Subnet: " & objItem.IPSubnet
Wscript.Echo "IP Use Zero Broadcast: " & objItem.IPUseZeroBroadcast
Wscript.Echo "IPX Address: " & objItem.IPXAddress
Wscript.Echo "IPX Enabled: " & objItem.IPXEnabled
Wscript.Echo "IPX Frame Type: " & objItem.IPXFrameType
Wscript.Echo "IPX Media Type: " & objItem.IPXMediaType
Wscript.Echo "IPX Network Number: " & objItem.IPXNetworkNumber
Wscript.Echo "IPX Virtual Net Number: " & objItem.IPXVirtualNetNumber
Wscript.Echo "Keep Alive Interval: " & objItem.KeepAliveInterval
Wscript.Echo "Keep Alive Time: " & objItem.KeepAliveTime
Wscript.Echo "MAC Address: " & objItem.MACAddress
Wscript.Echo "MTU: " & objItem.MTU
Wscript.Echo "Number of Forward Packets: " & objItem.NumForwardPackets
Wscript.Echo "PMTUBH Detect Enabled: " & objItem.PMTUBHDetectEnabled
Wscript.Echo "PMTU Discovery Enabled: " & objItem.PMTUDiscoveryEnabled
Wscript.Echo "Service Name: " & objItem.ServiceName
Wscript.Echo "Setting ID: " & objItem.SettingID
Wscript.Echo "TCPIP Netbios Options: " & objItem.TcpipNetbiosOptions
Wscript.Echo "TCP Maximum Connect Retransmissions: " & _
objItem.TcpMaxConnectRetransmissions
Wscript.Echo "TCP Maximum Data Retransmissions: " & _
objItem.TcpMaxDataRetransmissions
Wscript.Echo "TCP NumC onnections: " & objItem.TcpNumConnections
Wscript.Echo "TCP Use RFC1122 Urgent Pointer: " & _
objItem.TcpUseRFC1122UrgentPointer
Wscript.Echo "TCP Window Size: " & objItem.TcpWindowSize
Wscript.Echo "WINS Enable LMHosts Lookup: " & _
objItem.WINSEnableLMHostsLookup
Wscript.Echo "WINS Host Lookup File: " & objItem.WINSHostLookupFile
Wscript.Echo "WINS Primary Server: " & objItem.WINSPrimaryServer
Wscript.Echo "WINS Scope ID: " & objItem.WINSScopeID
Wscript.Echo "WINS Secondary Server: " & objItem.WINSSecondaryServer
Next
Configures the network adapters on a computer to use 802.3 SNAP encoding for Ethernet packets.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetArpUseEtherSNAP(True)
Returns information about all the network clients installed on a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkClient")
For Each objItem in colItems
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo
Next
Returns network login information for all the users of a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile")
For Each objItem in colItems
dtmWMIDate = objItem.AccountExpires
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Account Expires: " & strReturn
Wscript.Echo "Authorization Flags: " & objItem.AuthorizationFlags
Wscript.Echo "Bad Password Count: " & objItem.BadPasswordCount
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "CodePage: " & objItem.CodePage
Wscript.Echo "Comment: " & objItem.Comment
Wscript.Echo "Country Code: " & objItem.CountryCode
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Flags: " & objItem.Flags
Wscript.Echo "Full Name: " & objItem.FullName
Wscript.Echo "Home Directory: " & objItem.HomeDirectory
Wscript.Echo "Home Directory Drive: " & objItem.HomeDirectoryDrive
dtmWMIDate = objItem.LastLogoff
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logoff: " & strReturn
dtmWMIDate = objItem.LastLogon
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logon: " & strReturn
Wscript.Echo "Logon Hours: " & objItem.LogonHours
Wscript.Echo "Logon Server: " & objItem.LogonServer
Wscript.Echo "Maximum Storage: " & objItem.MaximumStorage
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Number Of Logons: " & objItem.NumberOfLogons
Wscript.Echo "Password Age: " & objItem.PasswordAge
dtmWMIDate = objItem.PasswordExpires
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Password Expires: " & strReturn
Wscript.Echo "Primary Group ID: " & objItem.PrimaryGroupId
Wscript.Echo "Privileges: " & objItem.Privileges
Wscript.Echo "Profile: " & objItem.Profile
Wscript.Echo "Script Path: " & objItem.ScriptPath
Wscript.Echo "Setting ID: " & objItem.SettingID
Wscript.Echo "Units Per Week: " & objItem.UnitsPerWeek
Wscript.Echo "User Comment: " & objItem.UserComment
Wscript.Echo "User Id: " & objItem.UserId
Wscript.Echo "User Type: " & objItem.UserType
Wscript.Echo "Workstations: " & objItem.Workstations
Wscript.Echo
Next
Function WMIDateStringToDate(dtmWMIDate)
If Not IsNull(dtmWMIDate) Then
WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
& " " & Mid (dtmWMIDate, 9, 2) & ":" & _
Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, _
13, 2))
End If
End Function
Uses WMI to return information about all the network protocols installed on a computer.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkProtocol")
For Each objItem in colItems
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Connectionless Service: " & objItem.ConnectionlessService
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Guarantees Delivery: " & objItem.GuaranteesDelivery
Wscript.Echo "Guarantees Sequencing: " & objItem.GuaranteesSequencing
strInstallDate = WMIDateStringToDate(objItem.InstallDate)
Wscript.Echo "Install Date: " & strInstallDate
Wscript.Echo "Maximum Address Size: " & objItem.MaximumAddressSize
Wscript.Echo "Maximum Message Size: " & objItem.MaximumMessageSize
Wscript.Echo "Message Oriented: " & objItem.MessageOriented
Wscript.Echo "Minimum Address Size: " & objItem.MinimumAddressSize
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Pseudo Stream Oriented: " & objItem.PseudoStreamOriented
Wscript.Echo "Supports Broadcasting: " & objItem.SupportsBroadcasting
Wscript.Echo "Supports Connect Data: " & objItem.SupportsConnectData
Wscript.Echo "Supports Disconnect Data: " & objItem.SupportsDisconnectData
Wscript.Echo "Supports Encryption: " & objItem.SupportsEncryption
Wscript.Echo "Supports Expedited Data: " & objItem.SupportsExpeditedData
Wscript.Echo "Supports Fragmentation: " & objItem.SupportsFragmentation
Wscript.Echo "Supports Graceful Closing: " & _
objItem.SupportsGracefulClosing
Wscript.Echo "Supports Guaranteed Bandwidth: " & _
objItem.SupportsGuaranteedBandwidth
Wscript.Echo "Supports Multicasting: " & objItem.SupportsMulticasting
Wscript.Echo "Supports Quality of Service: " & _
objItem.SupportsQualityofService
Next
Function WMIDateStringToDate(dtmDate)
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & _
Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate, _
13, 2))
End Function
Uses the Win32_PingStatus class to ping 4 computers and identify the computers that could not be reached over the network. This script was contributed by Maxim Stepin of Microsoft.
strMachines = "atl-dc-01;atl-win2k-01;atl-nt4-01;atl-dc-02"
aMachines = split(strMachines, ";")
For Each machine in aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
WScript.Echo("machine " & machine & " is not reachable")
End If
Next
Next
Releases all the DHCP leases currently in use on a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.ReleaseDHCPLeaseAll()
Releases the DHCP leases for all TCP/IP-bound network adapters on a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
objNetCard.ReleaseDHCPLease()
Next
Renews the DHCP lease for each TCP/IP-bound network adapter in a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
objNetCard.RenewDHCPLease()
Next
Renews all the DHCP leases currently in use on a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.RenewDHCPLeaseAll()
Returns information about the IP route tables configured on a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_IP4RouteTable")
For Each objItem in colItems
Wscript.Echo "Age: " & objItem.Age
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Destination: " & objItem.Destination
Wscript.Echo "Information: " & objItem.Information
Wscript.Echo "Interface Index: " & objItem.InterfaceIndex
Wscript.Echo "Mask: " & objItem.Mask
Wscript.Echo "Metric 1: " & objItem.Metric1
Wscript.Echo "Metric 2: " & objItem.Metric2
Wscript.Echo "Metric 3: " & objItem.Metric3
Wscript.Echo "Metric 4: " & objItem.Metric4
Wscript.Echo "Metric 5: " & objItem.Metric5
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Next Hop: " & objItem.NextHop
Wscript.Echo "Protocol: " & objItem.Protocol
Wscript.Echo "Type: " & objItem.Type
Wscript.Echo
Next
Returns information about the Internet proxy server used by a computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Proxy")
For Each objItem in colItems
Wscript.Echo "Proxy Port Number: " & objItem.ProxyPortNumber
Wscript.Echo "Proxy Server: " & objItem.ProxyServer
Wscript.Echo "Server Name: " & objItem.ServerName
Wscript.Echo
Next
WMI script that returns configuration data similar to that returned by Ipconfig.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
n = 1
WScript.Echo
For Each objAdapter in colAdapters
WScript.Echo "Network Adapter " & n
WScript.Echo "================="
WScript.Echo " Description: " & objAdapter.Description
WScript.Echo " Physical (MAC) address: " & objAdapter.MACAddress
WScript.Echo " Host name: " & objAdapter.DNSHostName
If Not IsNull(objAdapter.IPAddress) Then
For i = 0 To UBound(objAdapter.IPAddress)
WScript.Echo " IP address: " & objAdapter.IPAddress(i)
Next
End If
If Not IsNull(objAdapter.IPSubnet) Then
For i = 0 To UBound(objAdapter.IPSubnet)
WScript.Echo " Subnet: " & objAdapter.IPSubnet(i)
Next
End If
If Not IsNull(objAdapter.DefaultIPGateway) Then
For i = 0 To UBound(objAdapter.DefaultIPGateway)
WScript.Echo " Default gateway: " & _
objAdapter.DefaultIPGateway(i)
Next
End If
WScript.Echo
WScript.Echo " DNS"
WScript.Echo " ---"
WScript.Echo " DNS servers in search order:"
If Not IsNull(objAdapter.DNSServerSearchOrder) Then
For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
WScript.Echo " " & objAdapter.DNSServerSearchOrder(i)
Next
End If
WScript.Echo " DNS domain: " & objAdapter.DNSDomain
If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
WScript.Echo " DNS suffix search list: " & _
objAdapter.DNSDomainSuffixSearchOrder(i)
Next
End If
WScript.Echo
WScript.Echo " DHCP"
WScript.Echo " ----"
WScript.Echo " DHCP enabled: " & objAdapter.DHCPEnabled
WScript.Echo " DHCP server: " & objAdapter.DHCPServer
If Not IsNull(objAdapter.DHCPLeaseObtained) Then
utcLeaseObtained = objAdapter.DHCPLeaseObtained
strLeaseObtained = WMIDateStringToDate(utcLeaseObtained)
Else
strLeaseObtained = ""
End If
WScript.Echo " DHCP lease obtained: " & strLeaseObtained
If Not IsNull(objAdapter.DHCPLeaseExpires) Then
utcLeaseExpires = objAdapter.DHCPLeaseExpires
strLeaseExpires = WMIDateStringToDate(utcLeaseExpires)
Else
strLeaseExpires = ""
End If
WScript.Echo " DHCP lease expires: " & strLeaseExpires
WScript.Echo
WScript.Echo " WINS"
WScript.Echo " ----"
WScript.Echo " Primary WINS server: " & objAdapter.WINSPrimaryServer
WScript.Echo " Secondary WINS server: " & objAdapter.WINSSecondaryServer
WScript.Echo
n = n + 1
Next
Function WMIDateStringToDate(utcDate)
WMIDateStringToDate = CDate(Mid(utcDate, 5, 2) & "/" & _
Mid(utcDate, 7, 2) & "/" & _
Left(utcDate, 4) & " " & _
Mid (utcDate, 9, 2) & ":" & _
Mid(utcDate, 11, 2) & ":" & _
Mid(utcDate, 13, 2))
End Function
Sets the maximum allowed number of simultaneously-opened TCP connections on a computer to 10.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPNumConnections(10)
Sets the path to the standard Internet database files (HOSTS, LMHOSTS, NETWORKS, PROTOCOLS) used by the Windows Sockets interface.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDatabasePath("c:\windows\system32\drivers\etc")
Sets the default time-to-live value in the header of outgoing IP packets to 64 this represents the number of routers an IP packet can pass through before being discarded). Valid TTL values range from 1 to 255, with a default value of 32.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDefaultTTL(64)
Configures the keep alive time for all network adapters on a computer to 300,000 milliseconds (5 minutes).
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetKeepAliveTime(300000)
Configures the number of times TCP will attempt to retransmit an individual data segment before abandoning the effort. Valid values range from 0 to 0xFFFFFFFF.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPMaxDataRetransmissions(10)
Enables the auto-discovery of black hole routers while determining the maximum transmission unit on a network. To disable auto-discovery of black hole routers, pass the value False to the SetPMTUBHDetect method.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetPMTUBHDetect(True)
Sets the TCP window size for all network adapters on a computer. Valid windows sizes range from 0 to 65,535 bytes.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPWindowSize(65535)
Configures a computer to use the RFC 1122 specification for urgent data rather than the mode used by Berkeley Software Design (BSD) derived systems. To use the BSD mode instead, pass the value False to the SetTcpRFC1122UrgentPointer method.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTcpUseRFC1122UrgentPointer(True)