L

Lararu.Blog

Make It Happen.

  • 首页
  • DEVOPS
  • Python-Dev
  • Docker
  • 关于
Home Windows 11 上实现开关机时自动推送消息到 Gotify
文章

Windows 11 上实现开关机时自动推送消息到 Gotify

Posted 3 days ago Updated 3 days ago
By Administrator
3~4 min read

🛠️ 实现步骤

1. 获取 Gotify API 信息

  • 你需要 Gotify 的 服务器地址(例如 http://your-gotify-server.com)

  • 你的 应用 Token(在 Gotify 管理后台生成)

2. 编写 PowerShell 脚本

创建一个 .ps1 文件,例如 gotify_notify.ps1,内容如下:

param(
    [string]$EventType = "Unknown"
)

# Gotify 配置
$gotifyUrl = "http://your-gotify-server.com/message"
$token = "YOUR_GOTIFY_APP_TOKEN"

# 推送内容
$payload = @{
    title = "Windows 11 通知"
    message = "电脑已$EventType"
    priority = 5
} | ConvertTo-Json

# 发送请求
Invoke-RestMethod -Uri $gotifyUrl -Method Post -Headers @{ "X-Gotify-Key" = $token } -Body $payload -ContentType "application/json"

3. 设置任务计划程序触发器

  1. 打开 任务计划程序 (taskschd.msc)

  2. 创建两个任务:

    • 开机通知

      • 触发器:在系统启动时

      • 操作:运行 powershell.exe -File "C:\path\to\gotify_notify.ps1" -EventType "开机"

    • 关机通知

      • 触发器:在事件日志中(系统 → 事件 ID 1074 表示关机/重启)

      • 操作:运行 powershell.exe -File "C:\path\to\gotify_notify.ps1" -EventType "关机"

License:  CC BY 4.0
Share

Further Reading

OLDER

爬虫 coupang 상품판매 및 배송제공업체

NEWER

Recently Updated

  • Windows 11 上实现开关机时自动推送消息到 Gotify
  • 爬虫 coupang 상품판매 및 배송제공업체
  • docker部署faved 书签管理
  • docker compose部署wordpress
  • 侧柏叶提取物

Trending Tags

Python-dev Ubuntu Database PVE DevOps Docker Docker-compose

Contents

©2025 Lararu.Blog. Some rights reserved.

Using the Halo theme Chirpy