Scan ad for new servers + if specific service is running on them

Welcome Forums General PowerShell Q&A Scan ad for new servers + if specific service is running on them

  • This topic has 3 replies, 3 voices, and was last updated 2 weeks ago by
    Participant
    .
Viewing 3 reply threads
  • Author
    Posts
    • #272164
      Participant
      Topics: 3
      Replies: 4
      Points: 46
      Rank: Member

      Hi everyone
      I have script that is scanning my DC for new servers that has been added to my domain + sending an email with the Name, IP and OS of the new server.

      What I am looking, is how can i add a line to this script that will check if those new servers has specific Service running on them?

      The output that I’m receiving to the email now is:

      Dear IT Team,
      Weekly AD  scan for new servers:

      Name IPv4Address OperatingSystem
      testsrv x.x.x.x Windows Server 2016 Standard

      So i want somehow to add here a “Service” tab that will say “Servicename” running or no, in those servers.

      The script:

      • This topic was modified 2 weeks ago by kobeat50.
      • This topic was modified 2 weeks ago by kvprasoon. Reason: code formatting https://powershell.org/forums/topic/guide-to-posting-code-2/
    • #272179
      Participant
      Topics: 5
      Replies: 170
      Points: 656
      Helping Hand
      Rank: Major Contributor

      After you instantiate $computers, add this loop to add a property that is true or false depending on if the service is running on each computer.  Then you can just add the Service_Running property to your Select-Object and ConvertTo-Html cmdlets.

       

    • #272191
      Participant
      Topics: 16
      Replies: 1855
      Points: 3,568
      Helping Hand
      Rank: Community Hero

      Another option is using calculated expressions:

    • #272200
      Participant
      Topics: 5
      Replies: 170
      Points: 656
      Helping Hand
      Rank: Major Contributor

      I like Rob’s better.  I don’t know why I didn’t think of that.  Really only one additional line of code to existing script.

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