Загрузка данных


$Server = "RUKLGDC01.pcmarus.loc"

$ScopeIds = @(
    "10.182.150.0",
    "10.182.151.0",
    "10.182.152.0",
    "10.182.153.0",
    "10.182.154.0",
    "10.182.155.0"
)

foreach ($ScopeId in $ScopeIds) {

    Write-Host "`n==================================================" -ForegroundColor Cyan
    Write-Host "Scope: $ScopeId" -ForegroundColor Cyan
    Write-Host "==================================================" -ForegroundColor Cyan

    Write-Host "`n=== Статистика ===" -ForegroundColor Yellow
    Get-DhcpServerv4ScopeStatistics `
        -ComputerName $Server `
        -ScopeId $ScopeId |
    Format-List ScopeId,PercentageInUse,InUse,Free,Reserved,Pending

    Write-Host "`n=== Состояния аренд ===" -ForegroundColor Yellow
    Get-DhcpServerv4Lease `
        -ComputerName $Server `
        -ScopeId $ScopeId |
    Group-Object AddressState |
    Select-Object Name,Count |
    Format-Table -AutoSize

    Write-Host "`n=== Резервации ===" -ForegroundColor Yellow
    Get-DhcpServerv4Reservation `
        -ComputerName $Server `
        -ScopeId $ScopeId `
        -ErrorAction SilentlyContinue |
    Format-Table IPAddress,ClientId,Name,Description -AutoSize

    Write-Host "`n=== Последние аренды ===" -ForegroundColor Yellow
    Get-DhcpServerv4Lease `
        -ComputerName $Server `
        -ScopeId $ScopeId |
    Sort-Object LeaseExpiryTime |
    Select-Object IPAddress,HostName,ClientId,AddressState,LeaseExpiryTime |
    Format-Table -AutoSize
}