Created
March 11, 2020 21:00
-
-
Save drew-russell/afded9eba3351f2904bbd8070f00afb7 to your computer and use it in GitHub Desktop.
Example Powershell script that calls the Rubrik CDM GraphQL Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NodeIP = '' | |
# Prompt for Rubrik cluster Username and Passwrod | |
$RubrikCredential = Get-Credential | |
$EncodedCredential = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($RubrikCredential.UserName + ':' + $RubrikCredential.GetNetworkCredential().Password)) | |
$Headers = @{ | |
'Content-Type' = 'application/json'; | |
'Accept' = 'application/json'; | |
'Authorization' = "Basic " + $EncodedCredential | |
} | |
$GraphQLServiceEndpoint = 'https://' + $NodeIP + '/api/internal/graphql' | |
$ClusterID = 'me' | |
$Payload = @{ | |
"operationName" = "ClusterDetails"; | |
"variables" = @{"clusterID" = 'me' }; | |
"query" = "query ClusterDetails(`$clusterID: String!) { | |
cluster(id: `$clusterID) { | |
version | |
} | |
}" | |
} | |
$Response = Invoke-RestMethod -Method POST -Uri $GraphQLServiceEndpoint -Body $($Payload | ConvertTo-JSON -Depth 100) -Headers $Headers | |
Write-Output ($Response | ConvertTo-JSON -Depth 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment