Skip to content

Instantly share code, notes, and snippets.

@glallen01
Created May 22, 2013 02:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glallen01/5624949 to your computer and use it in GitHub Desktop.
Save glallen01/5624949 to your computer and use it in GitHub Desktop.
Create Multiple DHCP reservations with Powershell
$DHCPserver="172.16.32.2"
$DHCPscope="10.0.0.0"
$output="C:\netsh-out.cmd"
$csv=Import-CSV "MAC_LIST.csv"
# csv file MUST have the following header columns
# MAC,IP,NAME
# 12345678abcd,10.0.0.20,SITEWKCDR01
$csv | %{
add-content -Encoding ASCII -Path $output
-Value "netsh dhcp server $DHCPserver scope $DHCPscope `
add reservedip $($_.IP) $($_.MAC) $($_.NAME) $($_.NAME) BOTH"
}
# this script takes "MAC_LIST.csv" as input, and creates
# "netsh-out.cmd" as output. Run the "netsh-out.cmd" script
# to create reservations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment