首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检索DHCP Scopes

检索DHCP Scopes
EN

Stack Overflow用户
提问于 2017-11-28 17:01:26
回答 1查看 6.8K关注 0票数 2

我的脚本在本地运行时工作,我试图从远程服务器获取所有DHCP作用域信息,我收到脚本下面的错误。

代码语言:javascript
复制
$A = "TestDH01"
ForEach ($B in $A) {

Get-DHCPServerv4Lease -ScopeID $_.ScopeID -AllLeases | where 
{$_.AddressState -like '*Reservation'}

} Select-Object ScopeId,IPAddress,HostName,ClientID,AddressState | ExportCsv "\\TermServer\d$\New\Steve\$($A)-Reservations1.csv" -NoTypeInformation

Get-DhcpServerv4Leases:无法验证参数'ScopeId‘上的参数。参数为空或空。提供一个非空或空的参数,然后再试一次该命令。在行:4字符:36+Get-DHCPServerv4租赁-ScopeID $.ScopeID -AllLeases x,其中{$。.+ ~~ + CategoryInfo : InvalidData:(:) Get-DhcpServerv4租赁,ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DhcpServerv4租赁

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-28 18:24:10

我猜你是在找这样的东西:

代码语言:javascript
复制
#Get all DHCP Servers
$ServerList = Get-DhcpServerInDC | select IPADdress, DNSName
foreach ($server in $serverlist)
{
#Get the scopes from each server
    Get-DHCPServerv4Scope -ComputerName $server.IPAddress | select ScopeID | 
#Get the lease information for each scope
    ForEach-Object {Get-DHCPServerv4Lease -ScopeId $_.ScopeId -ComputerName $Server.DNSName -AllLeases  | 
        where {$_.AddressState -like "*Reservation"} | Select-Object ScopeId,IPAddress,HostName,ClientID,AddressState }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47537071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档