Announcement

Collapse
No announcement yet.

How to show network card speed/duplex setting in CLI

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to show network card speed/duplex setting in CLI

    Some of our client workstation have been hard coded to 100 full, instead of Auto long time ago by our previous network admin. I would like to change it back to Auto. It would be a pain to walk to 500 machine individually.

    Is there a way that I can retrive the NIC setting with a command or registry key?

  • #2
    Re: How to show network card speed/duplex setting in CLI

    I hope all 500 machines does not have to much different NIC models?

    You can find, for the interfaces, the specific hardware model setting-names and -values in the #### subkeys under this registrykey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}

    Create a ini file (SpdDplx.ini) for the setting per NIC you like:
    eg:
    Code:
    [14e4165d]
    ;Broadcom 570x Gigabit Integrated Controller
    ;ComponentId=pci\ven_14e4&dev_165d&subsys_865d1028
    RequestedMediaType=0
    
    [10B79805]
    ;3Com EtherLink Server 10/100 PCI (3C980C-TXM)
    ;ComponentId=PCI\VEN_10b7&DEV_9805
    Duplexmode=FullDuplex
    media=AUTO
    Create you own ini file by exploring the registrykey I mensioned.
    The code between [square brackets] must be 8 characters long. The script needs this unique model-ID for finding the right NIC to modify in the correct registry-subkey. The id is lifted from the value of the "ComponentId" item. It is the first 4charachters after "pci\ven_" and the first 4 characters after "&dev_". The next line starting with ; is the value of DriverDesc, next line starting with ; is the complete ComponentId item. And next are/is lines without ";" these are the setting going to written to the registry.

    Read more:
    http://www.pcreview.co.uk/forums/sho....php?t=2278296


    Then this wil be the script:
    Code:
    'SetNICSpeed.vbs
    'URL: http://forums.petri.com/showthread.php?t=14875
    'URL: http://www.pcreview.co.uk/forums/showthread.php?t=2278296
    '==========
    
    Const HKLM = &H80000002
    
    inputFile = "spddplx.ini"
    
    strComputer = "."
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
                      strComputer & "\root\default:StdRegProv")
    
    sNetPath = "System\Currentcontrolset\Control\Class\{4D36E972-E325-11CE-BFC1-08002be10318}"
    
    SetSpeedDuplex()
    
    Sub SetSpeedDuplex()
        Dim section, strValue, subkey, arrSubKeys
    
        objRegistry.EnumKey HKLM, sNetPath, arrSubKeys
        For Each subkey In arrSubKeys
            objRegistry.GetStringvalue HKLM, sNetPath & "\" & subkey, "ComponentId", strValue
            If not isnull(strValue) then
               strValue = lcase(strValue)
               section = left(replace(replace(strValue, "pci\ven_", ""), "&dev_",""), 8)
               ReadDuplexIni section, subkey
            End if
        Next
    End Sub
    
    Sub ReadDuplexIni(section, subkey)
        Dim ini, line, file
    
        file = chr(34)& inputFile &chr(34)
        If fso.FileExists(file) Then
           Set ini = fso.OpenTextFile(file, 1, False)
           Do While ini.AtEndOfStream = False
              line = ini.ReadLine
              If lcase(line) = "[" & lcase(section) & "]" Then
                 line = ini.ReadLine
                 Do While Left(line, 1) <> "["
                    If left(line, 1) <> ";" and len(line) > 0 Then
                       UpdateReg line, subkey
                    End If
                    If ini.AtEndOfStream Then Exit Do
                    line = ini.ReadLine
                 Loop
                 Exit Do
              End If
           Loop
        ini.Close
        End If
    End Sub
    
    Sub UpdateReg(line, subkey)
        Dim lRC
    
        key = split(line, "=")
        lRC=objRegistry.SetStringValue(HKLM, sNetPath & "\" & subkey, key(0), key(1))
    End Sub
    In the script you must enter the right full sharedpath to the SpdDplx.ini inputFile, so you will be able to use the script as a computer_startup_script in a GPO.

    \Rem
    Last edited by Rems; 29th March 2007, 09:44. Reason: made the script better readable

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: How to show network card speed/duplex setting in CLI

      Thank you so much. That's really helpful.

      Comment


      • #4
        Re: How to show network card speed/duplex setting in CLI

        Glad to hear.
        I hope that there is not to much difference between the NIC on the 500 workstations.



        Maybe some useful information about the SpdDplx.ini file;

        The [8-character] ID is nesserary to reconize the vendors-id and the unique NIC-model-id to connect to the the right subkey and change the vendor specific values for that specific card in that subkey.

        It appears to me (if I look at the examples in the link), that the card model-ID in the '8-character-ID' only is nessesary to tell a difference between newer and older NICs from vendor 3Com. One model is using other registry items and values then the other.
        Other vendors seems always have been using a same named, and only one, item to set the speed.

        So if in your case each vendor of the NIC on the workstations uses everytime the same item-name in the registry for all of its card models to set the speed value, then you be able to shorten the 8-character ID to a 3 character ID.
        Then istead of the 2nd-line ";value of 'DriverDesc'" you can use the ";value of 'ProviderName'". And the 3rd-line just static information: ";LAN NIC". (the lines starting with ; are for you informationj only, these lines will be skipped by the script)

        The bennefit of shorten the total ID to only the vendors unique ID is that now you have to make only one entry per vendor in the ini file, instead of per different NIC-model. That can save you a lot of time to write the ini file and collecting all the information from each computer.

        When you do change the ID format in the ini file then you must! also adjust the script line: 27
        section = left(replace(replace(strValue, "pci\ven_", ""), "&dev_",""), 8)
        To:
        section = left(replace(replace(strValue, "pci\ven_", ""), "&dev_",""), 3)


        \Rem

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment


        • #5
          Hi there,

          So I have over 8000 machines to change from 100 Full to Auto. We are using SCCM to manage the machines. We have tried the script but having issues

          I have the following in the .ini file

          [14e4167b]
          ;Broadcom
          ;ComponentId=pci\ven_14e4&dev_167b
          SpeedDuplex=0

          In the registry SpeedDuplex is named as *SpeedDuplex but added *SpeedDuplex or SpeedDuplex is not changing the value from 4 to 0.

          I have used both the following

          section = left(replace(replace(strValue, "pci\ven_", ""), "&dev_",""),
          To:
          section = left(replace(replace(strValue, "pci\ven_", ""), "&dev_",""), 3)

          Comment

          Working...
          X