Registered: 2002-05-09
Posts: 129
Loc: The Netherlands
Hello,
I'm busy making a scripts which has to check the NIC status in a laptop. This is because sometimes when a user pulls out the NIC cable when the laptop is still shutting down the nic gets disabled. Which result in a call to the helpdesk and a lot of tests to see what is wrong.
This part of code i tried to check the status of the NIC but this is not returned. The description is working but not the status.
code:
? @KIX $i = 0 For Each $Device In WMIQuery("DeviceID","Win32_NetworkAdapter",$Laptop) $Status = WMIQuery("Status","Win32_NetworkAdapter",$Laptop)[$i] $Description = WMIQuery("Description","Win32_NetworkAdapter",$Laptop)[$i] ? $Description+Chr(9)+$Status $i = 1+$i Next
[ 23. July 2003, 10:46: Message edited by: Raceeend ]
If you want to check if a network cable has been removed, you may want to check NetworkAdapterConfiguration instead.
Break On $strComputer = "." $objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48) For each $objItem in $colItems $aIPAddress = $objItem.IPAddress For Each $Address in $aIPAddress If Len($Address) $Address ? EndIf Next Next
If the cable is pulled, no device will have an IPAddress.
Registered: 2002-05-09
Posts: 129
Loc: The Netherlands
It's not working
code:
? @KIX $i = 0 For Each $Device In WMIQuery("DeviceID","Win32_NetworkAdapter","@WKSTA") $Status = WMIQuery("ConnectionState","Win32_NetWorkConnection")[$i] ;if $Status = "Connected" $Description = WMIQuery("Description","Win32_NetworkAdapter","@WKSTA")[$i] ? $Description+Chr(9)+$Status ;+Chr(9)+$i ;EndIf $i = 1+$i Next
output: on a Win2k pro station (laptop) 4.20 Infrared Port Connected Infrared Modem Port Disconnected RAS Async Adapter Disconnected WAN Miniport (L2TP) Disconnected WAN Miniport (PPTP) Connected Direct Parallel WAN Miniport (IP) Intel(R) PRO/100 VE Network Connection Deterministic Network Enhancer Miniport Deterministic Network Enhancer Miniport