Home » Cloud » How to remove unattached/orphaned volumes in AWS EC2 Console using powershell

How to remove unattached/orphaned volumes in AWS EC2 Console using powershell

This article will walk you thru on how to easily  remove unattached volumes in AWS EC2 Console using powershell. The first thing you will need is the volume ID can be retrieved by the command in the screenshot below. Please note that you will need to login using the access key and secret access key first

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”

 

below is the example of the command out and you can see the volumes that are not linked to anything

 

You can then copy the “VolumeId”  and copy it to the excel

Now you can load the file into the powersehll session by the suing the following command

 

Now that the file is loaded – you can confirm by using the following command

 

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 will remove the volumes  whatever was loaded in the excel worksheet

 

 

 

 

Leave a Reply

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

*
*