Skip to content

Instantly share code, notes, and snippets.

@klpatil
Created July 8, 2020 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klpatil/f2c7b8a561c4391d8a5b1b9f33a7df3f to your computer and use it in GitHub Desktop.
Save klpatil/f2c7b8a561c4391d8a5b1b9f33a7df3f to your computer and use it in GitHub Desktop.
Delete Solr Config using Search Stax API
# "Please provide authentication information."
$uname = Read-Host -Prompt 'Username - '
$password = Read-Host -AsSecureString -Prompt 'Password - '
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
Write-Host "Asking for an authorization token for $uname..."
Write-Host
$body = @{
username=$uname
password=$password
}
Remove-Variable PASSWORD
$body = $body | ConvertTo-Json
try {
$token = Invoke-RestMethod -uri "https://app.searchstax.com/api/rest/v2/obtain-auth-token/" -Method Post -Body $body -ContentType 'application/json'
$token = $token.token
Remove-Variable body
Write-Host "Obtained token" $token
Write-Host
$searchstaxUrl = 'https://app.searchstax.com'
$ACCOUNT = 'TODO' # <- CHANGE YOUR VALUE HERE
$uid = 'TODO' # <- CHANGE YOUR VALUE HERE
$NAME = 'sitecore_sitecore' # <- CHANGE YOUR VALUE HERE
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Token $token")
#Delete Config
$RESULTS = Invoke-RestMethod -Method Delete -Headers $headers `
-uri "https://app.searchstax.com/api/rest/v2/account/$ACCOUNT/deployment/$uid/zookeeper-config/$NAME/"
$RESULTS = $RESULTS | ConvertTo-Json
#return $token
} catch {
Write-Error -Message "Unable to get Auth Token. Error was: $_" -ErrorAction Stop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment