【发布时间】:2018-10-19 10:30:37
【问题描述】:
我有一个 IP 地址列表,我需要为该列表的每个 IP 地址关联站点和子网。 我有5203 IP地址,一一验证太多了;也许有人可以帮助我? 谢谢。
【问题讨论】:
标签: windows powershell active-directory subnet sites
我有一个 IP 地址列表,我需要为该列表的每个 IP 地址关联站点和子网。 我有5203 IP地址,一一验证太多了;也许有人可以帮助我? 谢谢。
【问题讨论】:
标签: windows powershell active-directory subnet sites
您没有像@boxdog 所说的那样提供太多信息。 我猜您正在使用 DHCP,并且您想查询租用的范围和 IP。
$scopes = Get-DhcpServerv4Scope -ComputerName "DHCP-Server"
foreach($scope in $scopes)
{
write-host -ForegroundColor Cyan "The current scope name is: " -NoNewline; Write-Host -ForegroundColor Green $scope.name
$lease = Get-DhcpServerv4Lease -ScopeId $scope.ScopeId -ComputerName "DHCP-Server"
$lease
}
如果没有,请提供有关您想要做什么的更多信息。您已经编写的脚本也很有帮助。
【讨论】:
$IPAdd = Get-Content "path of the txt file, e.g. c:\system\IPaddress.txt" ForEach ($IP in $IPAdd){ Get-DhcpServerv4Lease -IPAddress $IP -ComputerName "DHCPServer Name" | Format-Table -AutoSize }