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

this is the install command to install agents from power shell script

  1. $mgmtServer - is the primary management server.

  2. $AgentsDiscovered - is array of computer names that are discovered and on whom agent is to be installed.

  3. $Credential - contains the credential necessary for installation.

Agents are getting installed. I want the agents installed successfully to be logged into a file.

How to get the return values of Install-SCOMAgent Command to verify if agents are installed successfully or not.

Paul
  • 5,524
  • 1
  • 22
  • 39

2 Answers2

1

You can add this block code on your script

$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} }

0

The parameter -PassThru will output objects to the pipeline, so this allows you to pipe them to other cmdlets, or to store them into a variable.

I guess this will output one object per computer in $AgentsDiscovered .

Mathieu Buisson
  • 1,325
  • 10
  • 8