Über folgendes Skript kann einem Gerät ein Bild, das dann z.B. im Info-Widget sichtbar ist, hinterlegt werden:
# ---- Konfiguration ----
$BaseUrl = "http://YOURHOSTNAME/LOGINventory9"
$ApiKey = "YOUR API KEY HERE"
$DeviceName = "PC-12345"
$ImagePath = "C:\temp\image.jpg"
# ----------------------
function Set-DeviceImage {
param(
[Parameter(Mandatory)][string]$DeviceName,
[Parameter(Mandatory)][string]$ImagePath
)
if (-not (Test-Path $ImagePath)) {
Write-Error "Datei nicht gefunden: $ImagePath"
return
}
$imageBase64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes($ImagePath))
$body = @{
Name = $DeviceName
Image = $imageBase64
} | ConvertTo-Json
$response = Invoke-RestMethod `
-Uri "$BaseUrl/api/v1/Device" `
-Method POST `
-Headers @{ "X-Api-Key" = $ApiKey; "Content-Type" = "application/json" } `
-Body $body
return $response
}
# ---- Hauptteil ----
$result = Set-DeviceImage -DeviceName $DeviceName -ImagePath $ImagePath
if ($result) {
Write-Host "Erfolgreich gesetzt fuer: $DeviceName"
Write-Output $result
} else {
Write-Warning "Kein Ergebnis erhalten."
}Dazu muss die Web API erstmal aktiviert werden: Web API - LOGINventory9 Handbuch
Wenn Sie per API Key drauf zugreifen möchten (wie im Skript), müssen Sie dieser Anleitung folgen: Web API - LOGINventory9 Handbuch