claude-home/monitoring/scripts/windows-desktop/windows-setup-instructions.md
Cal Corum 4b7eca8a46
All checks were successful
Reindex Knowledge Base / reindex (push) Successful in 3s
docs: add YAML frontmatter to all 151 markdown files
Adds title, description, type, domain, and tags frontmatter to every
doc for improved KB semantic search. The description field is prepended
to every search chunk, and domain/type/tags enable filtered queries.

Type values: context, guide, runbook, reference, troubleshooting
Domain values match directory structure (networking, docker, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 09:00:44 -05:00

144 lines
4.4 KiB
Markdown

---
title: "Windows Reboot Monitor Setup"
description: "Installation and configuration guide for Windows reboot/shutdown Discord notifications using PowerShell scripts and Task Scheduler, including webhook setup, testing, and uninstallation."
type: guide
domain: monitoring
tags: [windows, powershell, discord, webhook, task-scheduler, reboot, setup]
---
# Windows Reboot Monitor Setup Instructions
This guide will help you set up Discord notifications for Windows reboots due to updates, power outages, or other events.
## Prerequisites
1. **Discord Webhook URL**: Create a webhook in your Discord server
- Go to Server Settings → Integrations → Webhooks
- Create a new webhook and copy the URL
2. **Administrator Access**: Required to set up scheduled tasks
## Installation Steps
### Step 1: Create Scripts Directory
```powershell
# Run as Administrator
New-Item -ItemType Directory -Path "C:\Scripts" -Force
```
### Step 2: Copy PowerShell Script
1. Copy `windows-reboot-monitor.ps1` to `C:\Scripts\`
2. Set execution policy (if needed):
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
```
### Step 3: Configure Discord Webhook
Option A - Environment Variable (Recommended):
```powershell
# Set system environment variable
[Environment]::SetEnvironmentVariable("DISCORD_WEBHOOK_URL", "YOUR_WEBHOOK_URL_HERE", "Machine")
```
Option B - Direct parameter:
- Edit the Task Scheduler XML files to include your webhook URL in the arguments
### Step 4: Import Scheduled Tasks
```powershell
# Import startup monitoring task
schtasks /create /xml "C:\path\to\windows-reboot-task-startup.xml" /tn "Discord Reboot Monitor - Startup"
# Import shutdown monitoring task
schtasks /create /xml "C:\path\to\windows-reboot-task-shutdown.xml" /tn "Discord Reboot Monitor - Shutdown"
```
### Step 5: Test the Setup
```powershell
# Test startup notification
C:\Scripts\windows-reboot-monitor.ps1 -EventType "startup"
# Test shutdown notification
C:\Scripts\windows-reboot-monitor.ps1 -EventType "shutdown"
```
## What You'll Get
### Startup Notifications (Green/Red)
- **Green**: Normal startup with boot reason and uptime info
- **Red**: Unexpected restart (power loss, crash, etc.)
### Shutdown Notifications (Yellow)
- System going offline with uptime and shutdown reason
### Information Included
- Computer name
- Timestamp
- Boot/shutdown reason (Windows Update, power loss, user initiated)
- System uptime
- Startup counter
## Troubleshooting
### Check Logs
View logs at: `C:\Windows\Temp\reboot-monitor.log`
### Verify Tasks are Running
```powershell
# List scheduled tasks
Get-ScheduledTask | Where-Object {$_.TaskName -like "*Discord Reboot*"}
# Check task history
Get-WinEvent -LogName "Microsoft-Windows-TaskScheduler/Operational" | Where-Object {$_.LevelDisplayName -eq "Error"}
```
### Test Discord Webhook
```powershell
# Manual test
$webhook = "YOUR_WEBHOOK_URL"
$payload = @{content = "Test message from Windows"} | ConvertTo-Json
Invoke-RestMethod -Uri $webhook -Method Post -Body $payload -ContentType "application/json"
```
### Common Issues
1. **PowerShell Execution Policy**: Run `Set-ExecutionPolicy RemoteSigned`
2. **Network Issues**: Ensure Windows can reach Discord (discord.com)
3. **Permissions**: Run PowerShell as Administrator for setup
4. **Webhook URL**: Verify the Discord webhook URL is correct
### Event Log Monitoring
The script monitors these Windows events:
- **Event ID 1074**: System shutdown/restart
- **Event ID 6008**: Unexpected shutdown
- **Boot events**: System startup
## Security Notes
- Script runs with SYSTEM privileges for reliable monitoring
- Webhook URL is stored securely in environment variables or config
- Logs are stored in Windows temp directory
- No sensitive system information is transmitted
## Customization
Edit `windows-reboot-monitor.ps1` to:
- Change Discord message format
- Add additional system information
- Modify notification colors
- Adjust logging behavior
- Add email notifications as backup
## Uninstallation
```powershell
# Remove scheduled tasks
schtasks /delete /tn "Discord Reboot Monitor - Startup" /f
schtasks /delete /tn "Discord Reboot Monitor - Shutdown" /f
# Remove files
Remove-Item -Path "C:\Scripts\windows-reboot-monitor.ps1" -Force
Remove-Item -Path "C:\Windows\Temp\reboot-monitor.*" -Force
# Remove environment variable
[Environment]::SetEnvironmentVariable("DISCORD_WEBHOOK_URL", $null, "Machine")
```