简体   繁体   English

在 Python 中动态写入 PowerShell CmdLets

[英]Writing PowerShell CmdLets in Python Dynamically

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.我希望能够使用 IronPython 编写 PowerShell CmdLets,此外,我需要一个 CmdLet 来查看环境并根据内容将 CmdLets 添加到 PowerShell 中。 For example, reading a directory, and adding a CmdLet Remove- for every filename it sees there.例如,读取一个目录,并为它在那里看到的每个文件名添加一个 CmdLet Remove-。

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.这里的问题是 IronPython class 不是 CLR class 或与 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. 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.

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

相关问题 使用PowerShell CmdLets进行交互 - Interoping With PowerShell CmdLets 是否有记录 Powershell 6.0 cmdlet 构建的位置? - Is there a location where the construction of Powershell 6.0 cmdlets are documented? Powershell导入自定义C#CMDlet,没有可用的“ExportedCommands” - Powershell Importing custom C# CMDlets, no available “ExportedCommands” 如何通过 PowerShell cmdlet 将 REG_DWORD 值的基数从十六进制更改为十进制? - How do I change a REG_DWORD value's base from Hexadecimal to Decimal via PowerShell cmdlets? 运行PowerShell cmdlet(函数?)的代码,该cmdlet位于cmpsts的.ps1文件中(函数?) - Code to run a PowerShell cmdlet (function?) that lives in a .ps1 file of cmdlets (functions?) 如果我使用 enter/import-pssession cmdlet,为什么在远程计算机(使用参数)上以编程方式 (C#) 执行 powershell cmdlet 不起作用? - Why executing powershell cmdlets programmatically (C#) on remote machine (using arguments) doesn't work if I use enter/import-pssession cmdlets? 动态写入列表 - Dynamically Writing to a List 动态获取Powershell中的class信息 - Dynamically retrieve class information in Powershell 测试自己的cmdlet - Test own cmdlets 为从 Powershell 动态创建的 .NET CheckBox 动态创建 EventHandler - Dynamically create EventHandler for a dynamically created .NET CheckBox from Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM