Windows dhcp server powershell

Настройка DHCP сервера с помощью PowerShell

В RSAT для Windows 10 отсутствует привычная консоль управления DHCP сервером (Dhcpmgmt.msc), а вместо нее предлагается использовать эквивалентные команды Powershell. Тем самым нас аккуратно подводят к мысли, что, скорее всего, и в грядущем релизе Windows Server 2016 конфигурация DHCP сервера будет осуществляться только из командной строки PowerShell. В этой статье мы познакомимся с основными командами PowerShell в Windows Server 2012 R2, необходимых для настройки и управления DHCP сервером.

Для возможности управления DHCP сервером нам понадобится загрузить модуль PoSh DHCPServer. По-умолчанию этот модуль в PowerShell не загружен. В том случае, если конфигурирование выполняется непосредственно с DHCP сервера, установить роль DHCP со средствами управления нужно так:

Add-WindowsFeature -Name DHCP –IncludeManagementTools

Если подразумевается управление удаленным DHCP сервером, нужно установить соответствующий компонент RSAT:

Перед использованием, нужно импортировать DHCP модуль в сессию:

Посмотрим, сколько командлетов доступно в рамках этого модуля:

(Get-Command -Module DHCPServer).count

Целых 121! Данные командлеты могут быть использования для управления DHCP серверами на Windows Server 2008 /R2 и Windows Server 2012 / R2.

Выведем список авторизованных DHCP серверов в Active Directory:

Get-DhcpServerInDC
Получим список DHCP областей на выбранном сервере:

Get-DhcpServerv4Scope –ComputerName msk-dhcp1

Если нужно показать большее количество полей (Delay, Description, Name и т.д.)

Get-DhcpServerv4Scope –ComputerName msk-dhcp1| FL *

Если нужно отобразить данные о IPv6 областях:

Получим настройки для конкретной области:

Get-DhcpServerv4Scope –ComputerName msk-dhcp1–ScopeID Helpdesk 10.10.1.0

Для авторизации нового DHCP сервера в домене Active Directory:

Add-DhcpServerInDC -DnsName msk-dhcp2.winitpro.ru -IPAddress 10.0.1.21

Создадим новую область с диапазоном адресов с 10.10.1.1 до 10.10.1.254:

Add-DHCPServerv4Scope -EndRange 10.10.1.254 -Name Office -StartRange 10.10.1.1 -SubnetMask 255.255.255.0 -State Active –ComputerName msk-dhcp1

Настроим следующие параметры DHCP сервера: DNS сервер, домен и адрес маршрутизатора

Set-DHCPServerv4OptionValue -ComputerName msk-dhcp1 -DnsServer 10.10.1.5 -DnsDomain winitpro.ru -Router 10.10.1.1

Вывести список настроенных опций DHCP сервера можно так:

Get-DHCPServerv4OptionValue -ComputerName msk-dhcp1 | Format-List

Настроим опции области:

Set-DHCPServerv4OptionValue -ComputerName msk-dhcp1 -ScopeId 10.10.1.0 -DnsServer 10.10.1.6 -DnsDomain winitpro.ru -Router 10.10.1.1

Выведем список настроенных параметров зоны:

Get-DHCPServerv4OptionValue -ComputerName msk-dhcp1 -ScopeId 10.10.1.0 | Format-List

Исключим диапазон адресов с 10.10.1.1 по 10.10.1.40 из раздаваемых адресов для определенной области:

Add-Dhcpserverv4ExclusionRange -ComputerName msk-dhcp1 -ScopeId 10.10.1.0 -StartRange 10.10.1.1 -EndRange 10.10.1.40

Выведем текущий список арендованных адресов для области 10.10.1.0

Get-DHCPServerv4Lease -ScopeId 10.25.4.0 -ComputerName msk-dhcp1

Создадим резервацию для клиента с IP адресом 10.10.1.88:

Get-DhcpServerv4Lease -ComputerName msk-dhcp1 -IPAddress 10.10.1.88| Add-DhcpServerv4Reservation -ComputerName msk-dhcp1

Можно массово зарезервировать IP адреса для компьютеров по списку из csv файла. Для этого создайте текстовый файл в формате:

ScopeId,IPAddress,Name,ClientId,Description
10.10.1.0,10.10.1.88,Client1,ba-ab-5c-3d-4e-6f,Reservation PC-msk-s1
10.10.1.0,10.10.1.89,Client2,ba-ab-5c-5d-2e-3f,Reservation PC-msk-s2

Сохраните файл с именем c:\dhcp\DHCPReservations.csv и запустите следующую команду, которая импортирует данные из csv файла и создаст резервации для клиентов:

