Redigera

Dela via


__Namespace class

The __Namespace system class represents a WMI namespace.

The following syntax is simplified from Managed Object Format (MOF) code and includes all inherited properties. Properties are listed in alphabetic order, not MOF order.

Syntax

class __Namespace : __SystemClass
{
  string Name;
};

Members

The __Namespace class has these types of members:

Properties

The __Namespace class has these properties.

Name

Data type: string

Access type: Read/write

Qualifiers: Key

Namespace name.

Remarks

The __Namespace class is derived from __SystemClass, which has no properties.

You can use __Namespace to identify, create, and delete child namespaces within the current working namespace for which you have an IWbemServices object. Creating a new instance of __Namespace within any working namespace creates a child namespace within the working namespace. Conversely, deleting an instance of __Namespace removes the child namespace from the working namespace. Note that deleting a child namespace also deletes all of its classes and instances.

Enumerating instances of this class within any working namespace gives the available child namespaces.

For example, within the \root namespace are two instances of __Namespace. One has its Name property set to "Default," the other has Name set to "Cimv2." These instances represent the \root\default, and \root\cimv2 namespaces, respectively.

Examples

The following code sample retrieves all namespaces in PowerShell.

get-wmiobject __namespace -namespace 'root' -list -recurse | format-table __namespace

The following code sample improves on the previous sample, and adds in additional information.

# Set computer name 
$comp = "." 
 
# Get the name spaces on the local computer, and the local computer name 
$Namespace = get-wmiobject __namespace -namespace 'root' -list -recurse -computer $comp  
$hotsname = hostname 
 
# Display number of and names of the namespaces 
"{0} Namespaces on: {1}" -f $namespace.count, $hostname 
$NameSpace| sort __namespace  | Format-Table @{Expression = "__Namespace"; Label = "Namespace"}

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
All WMI namespaces

See also

__SystemClass

WMI System Classes