Share via


WMI SELECT * FROM DhcpServerv4Scope Returns empty.

Question

Thursday, January 3, 2019 6:49 AM

I am trying to get a list of DHCP Scopes from Windows Server 2019 (Essentials) by running  

this WMI Query:  SELECT * FROM DhcpServerv4Scope  but it returns empty. No errors, just empty.

DHCP Server has lots of Scopes so I really expect some data in return.

Using Name space: ROOT\Microsoft\Windows\DHCP

Any help is appreciated.

All replies (11)

Thursday, January 3, 2019 6:53 AM

Get a specified instance of DhcpServerv4Scope by a key, get a default unnamed instance (singleton) of the class or list instances of the class by <g class="gr_ gr_3 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="3" id="3">wmi</g> query using this c# sample code.

//https://wutils.com/wmi/
    
    //Project -> Add reference -> System.Management
    //using System.Management;
    
    //create a management scope object
    ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\Microsoft\\Windows\\DHCP");
    
    //create object query
    ObjectQuery query = new ObjectQuery("SELECT * FROM DhcpServerv4Scope Where PropertyName=\"SomeText\"");
    
    //create object searcher
    ManagementObjectSearcher searcher =
                            new ManagementObjectSearcher(scope, query);
    
    //get a collection of WMI objects
    ManagementObjectCollection queryCollection = searcher.Get();
    
    //enumerate the collection.
    foreach (ManagementObject m in queryCollection) 
    {
      // access properties of the WMI object
      Console.WriteLine("ActivatePolicies : {0}", m["ActivatePolicies"]);
      
    }

Thursday, January 3, 2019 7:14 AM

Well.. 

You suggesting to use  "SELECT * FROM DhcpServerv4Scope" statement where my original question

stating that it does not return any data. Is there a reading disconnect?


Thursday, January 3, 2019 7:16 AM

Try with powershell query "Get-DhcpServerv4Scope -ComputerName "computer.domain.com"


Thursday, January 3, 2019 7:23 AM

Power Shell Query works fine: 

PS C:\Users\Administrator> Get-DhcpServerv4Scope

ScopeId         SubnetMask      Name           State    StartRange      EndRange        LeaseDuration
                                           
10.19.19.0      255.255.255.0   Saratov        Active   10.19.19.1      10.19.19.20     8.00:00:00
10.20.20.0      255.255.255.0   Vilnus         Active   10.20.20.1      10.20.20.2      8.00:00:00

But direct WMI Query returns Empty.  I am using "WMI Explorer" application to browse classes.


Thursday, January 3, 2019 7:28 AM

Try with the below query 

Get-WmiObject -Namespace ROOT\Microsoft\Windows\DHCP -List

Get-WmiObject -Namespace ROOT\Microsoft\Windows\DHCP -List | Where-Object Name -eq 'PS_DhcpServerv4ScopeStatistics'


Thursday, January 3, 2019 7:31 AM

here it is 

   NameSpace: ROOT\Microsoft\Windows\DHCP

Name                                Methods              Properties
                                             
