How to check windows server service status on remote servers through powershell

D Vijayakumar VLR 126 Reputation points
2021-05-22T05:35:17.127+00:00

Hi All,

I want to know windows service status is running or not running on multiple remote servers and the output is servername, service name, status, displayname, startup type in excel or csv file if service is runnig comes green, not running or stopped comes red

Windows for business Windows Server User experience PowerShell
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2021-05-22T08:31:49.813+00:00

    Hi @D Vijayakumar VLR ,

    You have asked the same question before and received answers to it. There is little point in repeating the questions.
    https://learn.microsoft.com/en-us/answers/questions/334116/how-to-check-service-status-are-running-or-stopped.html

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  2. Anonymous
    2021-05-24T08:20:52.99+00:00

    Hi,

    Please see if this works.

    $file = "C:\temp\processes.csv"  
    $computers =("computer1","computer2","computer3")  
    Get-service -ComputerName $computers | Select-Object MachineName, Name, DisplayName, Status, StartType | ForEach-Object{  
        if($_.Status -eq "Running") {  
            Write-Host $_.MachineName,$_.Name, $_.DisplayName, $_.Status, $_.StartType -ForegroundColor Green          
        }  
        else{  
            Write-Host $_.MachineName,$_.Name, $_.DisplayName, $_.Status, $_.StartType -ForegroundColor Red  
        }  
        $_   
    } | Export-Csv -NoTypeInformation -Path $file  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.