Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 1259
Благодарности: 861

Профиль | Отправить PM | Цитировать


Код: Выделить весь код
function IsIpAddressInRange {
param(
        [string] $ipAddress,
        [string] $fromAddress,
        [string] $toAddress
    )

    $ip = [system.net.ipaddress]::Parse($ipAddress).GetAddressBytes()
    [array]::Reverse($ip)
    $ip = [system.BitConverter]::ToUInt32($ip, 0)

    $from = [system.net.ipaddress]::Parse($fromAddress).GetAddressBytes()
    [array]::Reverse($from)
    $from = [system.BitConverter]::ToUInt32($from, 0)

    $to = [system.net.ipaddress]::Parse($toAddress).GetAddressBytes()
    [array]::Reverse($to)
    $to = [system.BitConverter]::ToUInt32($to, 0)

    $from -le $ip -and $ip -le $to
}

$IPAddress="10.9.9.200"
Get-DhcpServerv4Scope | Where {IsIpAddressInRange $IPAddress $_.StartRange $_.EndRange}
Если нет областей больше /24,то можно:
Код: Выделить весь код
Get-DhcpServerv4Scope -ScopeId ("10.9.9.200" -replace "\d+$","0")
Это сообщение посчитали полезным следующие участники:

Отправлено: 09:04, 12-10-2016 | #2