41 lines
1.1 KiB
PowerShell
41 lines
1.1 KiB
PowerShell
# Konfiguration
|
|
$apiUrl = "http://192.168.18.4:8000/api/updatecheck/"
|
|
$apiToken = "9d207bf0-10f5-4d8f-a479-22ff5aeff8d1"
|
|
|
|
# Hostname und Zeit
|
|
$hostname = $env:COMPUTERNAME
|
|
$timestamp = (Get-Date).ToString("yyyy-MM-ddTHH:mm:sszzz")
|
|
|
|
# OS- und Kernel-Info
|
|
$os = (Get-CimInstance Win32_OperatingSystem).Caption
|
|
$kernel = (Get-CimInstance Win32_OperatingSystem).Version
|
|
|
|
# Installierte Pakete mit DisplayName
|
|
$raw = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
|
|
Where-Object { $_.DisplayName -and ($_.DisplayName -match 'Python|OpenSSH|nginx') } |
|
|
ForEach-Object { "$($_.DisplayName)=unknown" }
|
|
|
|
# Fallback
|
|
if (-not $raw) {
|
|
$raw = @("none=none")
|
|
}
|
|
|
|
# Paketzeichenfolge zusammenbauen
|
|
$packageString = "os=$os;kernel=$kernel;" + ($raw -join ";")
|
|
|
|
# Body zusammenbauen
|
|
$body = "$hostname,$timestamp,$packageString"
|
|
|
|
# Header
|
|
$headers = @{
|
|
"Authorization" = "Bearer $apiToken"
|
|
}
|
|
|
|
# Abschicken
|
|
try {
|
|
Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body
|
|
Write-Host "✅ Update-Log gesendet von $hostname"
|
|
}
|
|
catch {
|
|
Write-Warning "❌ Fehler beim Senden: $_"
|
|
}
|