将Powershell命令输出捕获到变量

时间:2019-07-18 05:44:22

标签: azure powershell

我正在尝试在Windows上安装azure IoT Edge运行时。我正在关注Install and start the IoT Edge runtime上的Microsoft文档。文档告诉您如何在Powershell中运行命令。我想将以下命令的输出保存到变量中,以便可以检查天气安装是否成功

. {Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; `Deploy-IoTEdge -ContainerOs Windows

我已经尝试过这里介绍的几种解决方案

How do I capture the output into a variable from an external process in PowerShell?

How to capture output in a variable rather than a logfile?

修改

作为上述命令的输出,我的错误越来越小

    Exception setting "OutputEncoding": "The handle is invalid.
"
At line:3 char:1
+ [Console]::OutputEncoding = New-Object -typename System.Text.ASCIIEnc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting


ModuleType Version    Name                                ExportedCommands                                                  
---------- -------    ----                                ----------------                                                  
Script     0.0        IoTEdge                             {Deploy-IoTEdge, Get-IoTEdgeLog, Initialize-IoTEdge, Install-Io...
The container host is on unsupported build version 17134.
Please use a container host running one of the following build versions for running Windows containers:
17763

The prerequisites for installation of the IoT Edge Security daemon are not met. Please fix all known issues before rerunning 
this script.

任何帮助将不胜感激。

0 个答案:

没有答案