Link to home
Start Free TrialLog in
Avatar of *** Hopeleonie ***
*** Hopeleonie ***Flag for Switzerland

asked on

How can I save DHCP Scopes and Reservations in PowerShell?

Hi

Is someday having a PowerShell Script to save all existing DHCP Scopes & Reservations to a CSV file?

Script 1:
#Save Path
$path = "C:\temp"
PS C:\> Get-DhcpServerv4Scope -ComputerName dc.test.com | Export-Csv "$path\Clients2.csv" -Encoding UTF8 -Force -NoTypeInformation

Open in new window


Script 2:
#Save Path
$path = "C:\temp"
PS C:\> Get-DhcpServerv4Scope -ComputerName dc.test.com | Get-DhcpServerv4Reservation -ComputerName dc.test.com Export-Csv "$path\Clients2.csv" -Encoding UTF8 -Force -NoTypeInformation

Open in new window


Both scripts must work on a Server 2003 (not R2). We must migrate that old Server to a new 2012 R2.

Many thanks in advance.
Avatar of manuverhaegen
manuverhaegen

Export-DhcpServer -ComputerName dhcpserver.server.com -File C:\temp\dhcpexport.xml
Avatar of Todd Nelson
I suppose you are migrating DHCP from Windows 2003 to Windows 2012 R2, correct?

These are great references...

Migrate Active Directory from Windows Server 2003 to 2012 R2: Migrate DHCP, Remove Server 2003, and Raise Functional Levels ... https://www.petri.com/windows-server-2003-dhcp-migration-2012

Step-By-Step: Migrating DHCP From Windows Server 2003 to 2012 R2 ... https://blogs.technet.microsoft.com/canitpro/2014/11/25/step-by-step-migrating-dhcp-from-windows-server-2003-to-2012-r2/
Avatar of *** Hopeleonie ***

ASKER

@Todd Nelson
Yes, Windows 2003 to Windows 2012 R2.
Hi hopeleonie,

Unfortunately, there is no easy PowerShell way to migrate a Windows 2003 DHCP Server to Windows 2012 (R2) DHCP Server.
Your best chance is to backup the database from the internal Backup function of DHCP Server and then use the migration tools to export IP Data (PowerShell tools) to be used from the target DHCP Server.
You may find all the relevant info here:

1) Migrate DHCP Server to Windows Server 2012 R2
2) Migrate IP Configuration to Windows Server 2012

It is imperative to read #1 first and create your action plan or task list if you prefer. Then read #2 when the time of it comes through #1 (you will see references of it in there).

Good luck!
Thanks to all again.
Hi Qlemo

the technician who will migrate told that it may work if we install a higher PowerShell version on the DHCP Server.
Is that information false?
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Qlemo
So we have no way to save DHCP Scopes and Reservations to a CSV or Txt file?
Not that I know of. Your best bet is the Migration Toolkit as linked to above.
@Qlemo
Thanks I will try the Migration Toolkit.

We also found this command:
netsh dhcp server \\ServerName dump all > C:\backup_DHCP_servernamedump.txt

But I don't know if this will work. The customer needs a CSV or Text file before the migration    :-(
For documentation purposes the dump should work. I don't know if it is complete and compatible with 2012 ...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The author must check all the answers and after testing them and getting the required result, then the points must be assigned to the relative correct answers.
My comments were only supporting, and should not be considered as answers. Maybe http:#a41829680 might receive a (very small) share of points for confirming an info as false.

George Simos has posted what I would expect to be your answer regarding the CSV/text file in http:#a41830086 . It's much better than the netsh dump,

I'm not clear about whether the migration stuff is relevant for you, but would assume so, and then http:#a41822395 and http:#a41822490 should be accepted too.
Thanks to all again.
@hopeleonie: Thank you for accepting my answer! I hope you will solve your issues.

@Qlemo: Thanks for the clarifications and the supporting answers, you were right to the point for the PowerShell versions supported by Windows 2003/XP!
For the migration stuff I answered because it was a two part question. I think I saw another question from hopeleonie for the dhcp migration after this one in my mail alerts.