PowerShell for Windows Admins

Sep 26 2010   2:16PM GMT

WMI and Network Adapters: 6



Posted by: Richard Siddaway
Tags:
Network
PowerShell v2

We have seen how to test for the DNS server in use. What about testing for DHCP?

001
002
003
004
005
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName "." | 
where {$_.DHCPEnabled} | 
select Description, IPAddress, DHCPServer,
@{Name=‘LeaseStart’;Expression={$_.ConvertToDateTime($_.DHCPLeaseObtained)}},
@{Name=‘Leaseend’;Expression={$_.ConvertToDateTime($_.DHCPLeaseExpires)}}

Get the instances of the NetworkAdapterConfiguration class. This time we filter in those instances that have the DHCPEnabled property set to True. We select the NIC description, IP Address, DHCP server and the start and end time of the lease. We have to convert the dates into a readable format using the ConvertToDate method.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: