如何创建 Windows PowerShell 管理单元
Windows PowerShell 管理单元提供了一种向 shell 注册 cmdlet 集和另一个 Windows PowerShell 提供程序的机制,从而扩展了 shell 的功能。 Windows PowerShell 管理单元可以在单个程序集中注册所有 cmdlet 和提供程序,也可以注册特定的 cmdlet 和提供程序列表。
管理单元程序集应安装在受保护的目录中,就像安装在其他操作系统中一样。否则,恶意用户可以用不安全的代码替换程序集。
Windows PowerShell 管理单元类
所有 Windows PowerShell 管理单元类均派生自 System.Management.Automation.PSSnapIn 或 System.Management.Automation.Custompssnapin 类。
示例
编写 Windows PowerShell 管理单元:此示例演示如何创建用于注册程序集中的所有 cmdlet 和提供程序的管理单元。
编写自定义 Windows PowerShell 管理单元:此示例演示如何创建自定义管理单元,用于注册单个程序集中可能存在或不存在的一组特定 cmdlet 和提供程序。
参见
系统.管理.自动化.PSSnapIn
系统.管理.自动化.Custompssnapin
注册 Cmdlet
Windows PowerShell 外壳 SDK