How to remove AWS EC2 multiples unattached/orphaned volumes in using PowerShell

Remove EC2 volumes in Bulk in AWS



This article provides a step-by-step guide on effortlessly removing unattached volumes in AWS EC2 Console using PowerShell. To begin, you will require the volume ID, which can be obtained through the command displayed in the accompanying screenshot. It’s important to note that prior to proceeding, you must log in using the access key and secret access key.


This will list the volumes that have the values as “available”  and then you can take the VolumeID to copy them to the Excel sheet and name it “volumes”


Here is an example output of the command, which displays the volumes that are not associated with any resources.

Next, you can copy the “VolumeId” and paste it into the Excel spreadsheet.


Now you can load the file into the PowerShell session by using the following command

Upon successfully loading the file, you can verify its integrity by executing the variable in PowerShell. Simply type “$volumes” and press enter. This command will display all the volumes extracted from the Excel file.


You can now run the following command to remove the volumes that were loaded by the Excel worksheet

$volumes.VolumeId | %{remove-ec2volume -VolumeId $_ -force}


This operation will effectively eliminate any volumes that have been loaded within the Excel worksheet. Thanks for reading this and let us know if this is not accurate.


Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button