我的脚本在本地运行时工作,我试图从远程服务器获取所有DHCP作用域信息,我收到脚本下面的错误。
$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" -NoTypeInformationGet-DhcpServerv4Leases:无法验证参数'ScopeId‘上的参数。参数为空或空。提供一个非空或空的参数,然后再试一次该命令。在行:4字符:36+Get-DHCPServerv4租赁-ScopeID $.ScopeID -AllLeases x,其中{$。.+ ~~ + CategoryInfo : InvalidData:(:) Get-DhcpServerv4租赁,ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DhcpServerv4租赁
发布于 2017-11-28 18:24:10
我猜你是在找这样的东西:
#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 }
}https://stackoverflow.com/questions/47537071
复制相似问题