• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3020
  • Last Modified:

Powershell WMI Query for DHCP

I'm trying to build up a script that will query WMI on computers to determine if they are using DHCP or if they have a Static IP assigned to them. I'm not real sure if this is even possible. I'm not that great at WMI, so I could really use a good resource for figuring that part out. More specifically, I'm trying to find the spot in WMI where DHCP information is, and how to query that in powershell.
Adam Brown
Adam Brown
1 Solution
Slightly modified the script found here...

You could setup a variable
$computername = Get-Content "C:\TEMP\computerlist.txt"
and feed it to a foreach loop with the below script...
$IPconfigset = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName PC24211-VM02, PC24211
$count = 0  
foreach ($IPConfig in $IPConfigSet) 
   if ($Ipconfig.IPaddress) 
      foreach ($addr in $Ipconfig.Ipaddress) 
		"IP Address    : {0}" -f  $addr; 
		"DHCP Enabled  : {0}" -f $Ipconfig.DHCPEnabled

Open in new window

Adam BrownSr Solutions ArchitectAuthor Commented:
Got me what I wanted. Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

We Need Your Input!

WatchGuard is currently running a beta program for our new macOS Host Sensor for our Threat Detection and Response service. We're looking for more macOS users to help provide insight and feedback to help us make the product even better. Please sign up for our beta program today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now