Import-Csv –Path c:\dhcp\DHCPReservations.csv | Add-DhcpServerv4Reservation -ComputerName msk-dhcp1

Отключить область на DHCP сервере:

Set-DhcpServerv4Scope -ComputerName msk-dhcp1-ScopeId 10.10.1.0-State InActive

Set-DhcpServerv4Scope -ComputerName msk-dhcp1-ScopeId 10.10.1.0-State Active

Удалить область с DHCP сервера:

Remove-DHCPServerv4Scope -ComputerName msk-dhcp1-ScopeId 10.10.1.0 -Force

Возможно получить статистику DHCP сервера (количество областей, резерваций, процент использования адресов и пр.).

Get-DhcpServerv4Statistics -ComputerName msk-dhcp1:

Аналогичная информация для конкретной области может быть получена с помощью командлета Get-DhcpServerv4ScopeStatistics.

Опции для DHCP сервера добавляется так (к примеру, WPAD):

Читайте также:  Службы windows защищенное хранилище

Add-DhcpServerv4OptionDefinition -ComputerName msk-dhcp1-Name WPAD -OptionId 252 -Type String

Конфигурацию DHCP сервера можно экспортировать в указанный XML файл с помощью команды:

Export-DHCPServer -ComputerName msk-dhcp1 -File C:\dhcp\dhcp-export.xml

В дальнейшем эти настройки DHCP сервера можно импортировать на другой DHCP сервер (к примеру, с именем msk-dhcp2):

Dhcp Server

This reference provides cmdlet descriptions and syntax for all Dynamic Host Configuration Protocol (DHCP) server service-specific cmdlets. It lists the cmdlets in alphabetical order based on the verb at the beginning of the cmdlet.

DhcpServer

Adds the computer that runs the DHCP server service to the list of authorized DHCP server services in Active Directory.

Adds security groups to a DHCP server.

Adds an IPv4 vendor or user class to the DHCP server service.

Adds a range of excluded IP addresses for an IPv4 scope.

Adds an IPv4 failover relationship on the DHCP server service.

Adds one or more specified scopes to the failover relationship.

Adds a MAC address filter to the DHCP server service.

Adds a new IPv4 address lease in the DHCP server service.

Adds a range of addresses to exclude from a multicast scope.

Adds a multicast scope on the DHCP server.

Adds a DHCPv4 option definition on the DHCP server service.

Adds a new policy either at the server level or at the scope level.

Adds an IP range to an existing policy at the scope level.

Reserves an IPv4 address in the scope for a client.

Adds an IPv4 scope on the DHCP server service.

Adds scopes to a superscope.

Adds an IPv6 vendor or user class to the DHCP server service.

Sets the range of IPv6 addresses to exclude from an IPv6 scope.

Adds an IPv6 address lease to the DHCP server service.

Adds a DHCPv6 option definition to a DHCP server service.

Adds an IPv6 Reservation to an IPv6 prefix or scope.

Adds an IPv6 scope to the DHCP server service with the specified parameters.

Backs up the DHCP database of DHCP server service.

Exports the DHCP server service configuration and lease data.

Gets the configuration parameters related to the audit log of the DHCP server service.

Gets the configuration parameters related to the database of the DHCP server service.

Gets an account that the DHCP Server service uses to register or deregister client records on a DNS server.

Retrieves the list of authorized computers that run the DHCP server service from Active Directory.

Gets the configuration parameters of the database of the DHCP server service.

Gets the IPv4 interfaces on the computer to which the DHCP server service is bound.

Retrieves an IPv4 vendor or user class from the DHCP server service.

Gets the DNS settings configured on the DHCP server service for a specific scope, reservation, or server level.

Returns the IPv4 address ranges excluded from the specified scope IDs.

Gets the failover relationships configured on the DHCP server service for the specific failover relationship name.

Gets MAC addresses from the allow list or the deny list on the DHCP server service.

Gets the enabled state of the allow filter list and deny filter list set on the DHCP server service.

Читайте также:  Не открываются документы word windows 10

Gets one or more free or unassigned IPv4 Addresses from the specified scope.

Gets one or more lease records from the DHCP server service.

Retrieves the exclusion range for a specified multicast scope.

Retrieves multicast leases for a specified scope name.

Gets multicast scope objects.

Gets multicast scope statistics.

Gets the DHCPv4 option definition for the specified option IDs.

Returns the IPv4 option values for IPv4 options at the server, scope, or reservation level.

Gets policies at the server level or the scope level.

Gets IP address ranges from a policy in the specified scope.

Gets IPv4 reservations for IP addresses or client IDs.

Returns the IPv4 scope configuration of the specified scopes.

