Get Stopped Automatic Services
Get-Service |
Where-Object { $_.Status -eq 'Stopped' -and $_.StartType -eq 'Automatic' }
Set Execution Policy
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
Restart LTServices (ConnectWise Automate)
# Stop related processes
$processes = "ltsvcmon","ltsvc","lttray","labvnc","labtechupdate"
Stop-Process -Name $processes -Force -ErrorAction SilentlyContinue
# Restart services
$services = "ltsvcmon","labvnc","ltservice"
Restart-Service -Name $services -Force -ErrorAction SilentlyContinue
Scheduled Tasks Run in Last 30 Days
$cutoff = (Get-Date).AddDays(-30)
Get-ScheduledTask | ForEach-Object {
$info = Get-ScheduledTaskInfo $_
[PSCustomObject]@{
TaskName = $_.TaskName
State = $_.State
LastRunTime = $info.LastRunTime
TaskPath = $_.TaskPath
}
} | Where-Object { $_.LastRunTime -ge $cutoff } |
Sort-Object LastRunTime |
Format-Table -AutoSize
Common LastTaskResult codes:
| Code | Meaning | | :
| :
|
|
0 | Success ✅ |
| 1 | Generic failure ⚠️ |
| 2147942402 | File not found 📂 |
| 2147943726 | Logon failure 🔐 |Who Rebooted the Server
Get-EventLog -Log System -Newest 100 |
Where-Object { $_.EventID -eq '1074' } |
Format-Table MachineName, UserName, TimeGenerated -AutoSize