2024-04-01 10:40:20 +02:00

22 lines
439 B
PowerShell

# Restart Service Script
# Please enable external scripts and external scrips variable before use.
param (
[string[]]$serviceName
)
Foreach ($Service in $ServiceName)
{
Restart-Service $ServiceName -ErrorAction SilentlyContinue -ErrorVariable ServiceError
If (!$ServiceError) {
$Time=Get-Date
Write-Host "Restarted service $Service at $Time"
}
If ($ServiceError) {
write-host $error[0]
exit 3
}
}