当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何创建 Windows PowerShell 提供程序

作者:精品下载站 日期:2024-12-14 20:29:08 浏览:15 分类:玩电脑

如何创建 Windows PowerShell 提供程序


本节介绍如何构建 Windows PowerShell 提供程序。可以通过两种方式考虑 Windows PowerShell 提供程序。对于用户来说,提供者代表一组存储的数据。例如,存储的数据可以是 Internet 信息服务 (IIS) 元数据库、Microsoft Windows 注册表、Windows 文件系统、Active Directory 以及 Windows PowerShell 存储的变量和别名数据。

对于开发人员来说,Windows PowerShell 提供程序是用户和用户需要访问的数据之间的接口。从这个角度来看,本节中描述的每种类型的提供程序都支持一组特定的基类和接口,这些基类和接口允许 Windows PowerShell 运行时以通用方式向用户公开某些 cmdlet。

Windows PowerShell 提供的提供程序

Windows PowerShell 提供了多个用于访问已知数据存储的提供程序(例如文件系统提供程序、注册表提供程序和别名提供程序)。有关 Windows PowerShell 提供的提供程序的详细信息,请使用以下命令访问联机帮助:

PS>获取有关_providers的帮助

使用 Windows PowerShell 路径访问存储的数据

Windows PowerShell 提供程序可供 Windows PowerShell 运行时访问,并可通过使用 Windows PowerShell 路径以编程方式执行命令。大多数时候,这些路径用于通过提供者直接访问数据。但是,某些路径可以解析为提供程序内部路径,从而允许 cmdlet 使用非 Windows PowerShell 应用程序编程接口 (API) 访问数据。有关 Windows PowerShell 提供程序如何在 Windows PowerShell 中运行的详细信息,请参阅 Windows PowerShell 的工作原理。

使用 Windows PowerShell 驱动器公开提供程序 Cmdlet

Windows PowerShell 提供程序使用虚拟 Windows PowerShell 驱动器公开其支持的 cmdlet。 Windows PowerShell 对 Windows PowerShell 驱动器应用以下规则:

  • 驱动器的名称可以是任何字母数字序列。
  • 驱动器可以在路径上的任何有效点指定,称为“根”。
  • 驱动器可以用于任何存储的数据,而不仅仅是文件系统。
  • 每个驱动器都保留其自己的当前工作位置,允许用户在驱动器之间切换时保留上下文。

在这个部分

下表列出了包含相互构建的代码示例的主题。从第二个主题开始,基本的 Windows PowerShell 提供程序可以由 Windows PowerShell 运行时初始化和取消初始化,下一个主题添加用于访问数据的功能,下一个主题添加用于操作数据(存储数据中的项目)的功能,等等。

Designing Your Windows PowerShell Provider

本主题讨论在实施 Windows PowerShell 提供程序之前应考虑的事项。它总结了所使用的 Windows PowerShell 提供程序基类和接口。

Creating a Basic Windows PowerShell Provider

本主题演示如何创建允许 Windows PowerShell 运行时初始化和取消初始化提供程序的 Windows PowerShell 提供程序。

Creating a Windows PowerShell Drive Provider

本主题演示如何创建允许用户通过 Windows PowerShell 驱动器访问数据存储的 Windows PowerShell 提供程序。

Creating a Windows PowerShell Item Provider

本主题演示如何创建允许用户操作数据存储中的项目的 Windows PowerShell 提供程序。

Creating a Windows PowerShell Container Provider

本主题演示如何创建允许用户处理多层数据存储的 Windows PowerShell 提供程序。

Creating a Windows PowerShell Navigation Provider

本主题演示如何创建 Windows PowerShell 提供程序,该提供程序允许用户以分层方式导航数据存储的项目。

Creating a Windows PowerShell Content Provider

本主题演示如何创建允许用户操作数据存储中的项目内容的 Windows PowerShell 提供程序。

Creating a Windows PowerShell Property Provider

本主题演示如何创建允许用户操作数据存储中项目的属性的 Windows PowerShell 提供程序。

参见

Windows PowerShell 的工作原理

Windows PowerShell SDK

Windows PowerShell 程序员指南

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