PowerShell命令返回代码和状态

PowerShell命令返回代码和状态,powershell,Powershell,我正在Microsoft System Center Orchestrator PowerShell活动中运行以下命令: 安装WindowsFeature-ConfigurationFilePath C:\DeploymentConfigTemplate.xml-ComputerName ServerXYZ 命令没有执行它应该执行的操作,我希望能够返回命令是否成功,以及任何错误消息(如果可能)。忽略它在Orchestrator中运行的事实,因为我更关心PowerShell问题。当我从ISE运行命

我正在Microsoft System Center Orchestrator PowerShell活动中运行以下命令:

安装WindowsFeature-ConfigurationFilePath C:\DeploymentConfigTemplate.xml-ComputerName ServerXYZ

命令没有执行它应该执行的操作,我希望能够返回命令是否成功,以及任何错误消息(如果可能)。忽略它在Orchestrator中运行的事实,因为我更关心PowerShell问题。当我从ISE运行命令时,它会执行它应该执行的操作,这就是为什么我希望看到从PowerShell返回的内容


谢谢。

没有更多的上下文,很难知道会发生什么。以下内容将记录在xml文件中遇到的任何错误,您可以稍后使用import clixml导入该文件:

Install-WindowsFeature -ConfigurationFilePath C:\DeploymentConfigTemplate.xml -ComputerName ServerXYZ
IF (!($?)) {
    $error[0] | export-clixml C:\myerror.xml
    }

这就解决了我的问题:

$Result = Install-WindowsFeature -Name SNMP-Service -IncludeAllSubFeature -IncludeManagementTools
Write-Host $Result.ExitCode

谢谢你的回答。忘掉xml的东西吧。我只想知道
安装WindowsFeature
命令是否成功,以及是否显示返回消息。可能与写入主机一起显示。。。