Unable to output green/red status to pc’s in AD

Welcome Forums General PowerShell Q&A Unable to output green/red status to pc’s in AD

Viewing 3 reply threads
  • Author
    Posts
    • #218031
      Participant
      Topics: 4
      Replies: 10
      Points: 51
      Rank: Member

      I manage to get the data from AD successfully but i am unable to colour coordinate the output to green/red in the status field.
      Once that is completed i need to send it via email.
      If someone can help it will be appreciated

      $comps = Get-ADComputer -Filter "Location -like '*Conference Room*'" -Properties name, location
      $result = foreach ($comp in $comps) {
          [PSCustomObject]@{
              ComputerName = $comp.Name
              Location = $comp.Location
              Status = Test-Connection -ComputerName $comp.Name -Quiet -Count 1
      } 
      }
      
      $result
      
      
    • #218037
      Participant
      Topics: 3
      Replies: 314
      Points: 1,030
      Helping Hand
      Rank: Community Hero

      How have you tried to color coordinate them? Your code doesn’t have anything related to colors. Have you searched the forums? Someone asked practically the same question a few days ago.

    • #218040
      Participant
      Topics: 4
      Replies: 10
      Points: 51
      Rank: Member
      $comps = Get-ADComputer -Filter "Location -like '*Conference Room*'" -Properties name, location
      
      $result = foreach ($comp in $comps){
      
      
          [PSCustomObject]@{
              ComputerName = $comp.Name
              Location = $comp.Location
              Status = Test-Connection -ComputerName $comp.Name -Quiet -Count 1 }
              }
      
       if ($svc.State -eq 'False' -and $svc.StartMode -eq 'False') { $svccolor = 'red' } `
              elseif ($svc.State -eq 'True') { $svccolor = 'green' } `
              else { $svccolor = '' }
      
              $props = @{'Service Name' = $svc.Name;
                         'Display Name' = $svc.DisplayName;
                         'Start Mode'= $svc.StartMode;
                         'State' = $svc.State;
                         'Color' = $svccolor}
              New-Object -TypeName PSObject -Property $props
         
      
              $result
      
    • #218055
      Participant
      Topics: 4
      Replies: 2231
      Points: 5,414
      Helping Hand
      Rank: Community MVP

      Have you searched the forums? Someone asked practically the same question a few days ago.

      Doug, it was her/him asking this question … Unable to get a nice clear output HELP 🙁 … that’s why I think your question is absolutely legit. 😉

      @uthoma20 There is no easy/simple/magic/built in way to achieve what you’re asking for. Powershell is made for admins not for managers. Admins do not need colors – managers do. 😉 People have been there where you are at the moment and they tried to make it easier for others. But you will have to go the rest of the way yourself. Read the available free books, follow the links we’ve given to you and start coding. That’s how we all do it – it’s called try and error. You might search the PowershellGallery for something helpful or almost fitting and adapt it to your special needs. Sorry, we will not develop a ready to use solution for you.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.