Skip to content

Instantly share code, notes, and snippets.

@JamesCalleja
Last active September 13, 2016 10:26
Show Gist options
  • Save JamesCalleja/7fe2cd026999c2e305f6bcc1b5da17c5 to your computer and use it in GitHub Desktop.
Save JamesCalleja/7fe2cd026999c2e305f6bcc1b5da17c5 to your computer and use it in GitHub Desktop.
Delete-UnattachedVolumes
#delets all volumes not attached to a running instance
$volumes = Get-EC2Volume
for ($i = 0; $i -ne $volumes.Length; $i ++) {if ($volumes[$i].state -eq 'available') {Remove-EC2Volume -VolumeId $volumes[$i].volumeID -Force; write-host 'Deleting volume:' $volumes[$i].volumeID }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment