现在我将Get-DhcpServerv4Lease -ComputerName 'pc' -ScopeId 'id' -AllLeases
与$object.leaseExpiryTime
结合使用以获取租约到期时间。
但是可以通过WMI查询获得它吗?请问您一个例子。
使用Win32_NetworkAdapterConfiguration,因为它确实包含DHCPLeaseExpires
。例如,
gwmi -query "select DHCPLeaseExpires, ipaddress, Description from Win32_NetworkAdapterConfiguration where dhcpleaseexpires is not null"
# Output
Description : Intel(R) Dual Band Wireless-AC 8265
DHCPLeaseExpires : 20200604032809.000000+180
IPAddress : {192.168.1.104, fe80::...}