• 前提是安装RSAT tool for win10,这样才有相应的powershell module 来管理DHCP
  • 另外要有权限来查询DHCP服务器
加入下面代码到$profile 中
function get-dhcplease{
    $dhcpservers=Get-DhcpServerInDC
    $dhcpscopes=$dhcpservers|%{$computername=$_.dnsname;Get-DhcpServerv4Scope -ComputerName $computername|%{$_|Add-Member -Type NoteProperty -name "computername" -Value $computername;$_}}
    $dhcpscopes|%{Get-DhcpServerv4Lease -ScopeId $_.scopeid -ComputerName $_.computername}|Out-GridView
}
 
然后执行. $profile
 
get-dhcplease可以查询目前域内所有DHCP服务器的IP分发。