The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ContainerCmdletProvider.GetChildNames Method (String, ReturnContainers)


Updated: April 27, 2016

Applies To: Windows PowerShell

Returns strings that contain the names of the child items of the specified path.

Namespace:   System.Management.Automation.Provider
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

protected virtual void GetChildNames(
	string path,
	ReturnContainers returnContainers


Type: System.String

The path to the item from which to retrieve the child names.

Type: System.Management.Automation.ReturnContainers

true if all containers are returned, even if they do not match the filter. False if the provider should return only those containers that match the filter.

It is necessary to override this method so that the semantics of a container are logical.

The child names are the leaf portion of the path. For example, for the file system the child name for the path c:\windows\system32\fab.dll would be fab.dll and the child name for the directory c:\windows\system32 would be system32. In contrast, for Active Directory Domain Services (AD DS) the child names would be RDN values of the child objects of the container.

This method defines how the Get-ChildItem cmdlet perform when the Name parameter is specified. If the your provider requires additional parameters based on the path that is supplied when the cmdlet is called, you must overwrite the GetChildNamesDynamicParameters method.

For more information about implementing providers (including samples), see Writing a Windows PowerShell Provider.

This example shows an implementation of the GetChildNames method for a provider that access to an Access data base.

protected override void GetChildNames(
                                      string path,
                                      ReturnContainers returnContainers)
  // If the path represented is a drive, then the child items are
  // tables. Get the names of all the tables in the drive.
  if (this.PathIsDrive(path))
    foreach (DatabaseTableInfo table in this.GetTables())
      WriteItemObject(table.Name, path, true);
    } // End foreach (DatabaseTableInfo...) block.
    // Get type, table name and row number from path specified
    string tableName;
    int rowNumber;

    PathType type = this.GetNamesFromPath(path, out tableName, out rowNumber);

    if (type == PathType.Table)
      // Get all the rows in the table and then write out the 
      // row numbers.
      foreach (DatabaseRowInfo row in this.GetRows(tableName))
        WriteItemObject(row.RowNumber, path, false);
      } // End foreach (DatabaseRowInfo...) block.
    else if (type == PathType.Row)
      // In this case the user has directly specified a row, hence
      // just give that particular row.
      DatabaseRowInfo row = this.GetRow(tableName, rowNumber);
      WriteItemObject(row.RowNumber, path, false);
  } // End else block.
} // End GetChildNames method. 

For an example of of this provider, see AccessDBProviderSample04.

Return to top

Community Additions