none
PowerShell Script to find windows service status on multiple server RRS feed

  • Question

  • ############################################################
    # This script to find the Service Status on the list of computers.This script will generate a CSV file 

    #input the servers list in servers.txt

    # Author: Amit Hanamannavar
    ############################################################

    $servers = Get-Content C:\Temp\servers.txt
    $Service = Read-Host "Enter the Service Name"

    $result=foreach($server in $servers) {

    Get-Service -Name $Service -ComputerName $server | Select-Object @{n="HostName";e={$server}},@{n="ServiceName";e={$Service}},Status

    }
    $result | Export-Csv C:\Temp\ServiceStatus.csv -NoTypeInformation 

    Tuesday, June 30, 2020 8:35 AM

All replies

  • Is there any question or do you just wanted to share this snippet with the world?

    If you post code you should format it as code please: How to Use the Code Feature in a TechNet Forum Post


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Tuesday, June 30, 2020 8:45 AM
    Tuesday, June 30, 2020 8:44 AM
  • $service = Read-Host 'Enter the Service Name'
    Get-Content servers.txt |
        ForEach-Object{
            Get-Service -Name $service -ComputerName $_ 
        } |
        Select-Object MachineName,ServiceName,Status | 
        Export-Csv C:\Temp\ServiceStatus.csv -NoTypeInformation 
    
    

    \_(ツ)_/




    • Edited by jrv Tuesday, June 30, 2020 9:43 AM
    Tuesday, June 30, 2020 9:40 AM