通过powershell返回SCOM Install命令的值

时间:2014-12-26 09:04:41

标签: powershell scom

Install-SCOMAgent 
-PrimaryManagementServer $MgmtServer 
-DNSHostName $AgentDiscovered
-ActionAccount $Credential

这是从power shell脚本安装代理的安装命令

  1. $mgmtServer - 是主要管理服务器。

  2. $AgentsDiscovered - 已发现的计算机名称数组以及要安装代理程序的数组。

  3. $Credential - 包含安装所需的凭据。
  4. 正在安装代理。我希望成功安装代理程序登录到文件中。

    如何获取Install-SCOMAgent命令的返回值以验证代理是否已成功安装。

2 个答案:

答案 0 :(得分:1)

您可以在脚本上添加此块代码

$test_installation = Get-SCOMAgent -DNSHostName $AgentDiscovered if ($test_installation -eq $null) {write-host $AgentDiscovered " is not installed on SCOM "$MgmtServer } else { if ($test_installation -eq "success") {write-host $AgentDiscovered " is healthy and installed on SCOM server "$MgmtServer } else {write-host $AgentDiscovered " is not healthy but installed on SCOM server "$MgmtServer} }

答案 1 :(得分:0)

参数-PassThru会将对象输出到管道,因此这允许您将它们传输到其他cmdlet,或将它们存储到变量中。

我想这会在$ AgentsDiscovered中为每台计算机输出一个对象。