加入下面代码到$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分发。
Powershell function to get all dhcp lease
原文地址:http://yoke88.blog.51cto.com/973273/1742419