fix stuck service tweaks

This commit is contained in:
Chris Titus 2022-10-18 08:21:44 -05:00
parent d586219192
commit bd43288f99

View File

@ -569,9 +569,12 @@
Write-Logs -Level INFO -Message "Starting Services Modification" -LogPath $sync.logfile Write-Logs -Level INFO -Message "Starting Services Modification" -LogPath $sync.logfile
$ServicesToModify | ForEach-Object { $ServicesToModify | ForEach-Object {
Stop-Service "$($psitem.name)" $service = Get-Service -Name W32Time -ErrorAction SilentlyContinue
Set-Service "$($psitem.name)" -StartupType $($psitem.StartupType) if ($service.Length -gt 0) {
Write-Logs -Level INFO -Message "Service $($psitem.name) set to $($psitem.StartupType)" -LogPath $sync.logfile Stop-Service "$($psitem.name)"
Set-Service "$($psitem.name)" -StartupType $($psitem.StartupType)
Write-Logs -Level INFO -Message "Service $($psitem.name) set to $($psitem.StartupType)" -LogPath $sync.logfile
}
} }
Write-Logs -Level INFO -Message "Finished setting Services" -LogPath $sync.logfile Write-Logs -Level INFO -Message "Finished setting Services" -LogPath $sync.logfile