AD User anlegen

false, 'error' => 'Bitte alle Felder ausfüllen.']); exit; } try { $ps = new PowerShellService(); $script = __DIR__ . '/../../scripts/powershell/New-AdUserFromPhp.ps1'; $res = $ps->runScript($script, [ 'Username' => $username, 'Vorname' => $vorname, 'Nachname' => $nachname, 'Passwort' => $passwort, 'Benutzergruppe' => $gruppe, ], 60); // PowerShell gibt JSON zurück $json = $res['stdout']; $data = json_decode($json, true); if (!is_array($data)) { http_response_code(500); echo json_encode([ 'ok' => false, 'error' => 'Ungültige Antwort von PowerShell.', 'stderr' => $res['stderr'], 'raw' => $json, ]); exit; } // Wenn PS exitCode != 0, trotzdem JSON ausgeben (enthält error) if ($res['exitCode'] !== 0) { http_response_code(400); } echo json_encode($data); } catch (Throwable $e) { http_response_code(500); echo json_encode(['ok' => false, 'error' => $e->getMessage()]); }