【发布时间】:2021-05-03 00:32:21
【问题描述】:
假设我有以下 PowerShell source:
PowerShell shell = PowerShell.Create().AddCommand("Get-NetAdapter")
.AddParameter("name", "Ethernet*")
.AddParameter("ThrottleLimit", 5);
现在,在调用shell.Invoke() 之前,我想检查一下最终的命令行,以用于记录目的。在这种情况下,我期望类似
Get-NetAdapter -name Ethernet* -ThrottleLimit 5
我测试了这些,但没有一个有效:
shell.Commands.ToString()
shell.Commands.Commands.ToString()
shell.Commands.Commands.First().CommandText
shell.Commands.Commands.First().ToString()
是否有一些内置方法可以检查最终命令行?
【问题讨论】:
标签: c# powershell .net-core powershell-core