My script works when run locally, I am trying to get all DHCP scope info from remote servers, I receive the error below the script
$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-DhcpServerv4Lease : Cannot validate argument on parameter 'ScopeId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At line:4 char:36 + Get-DHCPServerv4Lease -ScopeID $.ScopeID -AllLeases | where {$. ... + ~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-DhcpServerv4Lease], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DhcpServerv4Lease
$_
so$_.ScopeID
will always be null. Do something like-ScopeID $B
- Nick