
The SQL Server Provider Hierarchy
Products whose data or object models can be represented in a hierarchy use Windows PowerShell providers to expose the hierarchies. The hierarchy is exposed by using a drive and path structure similar to what the Windows file system uses.
Each Windows PowerShell provider implements one or more drives. Each drive is the root node of a hierarchy of related objects. The SQL Server provider implements a SQLSERVER: drive. The SQLSERVER: drive has four primary folders. Each folder and its subfolders represent the set of objects that can be accessed by using a SQL Server management object model. When you are focused on a subfolder in a path that starts with one of these primary folders, you can use the methods from the associated object model to perform actions on the object that is represented by the node. The Windows PowerShell folders implemented by the SQL Server 2008 provider are listed in the following table.
For example, you can use the SQLSERVER:\SQL folder to start paths that can represent any object that is supported by the SMO object model. The leading part of a SQLSERVER:\SQL path is SQLSERVER:\SQL\ComputerName\InstanceName. You must specify a computer name. You can specify either localhost or `(local`) for the local computer. You must always specify the instance name, even for default instances. For default instances, specify DEFAULT. The nodes after the instance name alternate between object classes (such as Database or View) and object names (such as AdventureWorks). Schemas are not represented as object classes. When you specify the node for a top-level object in a schema, such as a table or view, you must specify the object name in the format SchemaName.ObjectName.
This is the path of the Vendor table in the Purchasing schema of the AdventureWorks database in a default instance of the Database Engine on the local computer:
SQLSERVER:\SQL\localhost\DEFAULT\Databases\AdventureWorks\Tables\Purchasing.Vendor
For more information about the SMO object model hierarchy, see SMO Object Model Diagram.
Object class nodes in a path are associated with a collection class in the associated object model. Object name nodes are associated with an object class in the associated object model, as in the following table.
|
Path
|
SMO class
|
|---|
|
SQLSERVER:\SQL\MyComputer\DEFAULT\Databases
|
DatabaseCollection
|
|
SQLSERVER:\SQL\MyComputer\DEFAULT\Databases\AdventureWorks
|
Database
|
Whenever you reference an instance of the Database Engine in a path, the SQL Server provider uses SMO to open a Windows Authentication connection to the instance. The connection is made using the credentials of the Windows account running the Windows PowerShell session. The SQL Server provider does not use SQL Server Authentication.