permission denied for Get-DhcpServerv4ScopeStatistics for some of the queries

Jost Mario 1 Reputation point
2022-09-01T11:58:44.017+00:00

We have following powershell script

$scopes = Get-DhcpServerv4Scope -ComputerName $DHCPservername | select ScopeId, Name
$DHCPservername = "dhcp.company.local"

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 172.16.0.0.
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 172.17.246.32 on DHCP server dhcp.company.local.
At line:7 char:9

  • Get-DhcpServerv4ScopeStatistics -ComputerName $DHCPservername ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : PermissionDenied: (172.17.246.32:root/Microsoft/...ScopeStatistics) [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
    2022-09-01T12:47:08.687+00:00

    Hi Mario (@Jost Mario ),

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

    Permission denied only when PSRemoting
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/1cd779fb-3308-4ce6-9b1d-941c3c052bb6/permission-denied-only-when-psremoting?forum=winserverpowershell

    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)
    Regards
    Stoyan Chalakov

    0 comments No comments

  2. Limitless Technology 39,331 Reputation points
    2022-09-06T07:46:08.687+00:00

    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 10.90.0.0 | gm

    Go to this link for your reference https://learn.microsoft.com/en-us/previous-versions/windows/desktop/dhcpserverpsprov/dhcpserverv4scopestatistics

    Kindly check also this link as the forum have the same issue as yours https://social.technet.microsoft.com/Forums/en-US/d28e327c-7856-4152-b53d-573e758caa81/getdhcpserverv4scopestatistics-query-problem

    ----------------------------------------------------------------------------------------------------------------------------------

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

    0 comments No comments