Gets the IPv4 scope statistics corresponding to the IPv4 scope IDs specified for a DHCP server service.

Gets DHCP server service statistics for IPv4.

Gets the configuration for the specified superscope.

Returns statistics for superscopes.

Returns the IPv6 interfaces to which the DHCP server service is bound.

Gets the IPv6 vendor or user class from the DHCP server service.

Gets the DNS settings configured on the DHCP server service for a specific scope, reservation, or server-wide.

Gets the IPv6 address ranges excluded from the specified IPv6 subnet prefix.

Gets one or more free or unassigned IPv6 addresses from the specified scope.

Gets IPv6 lease records from the DHCP server service.

Gets the option definition for the option identified by the option ID.

Returns the IPv6 option values for one or more IPv6 options either for a specific reserved IP, scope or, server level.

Returns the reserved IPv6 addresses on the DHCP server service.

Gets the scope information for the specified IPv6 prefixes on the DHCP server service.

Gets the IPv6 prefix statistics for an IPv6 prefix specified for a DHCP server service.

Gets IPv6 subnet prefixes which have stateless clients and the number of addresses in use in each subnet.

Gets the properties of IPv6 stateless store for an IPv6 subnet.

Gets the DHCP server service statistics for IPv6.

Gets the version of the DHCP server service.

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

Replicates scope configuration between failover partner DHCP server services.

Removes the credential that the DHCP Server service uses to register or deregister client records on a DNS server.

Deletes the specified DHCP server service from the list of authorized DHCP server services in Active Directory.

Deletes the IPv4 vendor class or user class from a DHCP server service.

Deletes a range of IPv4 addresses that were previously excluded from an IPv4 scope.

Removes failover relationships.

Removes the specified scopes from the failover relationship.

Deletes a MAC address or MAC address pattern from the allow list or the deny list of the DHCP server service.

Deletes IPv4 address lease records from the DHCP server service.

Removes a range of addresses previously excluded from a multicast scope.

Removes multicast scope leases for a multicast scope or IP address.

Читайте также:  Windows 10 для ноутбука lenovo ideapad 310 15isk

Removes multicast scopes.

Deletes IPv4 option definitions from a DHCP server service.

Deletes one or more IPv4 option values at the server, scope or reservation level, either for the standard IPv4 options or for the specified vendor or user class.

Deletes IPv4 policies at the server level or the scope level.

Deletes an IP range from an existing policy at the scope level.

Deletes the IPv4 reservation from the specified scope.

Deletes the specified IPv4 scopes from the DHCP server service.

Removes scopes from a superscope.

Deletes the specified IPv6 vendor class or user class from a DHCP server service.

Deletes a range of IPv6 addresses previously excluded from an IPv6 scope.

Deletes IPv6 lease records from the DHCP server service.

Deletes IPv6 option definitions from the DHCP server service.

Deletes DHCPv6 option values set at the reservation level, scope level, or server level, for the standard IPv6 options or for a vendor class.

Deletes IPv6 reservations from the specified scope.

Deletes the IPv6 scopes from the DHCP server service corresponding to the specified prefixes.

Renames a superscope.

Reconciles inconsistent lease records in the DHCP database.

Restores the database of the DHCP server service from the specified location.

Sets the DHCP server service audit log configuration on the DHCP server service that runs on the computer.

Modifies one or more configuration parameters of the database of the DHCP server service.

Sets credentials that the DHCP Server service uses to register or deregister client records on a DNS server.

Sets server level configuration parameters for the DHCP server service.

Sets the binding state of an IPv4 interface for the DHCP server service that runs on a computer.

Modifies an IPv4 vendor class or user class on the DHCP server service with the specified parameters.

Configures how the DHCP server service updates the DNS server with the client-related information.

Modifies the properties of an existing failover relationship.

Sets the enabled state for the allow and the deny MAC address filter lists on the DHCP server service.

Modifies the properties of a multicast scope.

Modifies the properties of an IPv4 option definition.

Sets an IPv4 option value at the server, scope, or reservation level.

Sets the properties of a policy at the server level or at the specified scope level.

Modifies the properties of an IPv4 reservation.

Sets the properties of an existing IPv4 scope on the DHCP server service.

Sets the binding state for an IPv6 interface of the DHCP server service.

Modifies the properties of an IPv6 vendor or user class on the DHCP server service.

Configures how the DHCP server service updates the DNS server with the client-related information.

Modifies the properties of a DHCPv6 option definition.

Sets an IPv6 option value at the server, scope, or reservation level.

Modifies the properties of the specified IPv6 reservation.

Modifies the properties of the IPv6 scope on the DHCP server service.

Sets properties of IPv6 stateless store for an IPv6 prefix.

Оцените статью