Import-DhcpServer

Import-DhcpServer is accessible with the help of DHCPServer module. To configure DHCPServer, go through this link.

Synopsis

Imports the Dynamic Host Configuration Protocol (DHCP) server service configuration, and optionally lease data, from the specified file.

Description

The Import-DhcpServer cmdlet imports the Dynamic Host Configuration Protocol (DHCP) server service configuration, and optionally lease data, from the specified file. This cmdlet is only supported for the DHCP server services running on Windows Server 2012.

If either the ScopeId or the Prefix parameter, or the ScopeId and Prefix parameters are specified, then only the specified scopes or prefixes will be imported.

If neither the ScopeId nor the Prefix parameter is specified, then all of the configurations contained in the file, and optionally any lease data, will be imported.

If the Leases parameter is specified, then the lease data in the specified file is imported in addition to configuration data.

If the ScopeOverWrite parameter is specified and the scope being imported exists on the destination server, then the scope on the target DHCP server service will be overwritten. If this parameter is not specified and the scope being imported exists on the destination DHCP server service, then a warning message is displayed and the import will proceed to process the next scope being imported.

If the ServerConfigOnly parameter is specified, then only the server level configuration will be imported on the destination DHCP server service. If the file specified contains any scope information, then the same information will not be imported on the destination DHCP server service.

Parameters

-BackupPath

Specifies the path where DHCP server database is backed up before it makes any configuration changes as part of the import operation.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-CimSession

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

-ComputerName

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

-Confirm

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

-File

Specifies the name of the file from which the data is imported. If a complete file path is not specified, the file is read from the current working directory.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Leases

Specifies that the lease data is also imported.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Prefix

Specifies the subnet prefixes of IPv6 scopes which are imported.

Type:IPAddress[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ScopeId

Specifies the scope identifiers (IDs), in IPv4 address format, which must be imported.

Type:IPAddress[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ScopeOverwrite

Specifies that, if the scope being imported exists on the target server, the scope on the destination DHCP server service are overwritten.

If this parameter is not specified and the scope being imported exists on the destination DHCP server service, a warning message is displayed and import will proceed to process the next scope being imported.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ServerConfigOnly

Specifies that only server level configuration is imported on the destination DHCP server service. If the file specified contains any scope information, the same is not imported on the destination DHCP server service.

Both DHCPv4 and DHCPv6 server level configurations is imported.

The server level configuration includes of (both v4 and v6):

  • Class definitions.
  • Option definitions.
  • Option values.
  • Server level Policies (DHCPv4).
  • MAC address filters (DHCPv4).
  • Other Server Properties (ConflictDetectionAttempts, DHCPv6 stateless store).
Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

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

Syntax

Import-DhcpServer [-File] <String> [-BackupPath] <String> [-ScopeId <IPAddress[]>] [-Prefix <IPAddress[]>] [-ScopeOverwrite] [-Leases] [-ServerConfigOnly] [-Force] [-ComputerName <String>] [-CimSession <CimSession>] [-WhatIf] [-Confirm] [<CommonParameters>]

—————EXAMPLE 1—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\
This example imports the configuration data in the specified file onto the DHCP server service running one the computer named dhcpsrv.TOSSolution.com. The file can contain DHCPv4 as well as DHCPv6 configuration data.

—————EXAMPLE 2—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -Leases
This example imports the configuration and lease data in the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. The file can contain DHCPv4 as well as DHCPv6 configuration data.

—————EXAMPLE 3—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -ScopeId 192.168.10.0,192.168.20.0
This example imports the configuration data for scopes 192.168.10.0 and 192.168.20.0 from the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. If the export file contains scopes besides 192.168.10.0 and 192.168.20.0, then those scopes are ignored. The DHCPv4 server level configuration data, if present in the export file, is also imported onto the DHCP server service.

—————EXAMPLE 4—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -ScopeId 192.168.10.0,192.168.20.0 -Leases
This example imports the configuration and lease data for scopes 192.168.10.0 and 192.168.20.0 from the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. If the export file contains scopes besides 192.168.10.0 and 192.168.20.0, then those scopes are ignored. The DHCPv4 server level configuration data, if present in the export file, is also imported onto the DHCP server service.

—————EXAMPLE 5—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -ScopeId 192.168.10.0,192.168.20.0 -Leases -ScopeOverwrite
This example imports the configuration and lease data for scopes 192.168.10.0 and 192.168.20.0 from the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. If the export file contains scopes besides 192.168.10.0 and 192.168.20.0, then those scopes are ignored. The DHCPv4 server level configuration data, if present in the export file, is also imported onto the server. If the scopes 192.168.10.0 and 192.168.20.0 are already present on the DHCP server service running one the computer named dhcpsrv.TOSSolution.com, then the scopes are deleted and recreated from the data in the export file.

—————EXAMPLE 6—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -ServerConfigOnly
This example imports only the server level configuration data in the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. Any scope configuration data, if present in the file, is ignored.

—————EXAMPLE 7—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -Prefix fe80:d9b9:a75a:4a8f::,fe80:d9b9:a75a:4a9f::
This example imports the configuration data for scopes fe80:d9b9:a75a:4a8f:: and fe80:d9b9:a75a:4a9f:: from the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. If the export file contains scopes besides fe80:d9b9:a75a:4a8f:: and fe80:d9b9:a75a:4a8f::, then those scopes are ignored. The DHCPv6 server level configuration data, if present in the export file, is also imported onto the DHCP server service.

—————EXAMPLE 8—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -Prefix fe80:d9b9:a75a:4a8f::,fe80:d9b9:a75a:4a9f:: -Leases
This example imports the configuration and lease data for scopes fe80:d9b9:a75a:4a8f:: and fe80:d9b9:a75a:4a9f:: from the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. If the export file contains scopes besides fe80:d9b9:a75a:4a8f:: and fe80:d9b9:a75a:4a9f::, then those scopes are ignored. The DHCPv6 server level configuration data, if present in the export file, is also imported onto the DHCP server service.

—————EXAMPLE 9—————
PS C:>Import-DhcpServer -ComputerName dhcpsrv.TOSSolution.com -File C:\dhcp\dhcpexport.xml -BackupPath D:\dhcpbackup\ -Prefix fe80:d9b9:a75a:4a8f::,fe80:d9b9:a75a:4a9f:: -Leases -ScopeOverwrite
This example imports the configuration and lease data for scopes fe80:d9b9:a75a:4a8f:: and fe80:d9b9:a75a:4a9f:: from the specified file onto the DHCP server service running on the computer named dhcpsrv.TOSSolution.com. If the export file contains scopes besides fe80:d9b9:a75a:4a8f:: and fe80:d9b9:a75a:4a9f::, then those scopes are ignored. The DHCPv6 server level configuration data, if present in the export file, is also imported onto the DHCP server service. If the scopes fe80:d9b9:a75a:4a8f:: and fe80:d9b9:a75a:4a9f:: are already present on the DHCP server service running on the computer named dhcpsrv.TOSSolution.com, then the scopes are deleted and recreated from the data in the export file.

You can check the Version, CommandType and Source of this cmdlet by giving below command.

Get-Command Import-DhcpServer

Get-Command Import-DhcpServer powershell script command cmdlet dhcp

You can also read about

  • Import-Csv
  • Backup-DhcpServer
  • Export-DhcpServer
  • Restore-DhcpServer

To know more PowerShell cmdlets(Commands) on DHCPServer click here

Click on this Link for an Single place where you get all the PowerShell cmdlet sorted based on the modules.

You can also refer other blogs on PowerShell at link

You can also refer other blogs on Microsoft at link

And also if you required any technology you want to learn, let us know below we will publish them in our site http://tossolution.com/

Like our page in Facebook and follow us for New technical information.

References are taken from Microsoft

Leave a Reply

Your email address will not be published. Required fields are marked *