I want to get a "first logon" script going that will auto create VLANs and set static IP's based on a CSV file that contains all the IP addresses for every workstation in the company (after a re-image is complete).
I plan to start with looking into the suggestions we already have on a previous post here. However, the previous post is for a single adapter, and each of our systems consist of 5 different VLANs:
VLAN1
VLAN2
VLAN3
VLAN4
VLAN5
Also, my CSV will only need IP and Subnet mask. No need for gateway or DNS.
My question is, what would be the best way to structure the information in the CSV file to get this to work best? The CSV will need the info for the 5 seperate VLANs:
Example CSV:
computerName,AdapterName,IPAddress,SubnetMask,
TestMachine2,VLAN1,10.1.0.1,255.255.255.0,
TestMachine2,VLAN2,10.2.0.1,255.255.255.0,
TestMachine2,VLAN3,10.3.0.1,255.255.255.0,
TestMachine2,VLAN4,10.4.0.1,255.255.255.0,
TestMachine2,VLAN5,10.5.0.1,255.255.255.0,
TestMachine3,VLAN1,10.1.0.1,255.255.255.0,
TestMachine3,VLAN2,10.2.0.1,255.255.255.0,
TestMachine3,VLAN3,10.3.0.1,255.255.255.0,
TestMachine3,VLAN4,10.4.0.1,255.255.255.0,
TestMachine3,VLAN5,10.5.0.1,255.255.255.0,
Does the above look OK?
The current script is only the creation and renaming part of the VLAN Adapters, but it would be grand if anyone is able to help me build the remaining section which applies the IP Addresses based on the CSV file:
# Import Intel Commandlets
Import-Module -Name "C:\Program Files\Intel\Wired Networking\IntelNetCmdlets\IntelNetCmdlets"
# Create VLANs
$IntelNic=Get-IntelNetAdapter -Name "Intel(R) Ethernet Converged Network Adapter X550-T2"
$adapterVLANs=(
@{"VLAN"="1"; "Name"="VLAN1"},
@{"VLAN"="2"; "Name"="VLAN2"},
@{"VLAN"="3"; "Name"="VLAN3"},
@{"VLAN"="4"; "Name"="VLAN4"},
@{"VLAN"="5"; "Name"="VLAN5"}
)
foreach($adapter in $adapterVLANs)
{
Add-IntelNetVLAN -Parent $intelnic -VLANID $adapter["VLAN"]
Set-IntelNetVLAN -Parent $intelnic -VLANID $adapter["VLAN"] -NewVLANName "$($adapter["VLAN"]) - $($adapter["Name"])"
}
Sleep -Seconds 10
# Rename Adapters
Rename-NetAdapter -Name "Ethernet 3" -NewName "MAIN"
Rename-NetAdapter -Name "Ethernet 5" -NewName "VLAN1"
Rename-NetAdapter -Name "Ethernet 6" -NewName "VLAN2"
Rename-NetAdapter -Name "Ethernet 7" -NewName "VLAN3"
Rename-NetAdapter -Name "Ethernet 8" -NewName "VLAN4"
Rename-NetAdapter -Name "Ethernet 9" -NewName "VLAN5"
# Rename Adapters
Next part goes here... set IP address for each VLAN based on what is read from the CSV file
Any help much appreciated. Thanks.