Created
July 8, 2020 19:58
-
-
Save klpatil/f2c7b8a561c4391d8a5b1b9f33a7df3f to your computer and use it in GitHub Desktop.
Delete Solr Config using Search Stax API
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
# "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