3

I want to list which things are useable under \\root\ .However i don't know how to list or see which things i can use.Because,i am beginner in the powershell.

I am coding this thing: wmic /namespace:\root\ (But i don't know which things i can use under root.And because of this, i cannot use anything :/)

How can i list which things could be useable under root ? If someone can help, i will be really happy :D

I tried use "/?" but it didn't help.Also i researched on google BUT again i couldn't find something useful for myself or maybe i couldn't understand their solutions.

2 Answers2

4

There is a WMI class of __namespace you can query:

Get-WmiObject -Namespace Root -Class __Namespace | Select Name

Name           
----           
subscription   
DEFAULT        
CIMV2          
msdtc          
Cli            
SECURITY       
SecurityCenter2
RSOP           
PEH            
StandardCimv2  
WMI            
MSPS           
directory      
Policy         
Interop        
Hardware       
ServiceModel   
SecurityCenter 
Microsoft      
Appv           

I would recommend reading through about WMI. It covers some of the discoverability aspects, which are important because:

In a default installation of Windows 8, there are more than 1,100 WMI classes in Root/Cimv2


Newer versions of powershell use CIM over WMI with commands like Get-CimInstance. It's not worth worrying about for now, but it's good to look into while you're learning

WMIC is a separate exe from powershell, and doesn't return powershell objects. I would avoid it unless you're stuck to command prompt

Cpt.Whale
  • 4,784
  • 1
  • 10
  • 16
  • Really thank you sir i am glad that i am able to list this namespaces unde the root.Also i have one question too sir i hope i am not doing you busy or angry.How i can see which codes can execute under this classes ? For example: wmic /namespace:\\root\securitycenter2 (After this which codes i can execute ? Do we can again list something about this ? – Goku Sensei Oct 26 '22 at 21:23
  • @GokuSensei use `-List` like `Get-WmiObject -Namespace root/cimv2/power -List` – Cpt.Whale Oct 27 '22 at 02:55
3

Cpt.Whale's answer is helpful, but is uses the deprecated WMI cmdlets (from the Get-WmiObject docs page: "Starting in PowerShell 3.0, this cmdlet has been superseded by Get-CimInstance"); similarly, wmic.exe is deprecated (see note at the top of the page). Both are deprecated in favor of the CIM cmdlets, so the standard advice applies:

  • The CIM cmdlets (e.g., Get-CimInstance) superseded the WMI cmdlets (e.g., Get-WmiObject) in PowerShell v3 (released in September 2012). Therefore, the WMI cmdlets should be avoided, not least because PowerShell (Core) v7+, where all future effort will go, doesn't even have them anymore. Note that WMI still underlies the CIM cmdlets, however.
  • For more information, including the differences between these two sets of cmdlets, see this answer.

Thus, here are solutions based on the CIM cmdlets:

  • To get all namespaces nested inside another namespace, such as root:
Get-CimInstance -Class __Namespace -Namespace root | ForEach-Object Name
  • To get all classes inside a given namespace, such as root, by name:
Get-CimClass -Namespace root | ForEach-Object CimClassName

Note:

  • Append | Sort-Object to the commands above to get alphabetically sorted output.

  • The default namespace (also for the WMI cmdlets) is root/cimv2, which applies if you omit a -Namespace argument.

mklement0
  • 382,024
  • 64
  • 607
  • 775