41 lines
1.4 KiB
PowerShell
41 lines
1.4 KiB
PowerShell
# --- Paramètres personnalisables ---
|
|
$repoName = "REPONAME" # Remplace par le nom du dépôt SVN
|
|
$apiKey = "TOKEN" # Clé API
|
|
$hostUrl = "https://localhost:8445" # URL de base de l'API
|
|
|
|
# --- Construction de l'URL complète avec paramètre GET ---
|
|
$apiUrl = "$hostUrl/action/getperm?repo=$([uri]::EscapeDataString($repoName))"
|
|
|
|
# --- Ignorer les erreurs SSL (certificat auto-signé) ---
|
|
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
|
|
|
|
# --- Appel de l'API ---
|
|
try {
|
|
$headers = @{ "x-api-key" = $apiKey }
|
|
|
|
# Envoi de la requête GET
|
|
$response = Invoke-RestMethod -Uri $apiUrl -Method Get -Headers $headers
|
|
|
|
# Affichage formaté de la réponse
|
|
Write-Host "`n--- Utilisateurs et Permissions pour '$repoName' ---"
|
|
for ($i = 0; $i -lt $response.users.Count; $i++) {
|
|
Write-Host "$($response.users[$i]) => $($response.permissions[$i])"
|
|
}
|
|
|
|
Write-Host "`nTotal: $($response.count) utilisateur(s)"
|
|
}
|
|
catch {
|
|
Write-Error "Erreur lors de l'appel à l'API : $($_.Exception.Message)"
|
|
}
|