Return to site

Powershell script to find available dhcp scope

broken image
broken image

Do NOT use this if you have devices that do not reply to ping, we will only kick off addresses that are older than your own set thresholds, Customize these to your environment. Working on a script to fully automate the deployment of a new 2012 box as a DC - with Windows updates configured, AD installed, Forest Created, DNS zones configured, DHCP scopes activated etc. The check’s we do are not very extensive, and you need to evaluate if you want to use this in your network, or look at a better solution such as increasing scope size.

broken image

Remember that a device does not lose its connection when you clear the scope of old addresses, but you could get duplicate IP’s if the device is still online. To do this we’re going to compare the age of old addresses, try to ping them and clear the lease if they do not respond.

broken image

a) Get-DhcpServerv4Scope ComputerName variable (write the output to a file) This will list the scopes of each DHCP server. 2) I then need it to loop through each DHCP server in this list (1a) and run. Checkip alternatives Anonymous-proxy-servers. 1) It will first run this command: a) Get-DhcpServerInDC (write the output to a file) This will list all DHCP servers in the domain. Now that we have the list of addresses, lets try to resolve the issue of a full scope. DHCP scopes: Check their utilization with this PowerShell script. $Leases = Get-DhcpServerv4Scope | Get-DhcpServerv4Lease foreach ( $lease in $leases | where-object

broken image