# Define variables $baseServer = "192.168.50.60" $keycloakBaseUrl = "https://$baseServer/auth" # Replace with your Keycloak server URL $zvmApiUrl = "https://$baseServer/v1" $realm = "zerto" # Replace with your Keycloak realm name $client_id = "api-script" $client_secret = "fcYMFuA5TkIUwp6b3hDUxim0f32z8erk" # Replace with your client's secret key $tokenUrl = "$keycloakBaseUrl/realms/$realm/protocol/openid-connect/token" # Define data as a hashtable $data = @{ "grant_type" = "client_credentials" "client_id" = $client_id "client_secret" = $client_secret } # Disable SSL certificate verification (use with caution) $response = Invoke-RestMethod -Uri $tokenUrl -Method Post -Body $data -SkipCertificateCheck if ($response.status_code -eq 200) { $access_token = $response.access_token Write-Host "Authentication successful. Access token: $access_token" } else { Write-Host "Authentication failed. Status code: $($response.status_code)" Write-Host "Error message: $($response.text)" } $uri = "$zvmApiUrl/vpgs" Write-Host $uri $headers = @{ "Authorization" = "Bearer $access_token" "accept" = "application/json" } # Make a GET request to the URI with the specified headers $response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get -SkipCertificateCheck # Check if the request was successful (HTTP status code 200) if ($response.status_code -eq 200) { # Output the response JSON Write-Host $response } else { Write-Host "Status code: $($response.status_code)" Write-Host "Error message: $($response)" }