在 Python 中动态编写 PowerShell CmdLets
我希望能够使用 IronPython 编写 PowerShell CmdLets,此外,我需要一个 CmdLet 来查看环境并根据内容将 CmdLets 添加到 PowerShell。例如,读取目录,并为其在其中看到的每个文件名添加 CmdLet Remove- 。
I want to be able to write PowerShell CmdLets using IronPython, and furthermore I need one CmdLet to look at the environment and add CmdLets to the PowerShell based on the contents. For example, reading a directory, and adding a CmdLet Remove- for every filename it sees there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知这是不可能的!
这里的问题是 IronPython 类不是 CLR 类或与 CLR 类兼容。 CLR 类是静态的,而 IronPython 类是动态的,据我所知,DLR 不提供具有 .net CLR 属性的 IronPython 类,而 CMDLET 开发需要这些属性。
As far as I know it can't be done!
The problem here is that an IronPython class is not a CLR class or compatible with a CLR class. A CLR class is static and an IronPython class is dynamic and the DLR, as far as I know, doesn't for example provide IronPython classes to have .net CLR attributes, which you need for CMDLET development.