Sep 26 2010 2:16PM GMT
Posted by: Richard Siddaway
Network, PowerShell v2
WMI and Network Adapters: 6
Posted by: Richard Siddaway
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.




