Files
claudio 368d6fafea Issue
Code backup
2026-05-10 16:59:01 +02:00

42 lines
1011 B
PowerShell

##########################
# Writer: Claudio Boggian
# Company: PAL s.r.l.
#-------------------------
# Date: 2023/08/25
# v: 1.0
# Reason: Emission
#-------------------------
##########################
$Services = Get-WmiObject win32_service -Filter "startmode = 'auto' AND state != 'running'"
$i = 0
$objs = $null
if ($Services){
foreach ($Service in $Services) {
# Exclude Triggered
if(!(Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\$($Service.Name)\TriggerInfo\"))
{
$i++
$objs += @(New-Object -TypeName PSObject -Property @{
Name = $Service.Name
Status = $Service.State
StartMode = $Service.StartMode
})
}
}
}
if ($i -ne 0){
Write-Output "$($i) Services is not running!"
Write-Output $objs
$exitcode = 2 #error
} else {
Write-Output "All Services are up and running!"
$exitcode = 0 #ok
}
exit ($exitcode)