$Servers = Get-SPServer

# ————

# Begin script

# ————

ForEach ($Server in $Servers)

{

Write-Host “Services running on” $Server.Name “…”

$Table = New-Object System.Data.DataTable “$Server.Name”

$Column1 = New-Object System.Data.DataColumn “Service”,([String])

$Column2 = New-Object System.Data.DataColumn “Status”,([String])

$Table.Columns.Add($Column1)

$Table.Columns.Add($Column2)

$Services = $Server.ServiceInstances

ForEach ($Service in $Services)

{

$Row = $Table.NewRow()

$Row.Service = $Service.TypeName

$Row.Status = $Service.Status

$Table.Rows.Add($Row)

}

$Table | Format-Table –AutoSize

}