简体   繁体   English

在Powershell中如何使来自cmdlet的内联脚本消息静音

[英]In Powershell How do I silence inlinescript messages from cmdlet

I have a script that uses workflow and inline scripts. 我有一个使用工作流和内联脚本的脚本。

Here is an example 这是一个例子

workflow PingExample ($computerNames) {
   foreach -parallel ($computerNames in $y)
   inlinescript { $PingM = New-Object System.Net.NetworkInformation.Ping
                $pingObj = $PingM.Send($using:comp)}
   return $pingObj
   }

The problem is that PowerShell cmdlet is flashing up messages like: - 问题在于,PowerShell cmdlet会刷新如下消息:-

Inlinescript
       Running
1.6.5   PingExample : Line 1 char 6

As there are parallel processes running the messages constantly strobing on the screen. 由于存在并行进程,因此消息不断在屏幕上闪烁。

How can I silence these messages? 如何使这些消息静音?

Thanks in advance. 提前致谢。

In the example you gave, there's a return. 在您给出的示例中,有回报。 When running code like that directly in powershell, it's expected that the return will show up in the pipeline. 当直接在Powershell中运行这样的代码时,预期返回值将显示在管道中。 You could simply remove the return or you could looping the command through something like invoke-command. 您可以简单地删除返回值,也可以通过诸如invoke-command之类的命令循环执行该命令。 My guess is that you're probably trying to capture those returns. 我的猜测是您可能正在尝试获取这些回报。 Maybe assigning a variable before the workflow could work? 也许在工作流可以工作之前分配一个变量? That way, you can inspect the returns in the variable? 这样,您可以检查变量中的收益吗?

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

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