#########################################################################################
# #
# NAME: ListServices #
# VERSION: 1 #
# AUTHOR: Arjen Huitema #
# DATE: 05-12-2011 #
# COMMENT: Script Inventories running services. #
# #
#########################################################################################
# —————————————————————————————
# List services and status
# —————————————————————————————
if (-not ([appdomain]::CurrentDomain.getassemblies() |? {$_.ManifestModule -like "system.serviceprocess"})) {[void][System.Reflection.Assembly]::LoadWithPartialName(‘system.serviceprocess’)}
$servers=Get-Content C:Test.txt
function ListServices
{
$all = $null
foreach($s in $servers)
{
if ($all -eq $null) { $all = [System.ServiceProcess.ServiceController]::GetServices($s) }
else
{
$all = $all + [System.ServiceProcess.ServiceController]::GetServices($s)
}
}
return $all
}
ListServices | Format-Table -AutoSize -Property MachineName,DisplayName,Status
Deja un comentario