Network Config

See and set adapter properties


NetConfig.ps1

Description

 

Uses list of target computers. Reports on, and optionally starts, Automatic service not running.

Version

 

1.0

Last Mod

 

January 2011

Client

 

NA

Language

 

PowerShell

Finish Level

 

Smooth

Download

Description

Script reads input text files for a list of computers to process and a variety of network interface parameters. Then, based on input parameters and command line arguments, the various properties are reported and modified.

Configuration

One input text file lists target computers, one per line. A second input text file lists IP parameters and processing options. Path to both input files and output log file can be modified by the command line. Default values:

  •  Input files path:  Current folder
  •  Server list file:  ServerList.txt
  •  IP information file:  IpInfo.txt
  •  Log file path:  Current folder
  •  Log file name:  NetConfig.txt
  •  Overwrite log of same name:  Yes

Usage information available with -? command line argument.

      NetConfig - Version 1.0, January 2011

      Usage:

      NetConfig [ Optional Parameters ]

      -InputPath <FolderWithInputFiles>

      -ServerFile <ServerFileName>

      -IpInfoFile <ExcludeServiceFileName>

      -LogBase <BaseNameForLogFile>

      -LogPath <FolderForLogFile>

      -Date switch

      -Time switch

      -Append switch

      -AdapterName <Local Area Connection>

      -ShowAdapters switch

      -ShowAdaptersNull switch

      -ChangeAdapterName switch

      -HaltWmiFail switch

      -ReportOnly switch

      -SetDnsServers switch

      -SetDomain switch

      -SetGateway switch

      -UpdateIpInfo switch

      -Append switch

      -Append switch

      -Append switch

              ServerFile: List of target computers, one entry per line.

              IpInfoFile: List of network interface properties.  See details in sample file.

                 LogBase: Base of log filename, optionally with date/time stamp.

                 LogPath: Folder for log file.

                    Date: Include date in log filename.

                    Time: Include time in log filename.

                  Append: Append to existing log file.  Not valid with [Time]

             AdapterName: Target adapter name.'Local Area Connection' by default.

            ShowAdapters: Display specified adapter information, then exit.

          ShowAdaptersIP: Display all IP enabled adapters.

         ShowAdaptersAll: Display all adapters.

       ChangeAdapterName: Change adapter name from 'AdapterName' to 'NewAdapterName'

             HaltWmiFail: Abort if fail to connect to any target computer.

              ReportOnly: Do not change any values.

           SetDnsServers: Modify DNS Servers to specified value.

               SetDomain: Modify DNS Domain name to specified value.

              SetGateway: Modify default gateway settings to specified value.

            UpdateIpInfo: Enable preceding three switches.

         WriteIpInfoFile: Create a sample IP Information file.

You may add a date and/or time component to the log file name with the –Date and –Time command line switches. You may append to an existing log file with the –Append command line switch, which is logically incompatible with the –Time switch.

Most of the switch options are self-explanatory.

Changing adapter properties is based on the name of the adapter, the -AdapterName value.  One way to start with the script is to display adapter names and then use the -ChangeAdapterName argument to standardize adapter names.

ShowAdapters – When any of the ShowAdapters options are enabled, the script will display adapter information and exit without making any changes. When used by itself, ShowAdapters will display information only for the adapter with the name specified by the AdapterName argument.

ShowAdaptersIP – Will display adapter information for all IP-enabled interfaces.

ShowAdaptersAll – Will display adapter information for all interfaces, including non-IP and null.

UpdateIpInfo – The script can update three values for the specified interface name; the DNS Domain Name, DNS Servers and the Default Gateway. Each of these has a corresponding "Set" switch for individual activation. The UpdateIpInfo switch enables all three at once. The settings will be made to the interface specified as AdapterName, and corresponding data value, for each switch, must be declared in the IpInfo file.

WriteIpInfoFile – This switch will generate a sample IpInfo.txt file in the same folder as the script. The file contains explanations and can be customized for specific use.

Execution

Run from anywhere. Target systems must have WMI enabled and remotely accessible. To modify settings, the script must be elevated to fun with Administrative permissions.

Default configuration values discussed above. Modify these with command line arguments. Include parameters with their name and value separated by a space. Several arguments, such as –Date and –Time are switches, entered without corresponding values.

Examples:

      NetConfig –Date

          Will include YYYYMMDD in the log file name

      NetConfig –Time will include HH:MM.SS.ssss

          Will include a time string in the log file name.

      NetConfig – Append

          Will append to an existing log file or create a new one if none exists.

      NetConfig –Append -Date

          Running this command repeatedly, will create a new log for each day, with all activity for one day contained in its respective file.

Arguments may be entered in any order or combination except the following mutually exclusive combinations.

      Both –Append and –Time

          Since the –Time parameter will produce a unique file name, based on milliseconds, it is virtually impossible to append to an existing file of the same name.

      ReportOnly and any –SetXXX or -ChangeAdapter

          The ReportOnly option will override and arguments for setting changes.

Documentation

Just this.

 

IpInfoFile

Following is the content of the sample file.

This file holds name/value pairs used by the script that reads this file.

The name is separated from the value by a single tab.

Data lines begin with a colon.

All other lines are ignored.

All entries are optional, but appropriate entries must exist for

intended operations, as determined by command line arguments.

Order of entries in file is not important.

If the same :Name is specified more than once (bad practice)

last entry wins. No error raised.

There are three settable values: Gateway, DNS Domain and DNS Servers.

The gateways value is (potentially) a list of IP V4 addresses.

If multiple values, use comma-separated list without spaces.

Enabling this change is controlled with the -SetGateway argument switch.

:Gateway 192.168.1.1

Changing this value is controlled with the -SetDomain argument switch.

:DnsDomain Home.Hom

DNS Server list is comma-separated with no spaces.

Changing this value is controlled with the -SetDnsServers argument switch.

:DnsServers 192.168.1.5,192.168.1.10

Interface Name is the string value displayed in the network properties

applet, "Local Area Connection" by Windows default.

This vaue determines which interface the script examines for information.

If using the -ChangeAdapterName feature, this is the "Old" or existing name.

:AdapterName Primary

If changing adapter names, the "AdapterName" above is the existing name.

If found, it will be changed to the "NewAdapterName."

This is controlled with the -ChangeAdapterName argument switch.

:NewAdapterName Primary

The following parameters correspond to command line arguments.

Values specified on command line override values (not) set in this file.

These are "switches," meaning that, if present, their value is "TRUE."

For information, the switches are shown here preceded with an asterisk (*).

Change the asterisk to a colon (:) to enable the switch.

*LogAppend

*LogDate

*LogTime

*ChangeAdapterName

*HaltWmiFail

*ReportOnly

*SetDnsServers

*SetDomain

*SetGateway

*ShowAdapters

*ShowAdaptersAll

*UpdateIpInfo

 

Download


Home Up