Description

This script runs against a server.txt file of computer names , outputs a file containing the server name and information about services running on that server.


The output can be a csv file which can be readable on excel with all the computers from the input file. If you ever wanted to get more information about the service, add Class properties to Select-Object and Get-WmiObject.

Info on Win32_Service Class - http://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspxScript

PowerShell
Edit|Remove
function a{  
    param(  
    [Parameter(Mandatory=$true,valuefrompipeline=$true)]  
    [string]$Servers)  
    begin {}  
        Process { 
        ForEach ($Server in $Servers){ 
        $Result = New-Object psobject 
        $Result = Get-WmiObject Win32_Service displayname,startname,startmode,state -computername $Server 
        $Result | Add-Member noteproperty Server $Server 
        Write-Output $Result 
        } 
    } 
} 
Get-Content "Servers.txt" |a|Select-Object Server,Displayname,Startname,Startmode,State|Export-Csv ".\PS_services.csv" -NoTypeInformation