我的DHCP服务器是2008R2。我想知道是否可以通过某种方式知道给定DHCP IP地址的发布日期和时间?
我看到有一个命令“ get-dhcpserverv4lease”,但是它仅存在于Win 10和Server 2016上。
我如何在2008R2或2012R2上知道它?
答案 0 :(得分:1)
您可以使用WMI oder netsh。
WMI
Get-WmiObject -Namespace ROOT\Microsoft\Windows\DHCP -List | Where-Object Name -eq 'DhcpServerv4Lease'
不幸的是,我无法验证此WMI查询,因为我只有Windows Server 2016 DHCP服务器,并且在那里返回空对象。但是,PS_DhcpServerv4IPLease
类在2016年运行良好。
NETSH
您需要解析输出并遍历所有作用域
netsh dhcp server \\dhcpservername show scope
==============================================================================
Scope Address - Subnet Mask - State - Scope Name - Comment
==============================================================================
192.168.178.0 - 255.255.255.0 -Active -Default IPv4 Scope -
Total No. of Scopes = 1
Command completed successfully.
然后通过所有IP地址
C:\Windows\system32>netsh dhcp server \\dhcpservername scope 192.168.178.0 show clients
Changed the current scope context to 192.168.178.0 scope.
Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP
==================================================================================
IP Address - Subnet Mask - Unique ID - Lease Expires -Type
==================================================================================
192.168.178.170 - 255.255.255.0 - b0-72-bf-cb-97-a0 -25.04.2019 18:56:41 -D
192.168.178.171 - 255.255.255.0 - 00-0d-2f-d5-b1-d6 -25.04.2019 12:03:38 -D
192.168.178.172 - 255.255.255.0 - b0-4e-26-72-9b-5f -19.04.2019 23:08:19 -D
192.168.178.173 - 255.255.255.0 - 70-4f-57-11-01-03 -20.04.2019 23:00:00 -D
No of Clients(version 4): 4 in the Scope : 192.168.178.0.
Command completed successfully.
答案 1 :(得分:1)
塞巴斯蒂安·塞格勒(Sebastian Segerer),netsh dhcp服务器只能在Windows 8.1上运行。
因此,如果您使用的是Windows 10,则无法运行,或者是2008 R2或2012或2016。