Created
May 22, 2013 02:53
-
-
Save glallen01/5624949 to your computer and use it in GitHub Desktop.
Create Multiple DHCP reservations with Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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