38 lines
1.2 KiB
PowerShell
38 lines
1.2 KiB
PowerShell
# Définir l'URL de l'API
|
|
$apiUrl = "http://loczlhost/action/newuser"
|
|
|
|
# Définir les données de l'utilisateur à créer
|
|
$username = "USERNAME" # Remplacez par le nom d'utilisateur souhaité
|
|
$password = "PASSWORD" # Remplacez par le mot de passe souhaité
|
|
$apiKey = "TOKEN"
|
|
|
|
# Créer les données à envoyer dans le corps de la requête
|
|
$body = @{
|
|
username = $username
|
|
password = $password
|
|
}
|
|
|
|
# Convertir les données en JSON
|
|
$jsonBody = $body | ConvertTo-Json
|
|
|
|
# Ignorer les erreurs de certificat SSL non valide
|
|
Add-Type @"
|
|
using System.Net;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
public class TrustAllCertsPolicy : ICertificatePolicy {
|
|
public bool CheckValidationResult(
|
|
ServicePoint srvPoint, X509Certificate certificate,
|
|
WebRequest request, int certificateProblem) {
|
|
return true;
|
|
}
|
|
}
|
|
"@
|
|
|
|
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
|
|
|
|
# Envoyer la requête POST à l'API
|
|
$response = Invoke-RestMethod -Uri $apiUrl -Method Post -Body $jsonBody -ContentType "application/json" -Headers @{ "x-api-key" = $apiKey }
|
|
|
|
# Afficher la réponse de l'API
|
|
$response | Format-List
|