我需要绝对简单但显然完全不可能的东西。我需要在powershell中向stdout
写一些东西。
到目前为止,我只找到了write-output
,但不幸的是,它附加了linefeed
。我试图通过从stdout
获取.net
来以某种方式“破解”它,但我总是得到host stream
,但它并没有满足我的要求。
[没有人知道如何将例如1
写入stdout
的方法,所以当我通过管道将脚本1
准确地放在其他脚本的stdin
上时?我接受任何形式的破解,但是我不想像()sth>&1 | script
那样对调用进行重定向。
我非常疯狂,试图从我在Python脚本中执行的PowerShell命令中捕获PowerShell输出。而且它不起作用,因为PowerShell无法正确写入STDOUT。
但是我发现了一些方法...
首先使用PowerShell命令Write-Information
:
Write-Information -Message "This goes to Stdout" -InformationAction Continue
另一个是使用cmd启动PowerShell并捕获cmd的输出:
cmd.exe /C "powershell.exe -command "Write-Host 'This goes to Stdout'"