|
See and set adapter properties |
NetConfig.ps1
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:
Usage information available with -? command line argument. NetConfig - Version 1.0, January 2011 Usage: NetConfig [ Optional Parameters ]
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
IpInfoFile Following is the content of the sample file.
|