title: Populate existing array/table with new data
body: <p>I'm still at the beginning of learning powershell. My goal here is to have a script that pulls SCOM alerts that are one day old, compares the alerts' netbios computer name to a value from a CSV that I will import.</p>
  <p>If the ServerName from the CSV Matches the NetbiosName it then adds the Administrator Name to the original Array/Table I created. Currently it does everything I ask of it, but when I have it output the final data it only has the last administrator that was used added to the Admin column instead of the appropriate admin.</p>
  <blockquote>
  <p>NetbiosComputerName         : Server</p>
  <p>MonitoringObjectDisplayName : Server.Domain</p>
  <p>Name                        : Blah Blah Blah</p>
  <p>Severity                    : Warning</p>
  <p>ResolutionState             : 0</p>
  <p>RepeatCount                 : 0</p>
  <p>Server Adminstrator         : Admin</p>
  <hr />
  <p>NetbiosComputerName         : Server</p>
  <p>MonitoringObjectDisplayName : Server.Domain</p>
  <p>Name                        : Blah Blah Blah</p>
  <p>Severity                    : Warning</p>
  <p>ResolutionState             : 0</p>
  <p>RepeatCount                 : 0</p>
  <p>Server Adminstrator         : Admin</p>
  </blockquote>
  <p>On the Second output the Admin should instead reflect the admin for that particular server and not very same one.</p>
  <p>Here is my code.</p>
  <pre><code>     # Load SCOM snap-in
  add-pssnapin &quot;Microsoft.EnterpriseManagement.OperationsManager.Client&quot;;
  $server = &quot;RMSSERVER&quot;
  
  # Connect to OpsMgr SDK - change management server to your RMS
  new-managementGroupConnection -ConnectionString:RMSSERVER.domain;
  set-location &quot;OperationsManagerMonitoring::&quot;;
  
  $Date = (Get-Date).adddays(-1)
  
  $ScomAlert = get-alert | where {($_.ResolutionState -eq 0) -and ($_.TimeRaised -gt $Date)  } | Select NetbiosComputerName,MonitoringObjectDisplayName, Name,Severity, ResolutionState, RepeatCount
  $Administrators = Import-CSV &quot;C:\Script\SCOM\admin.csv&quot;
  $TableSC = $ScomAlert
  
  
  
  ForEach ($Alert in $ScomAlert)
  {
      $NetBios       = &quot;$($Alert.NetBiosComputerName)&quot;
      $MonObjectName = &quot;$($Alert.MonitoringObjectDisplayName)&quot;
      $AlertName     = &quot;$($Alert.Name)&quot;
      $Severity      = &quot;$($Alert.Severity)&quot;
      $ResState      = &quot;$($Alert.ResolutionState)&quot;
      $RepCount      = &quot;$($Alert.RepeatCount)&quot;
     
  
          ForEach ( $Admin in $Administrators ) 
         {
              $ServerName  = &quot;$($Admin.ServerName)&quot;
              $ServerAdmin = &quot;$($Admin.AdminName)&quot;
             
              if($ServerName -eq $NetBios)
              {
                 $ServerAdministrator = $ServerAdmin    
                 
              } 
           
         }
      
       $TableSC | Add-Member -MemberType NoteProperty -Name &quot;Server Adminstrator&quot; -Value $ServerAdministrator -Force
    
      
  }
  </code></pre>