Windows ortamında sistem yöneticilerinin en güçlü silahı PowerShell'dir. Neredeyse her şey script'e dökülebilir — servis kontrolü, disk izleme, Event Log okuma, zamanlanmış görevler. Ama bu script'lerin ürettiği alarmlar genellikle e-posta veya Teams kanalına gider. Gece kimse bakmıyorsa yine aynı sorun.

PowerShell ile Alertalk webhook'unu çağırmak tek bir komut bloğudur. Windows üzerinde çalışan herhangi bir script sesli alarma dönüştürülebilir.

PowerShell ile Webhook Nasıl Gönderilir?

PowerShell'de HTTP POST isteği göndermek için Invoke-RestMethod cmdlet'i kullanılır. Alertalk webhook'unu çağırmak için gereken yapı şudur:

$webhookUrl = "https://tr.alertalk.net/webhook/receive"
$webhookKey = "buraya-alertalk-key-giriniz"

$body = @{
    phone_number  = "5XXXXXXXXX"
    error_message = "Alarm mesajınız buraya"
} | ConvertTo-Json

Invoke-RestMethod -Uri $webhookUrl `
    -Method POST `
    -Headers @{ "X-Webhook-Key" = $webhookKey; "Content-Type" = "application/json" } `
    -Body $body

Bu kadar. Alarm tetiklenmesi için fazlasına gerek yok.

Servis Durumu İzleme

Windows servislerinden biri durduğunda telefon çağrısı başlatan script:

$webhookUrl = "https://tr.alertalk.net/webhook/receive"
$webhookKey = "buraya-alertalk-key-giriniz"
$phone     = "5XXXXXXXXX"
$hostname  = $env:COMPUTERNAME

$services = @("W32Time", "Spooler", "wuauserv")

foreach ($svc in $services) {
    $status = (Get-Service -Name $svc -ErrorAction SilentlyContinue).Status

    if ($status -ne "Running") {
        $body = @{
            phone_number  = $phone
            error_message = "Servis alarmi: $hostname sunucusunda $svc servisi durdurulmus. Durum: $status"
        } | ConvertTo-Json

        Invoke-RestMethod -Uri $webhookUrl `
            -Method POST `
            -Headers @{ "X-Webhook-Key" = $webhookKey; "Content-Type" = "application/json" } `
            -Body $body
    }
}

Disk Doluluk Alarmı

$webhookUrl = "https://tr.alertalk.net/webhook/receive"
$webhookKey = "buraya-alertalk-key-giriniz"
$phone     = "5XXXXXXXXX"
$threshold = 85
$hostname  = $env:COMPUTERNAME

Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Used -gt 0 } | ForEach-Object {
    $total = $_.Used + $_.Free
    $usedPercent = [math]::Round(($_.Used / $total) * 100)

    if ($usedPercent -ge $threshold) {
        $body = @{
            phone_number  = $phone
            error_message = "Disk alarmi: $hostname sunucusunda $($_.Name) surucusu yuzde $usedPercent dolu."
        } | ConvertTo-Json

        Invoke-RestMethod -Uri $webhookUrl `
            -Method POST `
            -Headers @{ "X-Webhook-Key" = $webhookKey; "Content-Type" = "application/json" } `
            -Body $body
    }
}

Windows Event Log Alarmı

Kritik Event Log kayıtları tespit edildiğinde sesli alarm:

$webhookUrl = "https://tr.alertalk.net/webhook/receive"
$webhookKey = "buraya-alertalk-key-giriniz"
$phone     = "5XXXXXXXXX"
$hostname  = $env:COMPUTERNAME

$events = Get-EventLog -LogName System -EntryType Error -Newest 10 `
    -After (Get-Date).AddMinutes(-10) -ErrorAction SilentlyContinue

if ($events) {
    $count = $events.Count
    $body = @{
        phone_number  = $phone
        error_message = "Event Log alarmi: $hostname sunucusunda son 10 dakikada $count kritik hata tespit edildi."
    } | ConvertTo-Json

    Invoke-RestMethod -Uri $webhookUrl `
        -Method POST `
        -Headers @{ "X-Webhook-Key" = $webhookKey; "Content-Type" = "application/json" } `
        -Body $body
}

Scheduled Task ile Otomatik Çalıştırma

Script'i Windows Görev Zamanlayıcısı ile periyodik çalıştırmak için:

$action  = New-ScheduledTaskAction -Execute "powershell.exe" `
    -Argument "-NonInteractive -ExecutionPolicy Bypass -File C:\Scripts\alarm.ps1"

$trigger = New-ScheduledTaskTrigger -RepetitionInterval (New-TimeSpan -Minutes 5) `
    -Once -At (Get-Date)

Register-ScheduledTask -TaskName "AlertalkDiskMonitor" `
    -Action $action -Trigger $trigger -RunLevel Highest

PowerShell Alarm Senaryoları Karşılaştırması

Senaryo Cmdlet Zorluk
Servis durumu Get-Service Kolay
Disk doluluk Get-PSDrive Kolay
Event Log hatası Get-EventLog Orta
SQL Server bağlantısı Invoke-Sqlcmd Orta
IIS uygulama havuzu Get-WebConfiguration Orta

Kimler için Uygundur?

Windows altyapısı yöneten sistem yöneticileri için idealdir. Özellikle monitoring aracı olmayan ya da belirli özel senaryolar için ek alarm ihtiyacı duyan ortamlarda PowerShell ve Alertalk kombinasyonu hızlı ve etkili bir çözüm sunar.

Adım Adım Kurulum

Alertalk hesabı oluşturma ve webhook anahtarı alma için:

Webhook Entegrasyon Dokümantasyonu

PowerShell Entegrasyon Dokümantasyonu

Alertalk'ı Ücretsiz Deneyin