c# - 如何在 C# 中验证 PowerShell 脚本语法?

标签 c# .net powershell

我有一个生成 powershell 脚本的 C# 方法。

有没有办法在终端客户端上运行之前直接在 C# 中自动验证生成的脚本的语法?

最佳答案

您可以可能使用 Parser.ParseFile PowerShell SDK 中的方法,可能Microsoft.PowerShell.SDK 中找到小块

注意:我从未使用过这个并且完全没有经过测试,老实说我不知道​​这是否适合你。

关于c# - 如何在 C# 中验证 PowerShell 脚本语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62886094/

相关文章:

c# - 在 Windows Mobile 上访问可用 Wifi 应用程序列表

C# HTTP Post代码导致工作进程挂起

c# - DLL导入: Unable to find Entry Point "fnMultiply" in DLL "ImportDLL"

c# - 我应该从 SQL CLR 函数中使用 EF6

powershell - SSRS 和 PowerShell : Create and set schedule for reports?

powershell - 有没有办法在使用写输出时指定字体颜色

c# - 如何在服务器端检测客户端的超时异常?

.net - C# 中使用 Task 和 Task<TResult> 有什么区别

.net - 使用模块来处理表单类元素是否正确?

C# 到 Powershell