Using Powershell to configure IP addressing by importing CSV

Copper Contributor

Hi All,

 

New to powershell and just getting my feet wet.  I've been tasked with trying to automate an image process for a vendor as much as possible for a retail environment.  Rather then rely on the vendor to configure static IP addressing and 4 DNS entries for each machine they image for us I was able to create a small CMD script that allows them to type in the IP, Subnet, Gateway etc etc.  However I was then challenged to see if there was a way to build it in such a way where I import data from a csv, select the store number and terminal number then then it would import without needing to still enter in the IP address and reduce error.  Or better yet, read the %COMPUTERNAME% and parse out the store number and terminal number as they are all unique and assigned.

2 Replies
You can create a CSV with those values and import them if the CSV has a Computername and on the same line all the other values. You could do a $list=import-csv .\pathtoCSV\filename.csv and use a $list | where-object ComputerName -eq nameofcomputer. I need more information on how you do this already. Does the CMD script also set anything, or is it just for gathering information?

@Harm_Veenstra 

 

Currently in my cmd file i'm using set /p to have IP, subnet, and gateway entered and then using netsh to set the IP based on those values.  i'm thne using wmic nicconfig to set the 4 DNS records.  It works and it might be fine, but if I can simply import the csv with all the values preset, then pick a specific record to tie into what the static configuration might be then it could leave out some human error.

 

the CSV would have STORE, GATEWAY, SUBNET, REG1, REG2, REG3, etc etc.  computername would already be set an unique per machine as XXXXXRYYY where X= 5 digit store and Y = 3 digit register (001, 002, etc)