Powershell script for creating DHCP reservation batch file
/I've taken a handy script from Clint McGuire that creates batch files to aid in creating large groups of DHCP reservations and modified it a little bit to also insert the date in a sortable format at the start of the description field. Posting it here in case anyone else finds it useful:
##============================================================================== ##============================================================================== ## SCRIPT.........: Create-Reservation.ps1 ## AUTHOR.........: originally: Clint McGuire, modified by Seth H. Bokelman ## EMAIL..........: ## VERSION........: 2 ## DATE...........: 2012-04-020 ## COPYRIGHT......: 2011, Clint McGuire ## LICENSE........: ## REQUIREMENTS...: Powershell v2.0 ## ## DESCRIPTION....: Creates an CMD file to add reservations to DHCP. ## ## NOTES..........: Requires CSV file with 4 fields, IP, MAC, NAME and DESC ## ## CUSTOMIZE......: ##============================================================================== ## START ##============================================================================== # IP address of DHCP server $DHCPServer = "127.0.0.1" # DHCP Scope you'd like reservations created for $DHCPscope = "10.10.10.0" # Stores current date & time in a sortable format $date = Get-Date -format s # Name of output batch file $outputfile = "C:\DHCPreservations.cmd" # Assumes a CSV with four columns, MAC, IP, NAME and DESC. $ips = import-csv "C:\accesspoints.csv" $ips | %{ add-content -Encoding ASCII -Path $outputfile -Value "netsh Dhcp Server $DHCPServer Scope $DHCPScope Add reservedip $($_.IP) $($_.MAC) `"$($_.NAME)`" `"$date - $($_.DESC)`" `"DHCP`"" } ##============================================================================== ## END ##==============================================================================