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

How can I script changes to my servers NIC config

Status
Not open for further replies.

gbeetle

MIS
Dec 16, 2004
1
US
I'm working on setting up a script that performs all the steps that we are performing on our servers manually. One of the things I can't figure out is how to script a way to set all the NIC's on a server to 100MB Full Duplex. Has anyone every done this? Is there a VBScript method I can use, or even a registry change? Thanks in advance for your help.
 
I just went digging a bit and this looks like a tall order, but I may be a little doom and gloom. The good new is the settings is deffinetly in the registry, the bad news is you will probably have to enumerate all of HKLM\System\currentcontrolset\control\class to find which key is actaully the one you need. All I can find from a cursory exam is how to set the default, which if you reboot after the script runs should be near enough to actually setting it. I sure there is an actual setting for it hiding somewhere, you may want one of those differential registry analyzers in order to find it though. Run it, change the setting, then run it again and it will tell you what key changed. You can do this with VB or kix, but it might not be a super fast process for it to actually run. If you're familiar with enumerating registry keys it should be pretty easy for you to whip up though.
 
Actually, what you want to do is check this out with WMI.

Code:
'==========================================================================
'
' NAME: <filename>
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 12/16/2004
'
' COMMENT: <comment>
'
'==========================================================================

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
For Each objItem in colItems
    Report = Report & vbCrLf & "AdapterType: " & objItem.AdapterType
    Report = Report & vbCrLf & "AdapterTypeId: " & objItem.AdapterTypeId
    Report = Report & vbCrLf & "AutoSense: " & objItem.AutoSense
    Report = Report & vbCrLf & "Availability: " & objItem.Availability
    Report = Report & vbCrLf & "Caption: " & objItem.Caption
    Report = Report & vbCrLf & "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
    Report = Report & vbCrLf & "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
    Report = Report & vbCrLf & "CreationClassName: " & objItem.CreationClassName
    Report = Report & vbCrLf & "Description: " & objItem.Description
    Report = Report & vbCrLf & "DeviceID: " & objItem.DeviceID
    Report = Report & vbCrLf & "ErrorCleared: " & objItem.ErrorCleared
    Report = Report & vbCrLf & "ErrorDescription: " & objItem.ErrorDescription
    Report = Report & vbCrLf & "Index: " & objItem.Index
    Report = Report & vbCrLf & "InstallDate: " & objItem.InstallDate
    Report = Report & vbCrLf & "Installed: " & objItem.Installed
    Report = Report & vbCrLf & "LastErrorCode: " & objItem.LastErrorCode
    Report = Report & vbCrLf & "MACAddress: " & objItem.MACAddress
    Report = Report & vbCrLf & "Manufacturer: " & objItem.Manufacturer
    Report = Report & vbCrLf & "MaxNumberControlled: " & objItem.MaxNumberControlled
    Report = Report & vbCrLf & "MaxSpeed: " & objItem.MaxSpeed
    Report = Report & vbCrLf & "Name: " & objItem.Name
    Report = Report & vbCrLf & "NetConnectionID: " & objItem.NetConnectionID
    Report = Report & vbCrLf & "NetConnectionStatus: " & objItem.NetConnectionStatus
    Report = Report & vbCrLf & "NetworkAddresses: " & objItem.NetworkAddresses
    Report = Report & vbCrLf & "PermanentAddress: " & objItem.PermanentAddress
    Report = Report & vbCrLf & "PNPDeviceID: " & objItem.PNPDeviceID
    Report = Report & vbCrLf & "PowerManagementCapabilities: " & objItem.PowerManagementCapabilities
    Report = Report & vbCrLf & "PowerManagementSupported: " & objItem.PowerManagementSupported
    Report = Report & vbCrLf & "ProductName: " & objItem.ProductName
    Report = Report & vbCrLf & "ServiceName: " & objItem.ServiceName
    Report = Report & vbCrLf & "Speed: " & objItem.Speed
    Report = Report & vbCrLf & "Status: " & objItem.Status
    Report = Report & vbCrLf & "StatusInfo: " & objItem.StatusInfo
    Report = Report & vbCrLf & "SystemCreationClassName: " & objItem.SystemCreationClassName
    Report = Report & vbCrLf & "SystemName: " & objItem.SystemName
    Report = Report & vbCrLf & "TimeOfLastReset: " & objItem.TimeOfLastReset
Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile ("nicConfig.txt", ForWriting)
ts.write Report
set ts = nothing
set fso = nothing

That should show you how your card is configured.

Take a look at for some samples on setting some values.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
I didn't open the post but thanks for the script - it's been really useful!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top