title: How to add/replace psobject
body: <p>I am trying to write a script about the state of the server hardware</p>
  
  <p>The following functions have been completed.</p>
  
  <p>Get-SummaryStatus.ps1 </p>
  
  <p>Get-Memory.ps1</p>
  
  <p>Get-PowerSupply.ps1</p>
  
  <p>Get-Proecssor.ps1</p>
  
  <p>Get-Fanstatus.ps1</p>
  
  <pre><code>
  Get-SummaryStatus.ps1 output is
  Server         ServerStatus                  
  ------         ------------                  
  AAA            {System.Collections.Hashtable}
  
  $report.server output is 
  AAA
  
  $report.serverstatus output is 
  Name                           Value                                                                                                            
  ----                           -----                                                                                                            
  MemoryStatus                   OK                                                                                                                                                                                                                                                                                                                                             
  PowerStatus                    OK                                                                                                               
  ProcessorStatus                OK                                                                                                               
  Fanstatus                      OK
  
  </code></pre>
  
  <p>Get-Memory.ps1 output is </p>
  
  <p>Server         MemoryStatus<br>
  ------         ------------<br>
  AAA           {System.Collections.Hashtable, System.Collections.Hashtable}</p>
  
  <p>$report.server output is </p>
  
  <p>AAA</p>
  
  <p>$report.MemoryStatus output is </p>
  
  <p>Name                           Value<br>
  ----                           -----<br>
  MemoryID                       1<br>
  MemoryStatus                   OK<br>
  MemoryID                       2<br>
  MemoryStatus                   OK</p>
  
  <pre><code>
  Get-PowerSupply.ps1 output is
  
  Server         MemoryStatus                                                
  ------         ------------                                                
  AAA           {System.Collections.Hashtable, System.Collections.Hashtable}
  
  $report.server output is 
  
  AAA
  
  
  $report.PowerStatus output is 
  
  Name                           Value                                                                                                            
  ----                           -----                                                                                                            
  PowerID                       1                                                                                                               
  PowerStatus                   OK                                                                                                               
  PowerID                       2                                                                                                               
  PowerStatus                   OK
  
  </code></pre>
  
  <p>Get-Proecssor.ps1 output Similar to the three above</p>
  
  <p>Get-Fanstatus.ps1 output Similar to the three above</p>
  
  <p>Duo to I have more than 1000 services that need to be monitored, So I want to make the following steps to improve efficiency.</p>
  
  <p>I created a new main function（ServerHealthCheck） and call all sub-founcitons(summary,memory,power...) to main function. (completed)</p>
  
  <p>If the summary state are OK, and then output summarystatus. (completed.)</p>
  
  <p>If Summary memory status is failed. and then will call Get-Memory.ps1 to find which memory is bad.(completed)</p>
  
  <p>If Summary power status is failed. and then will call Get-powersupply.ps1 to find which powersupply is bad.(completed.)</p>
  
  <p>if One of the hardware was failed , I want to rearrange a new object. </p>
  
  <p>my question is How to add/replace object to get expected output? thanks in advance.</p>
  
  <pre><code>Expected output(if summary memory status is failed):
  
  Server         ServerStatus                  
  ------         ------------                  
  AAA            {System.Collections.Hashtable}
  
  $report.server output is 
  AAA
  
  $report.serverstatus output is
  
  Name                           Value                                                                                                            
  ----                           -----                                                                                                            
  MemoryID                       1   
  MemoryStatus                   failed                                                                                                                                                                                                                                                                                                                       
  PowerStatus                    OK                                                                                                               
  ProcessorStatus                OK                                                                                                               
  Fanstatus                      OK
  
  
  </code></pre>