简体   繁体   English

从C#创建PowerShell cmdlet

[英]Creating PowerShell cmdlet from C#

I am using Visual Studio 2010 Ultimate Beta 2. What is the relevant namespace/classes for creating a PowerShell cmdlet in C#? 我正在使用Visual Studio 2010 Ultimate Beta2。在C#中创建PowerShell cmdlet的相关名称空间/类是什么?

I assume there is an interface or abstract class to derive from. 我假设有一个派生自的接口或抽象类。

You'll need to derive from System.Management.Automation.Cmdlet . 您需要从System.Management.Automation.Cmdlet派生。

It lives in system.management.automation.dll. 它位于system.management.automation.dll中。 If you're on Windows Vista or newer, the file's in your GAC, which can be referenced but it's tricky. 如果您使用的是Windows Vista或较新的文件在您的GAC,它可以被引用,但它的棘手。 It's probably easiest to install the PowerShell SDK , and then you can reference the assembly directly from "Add Reference..." in Visual Studio. 安装PowerShell SDK可能是最简单的,然后您可以直接从Visual Studio中的“添加引用...”引用程序集。 (Full path is C:\\Program Files\\Reference Assemblies\\Microsoft\\WindowsPowerShell\\v1.0 .) (完整路径为C:\\Program Files\\Reference Assemblies\\Microsoft\\WindowsPowerShell\\v1.0 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM