top of page

PowerShell | DHCP Check Enabled

          Get list of servers from AD
          Loop through servers and test access
          Use WMI to get NIC settings in relation to specific IP
          Check if that NIC with IP Scheme has DHCP value enabled 
          Export results to file

Author:   Scott Head
Date:     05/09/2022
Version:  1.0 

# Get all Enabled Computers from IT
$Server_Computers=Get-ADComputer -Properties * -Filter {(Enabled -eq $True) -and (Operatingsystem -Like "Windows Server*")} | Select -ExpandProperty Name

#Array of Computers

# Test network connection 
Foreach($Computer in $Server_Computers){
    $Checker=Test-Connection $Computer -Count 1 -Quiet    

Foreach($Comp in $Array){

    $Result=Get-WMIObject -ComputerName $Comp Win32_NetworkAdapterConfiguration | where{$_.IPAddress -like "172.*"} | select -ExpandProperty DHCPEnabled
    "$Comp | $Result" | Tee-Object C:\temp\DHCP.txt -Append


bottom of page