permission denied for Get-DhcpServerv4ScopeStatistics for some of the queries

Jost Mario 1 Reputation point

We have following powershell script

$scopes = Get-DhcpServerv4Scope -ComputerName $DHCPservername | select ScopeId, Name
$DHCPservername = ""

Foreach ($s in $scopes)
write-host "Getting statistics for" $s.ScopeId $s.Name
Get-DhcpServerv4ScopeStatistics -ComputerName $DHCPservername -ScopeID $s.ScopeId

This has been simplified to narrow down the issue. Basically we want to get all the scopes on a DHCP server and get the scopeID (which is the network ID like
When we run this script, on some entries whithin the foreach, we get following error:

Get-DhcpServerv4ScopeStatistics : Failed to enumerate reserved IP addresses in scope on DHCP server
At line:7 char:9

  • Get-DhcpServerv4ScopeStatistics -ComputerName $DHCPservername ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : PermissionDenied: ( [Get-DhcpServerv4ScopeStatistics], CimException
  • FullyQualifiedErrorId : WIN32 5,Get-DhcpServerv4ScopeStatistics

This is very sporadic. We have around 112 scopes and when we run the script 20 times, sometimes there is no error at all, then there is this error on one scope alone, another run, again maybe only one error but on a different scope and sometimes there are even multiple errors where 3-5 scopes return the message above. Clearly this is no permission issue, because we have permission for all the other scopes and the error switches from run to run. We tested some delays (1s wait in the foreach) which did not help.

We have multiple powershell scripts running on this server as it is our monitoring server. I tested this script on another server, that does not do other powershell scripts, and i coulnt reproduce the issue there. So this seems to be related with something like: running multiple powershell scripts at once or in parralel or something. I couldnt find any limitations on that regard online. So is there something i can test or adjust to increase the amount of powershell processes somehow?

Windows DHCP
Windows DHCP
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.DHCP: Dynamic Host Configuration Protocol (DHCP). A communications protocol that lets network administrators manage centrally and automate the assignment of Internet Protocol (IP) addresses in an organization's network.
1,021 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,343 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. SChalakov 10,261 Reputation points MVP

    Hi Mario (@Jost Mario ),

    this could be related to doing PS Remoting as mentioned here:

    Permission denied only when PSRemoting

    Can you please give the answer from the post a try?

    What bothers me though is that you say that this iss sporadic.. Do you see some events in the logs on the DHCP Server when this happens? Look for WMI related events also...


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
    Stoyan Chalakov

    0 comments No comments

  2. Limitless Technology 39,331 Reputation points

    Hi Jost,

    Thank you for posting your query.

    To resolve your query kindly do the steps below.

    As with many CmdLet return objects some can be calculated by the default type format and may not be available as selectable properties.

    To see which properties are available do the following:

    Get-DhcpServerv4ScopeStatistics -ScopeID | gm

    Go to this link for your reference

    Kindly check also this link as the forum have the same issue as yours


    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments