Home > DevOps > Transfer DHCP Server configuration to another server with PowerShell

Transfer DHCP Server configuration to another server with PowerShell

I had a call the other day

export

Get-DhcpServerv4Scope | ForEach-Object {
$ScopeID = $_.ScopeId
    Export-DhcpServer -File "C:\IPM1\Scope-$scopeId.xml" -ScopeId $ScopeID
}

import

$item = Get-ChildItem -Path C:\IPM1 | Where {$_.Name -like "*.xml"}

foreach($i in $Item) {
    Import-Dhcpserver -File $i.FullName -BackupPath C:\Windows\System32\dhcp\backup
}