Issue
Code backup
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
##########################
|
||||
# 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)
|
||||
Reference in New Issue
Block a user