__SystemClass                       {}                   {}
__thisNAMESPACE                     {}                   {SECURITY_DESCRIPTOR}
__NAMESPACE                         {}                   {Name}
__ProviderRegistration              {}                   {provider}
__EventProviderRegistration         {}                   {EventQueryList, provider}
__ObjectProviderRegistration        {}                   {InteractionType, provider, QuerySupportLevels, SupportsBat...
__ClassProviderRegistration         {}                   {CacheRefreshInterval, InteractionType, PerUserSchema, prov...
__InstanceProviderRegistration      {}                   {InteractionType, provider, QuerySupportLevels, SupportsBat...
__MethodProviderRegistration        {}                   {provider}
__PropertyProviderRegistration      {}                   {provider, SupportsGet, SupportsPut}
__EventConsumerProviderRegistration {}                   {ConsumerClassNames, provider}
__IndicationRelated                 {}                   {}
__FilterToConsumerBinding           {}                   {Consumer, CreatorSID, DeliverSynchronously, DeliveryQoS...}
__EventConsumer                     {}                   {CreatorSID, MachineName, MaximumQueueSize}
__AggregateEvent                    {}                   {NumberOfEvents, Representative}
__TimerNextFiring                   {}                   {NextEvent64BitTime, TimerId}
__EventFilter                       {}                   {CreatorSID, EventAccess, EventNamespace, Name...}
__Event                             {}                   {SECURITY_DESCRIPTOR, TIME_CREATED}
__NamespaceOperationEvent           {}                   {SECURITY_DESCRIPTOR, TargetNamespace, TIME_CREATED}
__NamespaceModificationEvent        {}                   {PreviousNamespace, SECURITY_DESCRIPTOR, TargetNamespace, T...
__NamespaceDeletionEvent            {}                   {SECURITY_DESCRIPTOR, TargetNamespace, TIME_CREATED}
__NamespaceCreationEvent            {}                   {SECURITY_DESCRIPTOR, TargetNamespace, TIME_CREATED}
__ClassOperationEvent               {}                   {SECURITY_DESCRIPTOR, TargetClass, TIME_CREATED}
__ClassDeletionEvent                {}                   {SECURITY_DESCRIPTOR, TargetClass, TIME_CREATED}
__ClassModificationEvent            {}                   {PreviousClass, SECURITY_DESCRIPTOR, TargetClass, TIME_CREA...
__ClassCreationEvent                {}                   {SECURITY_DESCRIPTOR, TargetClass, TIME_CREATED}
__InstanceOperationEvent            {}                   {SECURITY_DESCRIPTOR, TargetInstance, TIME_CREATED}
__InstanceCreationEvent             {}                   {SECURITY_DESCRIPTOR, TargetInstance, TIME_CREATED}
__MethodInvocationEvent             {}                   {Method, Parameters, PreCall, SECURITY_DESCRIPTOR...}
__InstanceModificationEvent         {}                   {PreviousInstance, SECURITY_DESCRIPTOR, TargetInstance, TIM...
__InstanceDeletionEvent             {}                   {SECURITY_DESCRIPTOR, TargetInstance, TIME_CREATED}
__TimerEvent                        {}                   {NumFirings, SECURITY_DESCRIPTOR, TIME_CREATED, TimerId}
__ExtrinsicEvent                    {}                   {SECURITY_DESCRIPTOR, TIME_CREATED}
__SystemEvent                       {}                   {SECURITY_DESCRIPTOR, TIME_CREATED}
__EventDroppedEvent                 {}                   {Event, IntendedConsumer, SECURITY_DESCRIPTOR, TIME_CREATED}
__EventQueueOverflowEvent           {}                   {CurrentQueueSize, Event, IntendedConsumer, SECURITY_DESCRI...
__QOSFailureEvent                   {}                   {ErrorCode, ErrorDescription, Event, IntendedConsumer...}
__ConsumerFailureEvent              {}                   {ErrorCode, ErrorDescription, ErrorObject, Event...}
__EventGenerator                    {}                   {}
__TimerInstruction                  {}                   {SkipIfPassed, TimerId}
__AbsoluteTimerInstruction          {}                   {EventDateTime, SkipIfPassed, TimerId}
__IntervalTimerInstruction          {}                   {IntervalBetweenEvents, SkipIfPassed, TimerId}
__Provider                          {}                   {Name}
__Win32Provider                     {}                   {ClientLoadableCLSID, CLSID, Concurrency, DefaultMachineNam...
__SystemSecurity                    {GetSD, GetSecuri... {}
CIM_Indication                      {}                   {CorrelatedIndications, IndicationFilterName, IndicationIde...
CIM_ClassIndication                 {}                   {ClassDefinition, CorrelatedIndications, IndicationFilterNa...
CIM_ClassDeletion                   {}                   {ClassDefinition, CorrelatedIndications, IndicationFilterNa...
CIM_ClassCreation                   {}                   {ClassDefinition, CorrelatedIndications, IndicationFilterNa...
CIM_ClassModification               {}                   {ClassDefinition, CorrelatedIndications, IndicationFilterNa...
CIM_InstIndication                  {}                   {CorrelatedIndications, IndicationFilterName, IndicationIde...
CIM_InstCreation                    {}                   {CorrelatedIndications, IndicationFilterName, IndicationIde...
CIM_InstModification                {}                   {CorrelatedIndications, IndicationFilterName, IndicationIde...
CIM_InstDeletion                    {}                   {CorrelatedIndications, IndicationFilterName, IndicationIde...
__NotifyStatus                      {}                   {StatusCode}
__ExtendedStatus                    {}                   {Description, Operation, ParameterInfo, ProviderName...}
CIM_Error                           {}                   {CIMStatusCode, CIMStatusCodeDescription, ErrorSource, Erro...
MSFT_WmiError                       {}                   {CIMStatusCode, CIMStatusCodeDescription, error_Category, e...
MSFT_ExtendedStatus                 {}                   {CIMStatusCode, CIMStatusCodeDescription, error_Category, e...
__SecurityRelatedClass              {}                   {}
__Trustee                           {}                   {Domain, Name, SID, SidLength...}
__NTLMUser9X                        {}                   {Authority, Flags, Mask, Name...}
__ACE                               {}                   {AccessMask, AceFlags, AceType, GuidInheritedObjectType...}
__SecurityDescriptor                {}                   {ControlFlags, DACL, Group, Owner...}
__PARAMETERS                        {}                   {}
DhcpServerv4MulticastLease          {}                   {AddressState, ClientId, HostName, IPAddress...}
DhcpServerv6Statistics              {}                   {AddressesAvailable, AddressesInUse, Advertises, Confirms...}
PS_DhcpServerInDC                   {Add, Remove, Get}   {}
PS_DhcpServerv4FreeIPAddress        {Get}                {}
PS_DhcpServerv6Statistics           {Get}                {}
PS_DhcpServerv6OptionDefinition     {Add, Get, Set, R... {}
DhcpServerv4IPRecords               {}                   {IPAddress, ScopeId}
DhcpServerVersion                   {}                   {MajorVersion, MinorVersion}
PS_DhcpServerv4OptionValue          {SetByCommonOptio... {}
DhcpServerv4FilterList              {}                   {Allow, Deny}
PS_DhcpServerv4FilterList           {Get, Set}           {}
DhcpServerv4MulticastScopeStatis... {}                   {AddressesFree, AddressesInUse, Name, PendingOffers...}
DhcpServerv6DnsSetting              {}                   {DeleteDnsRROnLeaseExpiry, DynamicUpdates, NameProtection}
PS_DhcpServerv4Scope                {SetByWithoutRang... {}
DhcpServerv4DnsSetting              {}                   {DeleteDnsRROnLeaseExpiry, DisableDnsPtrRRUpdate, DnsSuffix...
DhcpServerv4OptionDefinition        {}                   {DefaultValue, Description, MultiValued, Name...}
DhcpServerv6ExclusionRange          {}                   {EndRange, Prefix, StartRange}
DhcpServerv6ScopeStatistics         {}                   {AddressesFree, AddressesInUse, PendingAdvertises, Percenta...
PS_DhcpServerv4Reservation          {Add, GetByClient... {}
PS_DhcpServerv4Superscope           {Add, Get, Remove... {}
PS_DhcpServerv4MulticastScope       {Add, Remove, Set... {}
DhcpServerv4MulticastScope          {}                   {Description, EndRange, ExpiryTime, LeaseDuration...}
DhcpServerv6OptionValue             {}                   {Name, OptionId, Type, UserClass...}
PS_DhcpServerv4FailoverScope        {Add, Remove}        {}
PS_DhcpServerSetting                {Set, Get}           {}
DhcpServerDnsCredential             {}                   {DomainName, UserName}
DhcpServerv4OptionValue             {}                   {Name, OptionId, PolicyName, Type...}
PS_DhcpServerSecurityGroup          {Add}                {}
PS_DhcpServerv6StatelessStatistics  {Get}                {}
PS_DhcpServerv4MulticastExclusio... {Add, Remove, Get}   {}
PS_DhcpServerv6StatelessStore       {Set, Get}           {}
PS_DhcpServerv4Statistics           {Get}                {}
PS_DhcpServerDnsCredential          {Set, Get, Remove}   {}
PS_DhcpServerv4Class                {Add, Remove, Set... {}
DhcpServerAuditLog                  {}                   {DiskCheckInterval, Enable, MaxMBFileSize, MinMBDiskSpace...}
DhcpServerv4Class                   {}                   {Data, Description, Name, Type}
DhcpServerv6StatelessStore          {}                   {Enabled, Prefix, PurgeInterval}
PS_DhcpServerv6Scope                {Add, Get, Set, R... {}
DhcpServerv4Policy                  {}                   {CircuitId, ClientId, Condition, Description...}
PS_DhcpServerv6Binding              {Get, Set}           {}
PS_DhcpServerv4SuperscopeStatistics {Get}                {}
DhcpServerv6Scope                   {}                   {Description, Name, Preference, PreferredLifetime...}
PS_DhcpServerv4IPRecord             {Repair}             {}
PS_DhcpServerv6Lease                {GetByIPAddress, ... {}
PS_DhcpServerv4ExclusionRange       {Get, Add, Remove}   {}
PS_DhcpServerv4PolicyIPRange        {Add, Remove, Get}   {}
PS_DhcpServer                       {Backup, Restore}    {}
DhcpServerv6Reservation             {}                   {AddressState, ClientDuid, Description, Iaid...}
PS_DhcpServerv6DnsSetting           {Set, Get}           {}
PS_DhcpServerv4MulticastScopeSta... {Get}                {}
PS_DhcpServerv4Policy               {Add, Remove, Get... {}
PS_DhcpServerv4Binding              {Get, Set}           {}
DhcpServerv6OptionDefinition        {}                   {DefaultValue, Description, MultiValued, Name...}
PS_DhcpServerv4DnsSetting           {Set, Get}           {}
PS_DhcpServerv6Reservation          {Add, GetByIPAddr... {}
DhcpServerv4PolicyIPRange           {}                   {EndRange, Name, ScopeId, StartRange}
DhcpServerv4ScopeStatistics         {}                   {AddressesFree, AddressesFreeOnPartnerServer, AddressesFree...
PS_DhcpServerv4Failover             {GetByName, GetBy... {}
DhcpServerDatabase                  {}                   {BackupInterval, BackupPath, CleanupInterval, FileName...}
DhcpServerv4Filter                  {}                   {Description, List, MacAddress}
PS_DhcpServerDatabase               {Set, Get}           {}
PS_DhcpServerv4Filter               {Add, Remove, Get}   {}
PS_DhcpServerv6FreeIPAddress        {Get}                {}
DhcpServerv4Reservation             {}                   {AddressState, ClientId, Description, IPAddress...}
PS_DhcpServerVersion                {Get}                {}
DhcpServerv4Statistics              {}                   {Acks, AddressesAvailable, AddressesInUse, Declines...}
DhcpServerv4ExclusionRange          {}                   {EndRange, ScopeId, StartRange}
DhcpServerv4SuperscopeStatistics    {}                   {AddressesFree, AddressesInUse, NumScopes, PercentageInUse...}
DhcpServerv4Scope                   {}                   {ActivatePolicies, Delay, Description, EndRange...}
DhcpServerv4Superscope              {}                   {ScopeId, SuperscopeName}
PS_DhcpServerv6ScopeStatistics      {Get}                {}
PS_DhcpServerv4Lease                {GetByBadLeases, ... {}
PS_DhcpServerv6ExclusionRange       {Get, Add, Remove}   {}
PS_DhcpServerv6Class                {Add, Remove, Set... {}
DhcpServerv6StatelessStatistics     {}                   {AddressesInUse, Prefix}
PS_DhcpServerv4FailoverReplication  {InvokeByName, In... {}
DhcpServerv6Class                   {}                   {Data, Description, Name, Type...}
DhcpServerInDC                      {}                   {DnsName, IPAddress}
PS_DhcpServerv6OptionValue          {Get, Remove, Set... {}
DhcpServerSetting                   {}                   {ActivatePolicies, ConflictDetectionAttempts, DynamicBootp,...
DhcpServerv4Lease                   {}                   {AddressState, ClientId, ClientType, Description...}
DhcpServerv6Binding                 {}                   {BindingState, InterfaceAlias, InterfaceGuid, InterfaceInde...
DhcpServerv4Failover                {}                   {AutoStateTransition, EnableAuth, LoadBalancePercent, MaxCl...
DhcpServerv4Binding                 {}                   {BindingState, InterfaceAlias, InterfaceGuid, IPAddress...}
PS_DhcpServerAuditLog               {Set, Get}           {}
PS_DhcpServerv4OptionDefinition     {Get, Add, Set, R... {}
DhcpServerv4MulticastExclusionRange {}                   {EndRange, Name, StartRange}
PS_DhcpServerv4ScopeStatistics      {Get}                {}
DhcpServerv6Lease                   {}                   {AddressType, ClientDuid, Description, HostName...}
PS_DhcpServerv4MulticastLease       {Get, Remove}        {}
PS_DhcpServerv4ScopeStatistics      {Get}                {}

PS C:\WMI Explorer>


Thursday, January 3, 2019 7:32 AM

PS C:\Users\Dmitry> Get-WmiObject -Namespace ROOT\Microsoft\Windows\DHCP -List | Where-Object Name -eq 'PS_DhcpServerv4S
copeStatistics'

   NameSpace: ROOT\Microsoft\Windows\DHCP

Name                                Methods              Properties
                                             
PS_DhcpServerv4ScopeStatistics      {Get}                {}


Monday, January 7, 2019 10:06 AM

Hi,

Thanks for posting on the forum.

This is a quick note to let you know that we are currently performing research on this issue and will get back to you as soon as possible. Appreciate your patience.

If you have any updates during this process, please feel free to let us know.

Regards,

Zoe

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Wednesday, January 9, 2019 1:25 AM

Hi,

Please try this command to check if it helps.

(Get-WmiObject -ComputerName <YOURSERVER> -Namespace ROOT\Microsoft\Windows\DHCP -List | Where-Object Name -eq “PS_DhcpServerv4Scope”).Get() | Select-Object -ExpandProperty cmdletOutput

Regards,

Zoe

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Thursday, January 10, 2019 2:51 AM

Hi,

 

Just checking in to see if the information provided was helpful.

Please let us know if you would like further assistance.

 

Best Regards,

Zoe

 

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Wednesday, January 16, 2019 1:54 AM

Hi,

 

Was your issue resolved?

If the information provided was helpful, please "mark it as answer" to help other community members find the helpful reply quickly.

If no, please reply and tell us the current situation in order to provide further help.

 

Best Regards,

Zoe

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].