dhcp Archives » nexxai.dev https://nexxai.dev/category/dhcp/ reminders for my future self Tue, 12 Jul 2022 16:29:25 +0000 en-CA hourly 1 https://wordpress.org/?v=6.5.5 Get all of the scopes and reservations from all activated DHCP servers in an Active Directory domain https://nexxai.dev/get-all-of-the-scopes-and-reservations-from-all-activated-dhcp-servers-in-an-active-directory-domain/?utm_source=rss&utm_medium=rss&utm_campaign=get-all-of-the-scopes-and-reservations-from-all-activated-dhcp-servers-in-an-active-directory-domain https://nexxai.dev/get-all-of-the-scopes-and-reservations-from-all-activated-dhcp-servers-in-an-active-directory-domain/#respond Tue, 12 Jul 2022 16:28:52 +0000 https://nexxai.dev/?p=316 The post Get all of the scopes and reservations from all activated DHCP servers in an Active Directory domain appeared first on nexxai.dev.

Today I had to get all of the scopes and reservations from all activated DHCP servers in our Active Directory domain. I whipped up this PowerShell script and figured someone else out there might need it. Please note that the Import-Excel package is required if you plan on using this script verbatim. It can be […]

]]>
The post Get all of the scopes and reservations from all activated DHCP servers in an Active Directory domain appeared first on nexxai.dev.

Today I had to get all of the scopes and reservations from all activated DHCP servers in our Active Directory domain. I whipped up this PowerShell script and figured someone else out there might need it. Please note that the Import-Excel package is required if you plan on using this script verbatim. It can be easily modified to not use it, however this is left as an exercise for the reader to implement.

Get-DhcpServerInDC | ForEach-Object {
    $DHCPServer = $_
    $hostName = $DHCPServer.DnsName
    Write-Host $hostName

    $scopes = Get-DhcpServerv4Scope -ComputerName $DHCPServer.DnsName | Where-Object { $_.State -eq "Active" } | Select-Object -Property Name, ScopeId, SubnetMask, StartRange, EndRange
    $scopes | Export-Excel ".\DHCPScopes.xlsx" -WorkSheetname "$($hostName)-Scopes" -AutoSize -AutoFilter

    ForEach ($scope in $scopes) {
        $reservations = Get-DhcpServerv4Reservation -ComputerName $DHCPServer.DnsName -ScopeId $scope.ScopeId | Select-Object -Property ClientId, Description, IPAddress, Name
        $reservations | Export-Excel ".\DHCPScopes.xlsx" -WorkSheetname "$($hostName)-Reservations" -AutoSize -AutoFilter 
    }
}
]]>
https://nexxai.dev/get-all-of-the-scopes-and-reservations-from-all-activated-dhcp-servers-in-an-active-directory-domain/feed/ 0