Microsoft Dhcp Export Reservations With Mac
Posted By admin On 03.04.202018-4-16 The Netsh.exe utility in Windows Server 2003 contains two commands that are available for Dynamic Host Configuration Protocol (DHCP): export and import.You can use these commands to selectively export and import DHCP scopes.
Let's say that you have two DHCP servers, both serving addresses to different parts of the same scope for resiliency. You would probably want to make sure that reservations are duplicated on both servers. Here is a fairly simple way to copy the reservations.
- Netsh dhcp server scope dumpdump.txt. Replace with the IP address or the name of the DHCP server that you are copying from. Replace with the IP address of the scope that the reservations are in. In the DHCP console, you will see this in the tree on the left side of the screen.
- I had difficulty recently with our DHCP reservations, namely i coudnt export the MAC addresses included in the reservation and the mmc was only allowing very limited as I could only export the ip address and the FQDN of the computer owner.
I have tested this on Windows Server 2008 R2. It should be consistent in later versions of Windows.
Please note that you should be able to do this from any workstation as long as you have the appropriate rights. I did it from the servers themselves.
3 Steps total
Step 1: Copy the configuration
On the server you are copying from, run the command:
netsh dhcp server scope dump>dump.txt
Replace with the IP address or the name of the DHCP server that you are copying from.
Replace with the IP address of the scope that the reservations are in. In the DHCP console, you will see this in the tree on the left side of the screen.
This will create a text file (dump.txt) with the entire configuration of the server.
Step 2: Modify the text file
You will find the reservation commands at the bottom of the file in the format:
Dhcp Server Server.domain.com Scope 192.168.0.0 Add reservedip 192.168.0.250 <> 'DeviceName.domain.com' ' 'BOTH'
Copy just these commands to another text file. On each line, replace the server name or IP address with the name or IP address of the destination server. Leave the rest of the line the same.
Step 3: Run the text file
On the destination DHCP server, run the following command:
NETSH exec <>
This will import all of the reservations quickly.
References
- Microsoft DHCP Team BLOG
19 Comments
- Macemolan Oct 14, 2013 at 06:20pm
that's good to know! Thanks for sharing! I am sure I will end up using this
- MaceErikN Oct 23, 2013 at 01:52pm
I have a split scope configured and was curious about how to do this. Thanks!
- Jalapenoperbauer Jun 18, 2014 at 07:31am
Worked like a charm! Used it for getting reservations of Server 2003 and onto 2012R2. Thanks!
- PoblanoDanny6547 Jul 28, 2014 at 09:15pm
Where was this when I was migrating DHCP from 03 to 2012 6 months ago?!?! Works like a champ.
- Anaheimtreyrowzie Nov 17, 2014 at 07:09am
Thanks! Great time saver. BTW, the server's IP address work just as well as fully qualified name.
- PimientoWPC Roger Keast Dec 1, 2014 at 10:48pm
Thanks! This worked really well. One caveat I found - Check mac addresses that start with leading zeros. Not sure what happened on mine, but all my hw addys that started with 00 were truncated. It happened with all my Meraki wireless units and I had a few come back up after power cycles with the wrong IP addresses. Fixing the hw addys in DHCP afterwards was my fix.
- Pimientotoddpainter Dec 9, 2014 at 07:22pm
I just used this, and it worked without any issues. None of my macs started with 00, so I didn't run into that issue.
- ChipotleKO3457 Feb 27, 2015 at 05:28pm
Thanks for the commands. This worked for what I needed.
- PimientoKnaphKnaph Mar 9, 2015 at 11:31am
Hi Alan,
Great tip. I used this to expand a range by 'exporting', then editing the 'Add iprange' values. Then I cleared out the old DHCP scope and re-imported the edited file.
I can see how this would also be a great way to set up a slit scope by changing the same value and saving two different files for 'importing' into different servers.
Many thanks.
Steve B - Sonoraichayan Sep 15, 2015 at 08:49am
Great post, does any one know how this deals if there are duplicates? as some reservations were added on both servers but some are not. Also do we need to include the last lines 'Set Name protection enable' and 'Set DnsConfig'
- TabascoAlanK Sep 15, 2015 at 01:16pm
It's been a while since I've done this, but if I recall, it will replace duplicates.
- Anaheim1337_Geek Dec 28, 2015 at 07:05pm
Just wanted to mention here as well that if you get the nebulous error 'the command needs a valid scope ip address' you have to run the netsh exec command as an admin and it works properly. At least this was my experience with Win2012 R2
- SerranoJoel Porozynski Jun 16, 2016 at 09:44pm
So on the modified file, do I only keep the reservation lines? Do I need any other parts from above or below the reservations?
- CayenneManyHats08 Oct 5, 2017 at 01:39pm
That is great. I did not know that was so easy to accomplish. thank you,
- SerranoCambridgeport90 Oct 13, 2017 at 06:40pm
There is a new powershell module for this now; Netsh is no longer necessary.
- 1
- 2
Syntax
Description
The Export-DhcpServer cmdlet exports the Dynamic Host Configuration Protocol (DHCP) server service configuration, and optionally lease data, to the specified file.
If you specify the ScopeId or Prefix parameter,only the specified scopes or prefixes and all server level settings are exported.
If you specify neither ScopeId or Prefix, the DHCP server service configuration including all scopes, v4 and v6 and optionally the lease data, is exported.
If you specify the Leases parameter, the lease data is also exported in addition to configuration data.
Examples
Example 1: Export all DHCP configurations
Here are a few things we're already aware of:.In the VB Editor, if you click the object dropdown in the code window (for example the ThisWorkbook object), an error occurs.In some languages, the labels in the Preferences dialog are showing incorrect text. Microsoft excel for mac 16.23. 2 update notes.Bug fixes.Fixed several crashes.Typing and navigating could become slow if the VBA project contained user-defined functions and the formula builder pane was displayed.Excel would crash when loading some VBA add-ins.In some languages, setting a date format using VBA with a format containing 'yyyy' would enter 'yyyy' into the cell rather than the year.Known issuesThis is still considered a preview of the next major version, so we expect to see some issues. Please provide feedback about any issues you find by clicking the smiley-face button near the top corner of the application window.
This example exports all of the DHCP server, DHCPv4 and DHCPv6, configurations including scopes present on the DHCP server service to the specified export file in XML file format.
Example 2: Export the specified scopes
This example exports the scopes 10.10.10.0 and 10.20.20.0 present on the DHCP server service to the specified export file in XML file format.The DHCPv4 server level configuration is also exported to the specified file.
Example 3: Export specified scopes and their leases
This example exports the scopes 10.10.10.0 and 10.20.20.0 present on the DHCP server service to the specified export file in XML file format.This includes the leases present in the specified scopes.The DHCPv4 server level configuration will also be exported to the specified file.
Example 4: Export the specified scopes and DHCPv6 server level configuration
This example exports the specified scopes 2001:4898:7020:1020:: and 2001:4898:7020:1030:: present on the DHCP server service to the specified export file in XML file format.The DHCPv6 server level configuration is also exported to the specified file.
Example 5: Export the specified scopes, their leases, and DHCPv6 server level configuration
This example exports the specified scopes 2001:4898:7020:1020:: and 2001:4898:7020:1030:: present on the DHCP server service to the specified export file in XML file format.This includes the leases present in the specified scopes.The DHCP server level configuration is also exported to the specified file.
Example 6: Export scopes specified in a file
This example exports a list of scopes specified in file named ScopeList.txt to the specified export file in XML file format.The Import-Csv cmdlet returns the objects that contain the scope IDs output and pipes the objects into this cmdlet, which exports the specified scopes.
The file named ScopeList.txt should contain the following format:
ScopeId
10.10.10.0
Help and support for the Microsoft Outlook app on PC, Mac, and mobile. Find how-to articles, watch video tutorials, and get the most out of your Office 365 subscription. Outlook for Mac Help - Most popular topics Set up Outlook. Update your password. Sync your Google account with Outlook. My message doesn't send. Turn off Focused Inbox. Import email messages and contacts. Archive messages. Add holidays to your Outlook. Help with microsoft outlook for mac.
20.20.20.0
30.30.30.0
Parameters
Runs the cmdlet in a remote session or on a remote computer.Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet.The default is the current session on the local computer.
Type: | CimSession |
Aliases: | Session |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the DNS name, or IPv4 or IPv6 address, of the target computer that runs the DHCP server service.
Type: | String |
Aliases: | Cn |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the name of the file to which the data will be exported.If the complete file path is not specified, the file is created in the current working directory.If there is an existing file by the same name, an error is returned.
Type: | String |
Position: | 0 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies that, if there is a file that already exists with the specified name, the file is overwritten.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies that IP address leases is also exported.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies one or more subnet prefixes of the IPv6 scopes which are exported.
Type: | IPAddress[] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
Specifies the scope identifiers, in IPv4 address format, which are exported.
Type: | IPAddress[] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Microsoft.Management.Infrastructure.CimInstance#root/Microsoft/Windows/DHCP/DhcpServerv4Scope
The Microsoft.Management.Infrastructure.CimInstance
object is a wrapper class that displays Windows Management Instrumentation (WMI) objects.The path after the pound sign (#
) provides the namespace and class name for the underlying WMI object.
Microsoft.Management.Infrastructure.CimInstance#root/Microsoft/Windows/DHCP/DhcpServerv6Scope
The Microsoft.Management.Infrastructure.CimInstance
object is a wrapper class that displays Windows Management Instrumentation (WMI) objects.The path after the pound sign (#
) provides the namespace and class name for the underlying WMI object.
Microsoft Dhcp Export Reservations With Mac Office
Outputs
None