?
Solved

Powershell WMI Query for DHCP

Posted on 2010-08-12
2
Medium Priority
?
2,796 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:Adam Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
PWeerakoon earned 2000 total points
ID: 33424557
Slightly modified the script found here...
http://pshscripts.blogspot.com/2009/01/get-ipaddressps1.html 

You could setup a variable
$computername = Get-Content "C:\TEMP\computerlist.txt"
and feed it to a foreach loop with the below script...
CLS
$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
		$count++   
		}  
   }
}

Open in new window

0
 
LVL 42

Author Closing Comment

by:Adam Brown
ID: 33425173
Got me what I wanted. Thanks.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question