Skip to content

Instantly share code, notes, and snippets.

@Alex-Yates
Created July 3, 2023 16:32
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 Alex-Yates/f9a9d6aea7481d2defbf667b0f6fec02 to your computer and use it in GitHub Desktop.
Save Alex-Yates/f9a9d6aea7481d2defbf667b0f6fec02 to your computer and use it in GitHub Desktop.
$testMode = $true # By default, don't actually delete anything. Just print out the commands you would execute without executing them. Set this to false if you want to actually delete stuff
$images = (rgclone get di --output json) | ConvertFrom-Json
$failedImageIds = ($images | Where-Object {$_.status -like "Failed"}).Id
$containers = (rgclone get dc --output json) | ConvertFrom-Json
$failedContainerIds = ($containers | Where-Object {$_.status -like "Failed"}).Id
if ($failedImageIds.length -ne 0){
$failedImageIds | ForEach-Object {
Write-Output "Deleting data-image $_"
if ($testMode){
Write-output "NOT ACTUALLY EXECUTING: rgclone delete di $_"
}
else {
& rgclone delete di $_
}
}
}
if ($failedContainerIds.length -ne 0){
$failedContainerIds | ForEach-Object {
Write-Output "Deleting data-container $_"
if ($testMode){
Write-output "NOT ACTUALLY EXECUTING: rgclone delete dc $_"
}
else {
& rgclone delete di $_
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment