[英]PowerShell Robocopy capture error message
When I use robocopy with invalid source directory I get the following message returned from PowerShell.当我使用带有无效源目录的 robocopy 时,我收到从 PowerShell 返回的以下消息。 My question is is the error message "2021/12/09 01:55:41 ERROR 3 (0x00000003) Accessing Source Directory c:\artifactTempDir....The system cannot find the path specified."
我的问题是错误消息“2021/12/09 01:55:41 ERROR 3 (0x00000003) Accessing Source Directory c:\artifactTempDir....系统找不到指定的路径。”
Is this stored in any variable?这是否存储在任何变量中? i am just trying to capture these two lines from the entire message.
我只是想从整个消息中捕获这两行。
Assuming that robocopy
writes its error messages to the stderr stream (which it should):假设
robocopy
将其错误消息写入标准错误stream (它应该):
$stdout, $stderr = (robocopy ... 2>&1).Where({ $_ -is [string] }, 'Split')
$stderr
now contains any stderr output (and $stdout
contains the stdout output). $stderr
现在包含任何标准错误 output(并且$stdout
包含标准输出输出)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.