EC2 Volumes detached list

This topic contains 4 replies, has 2 voices, and was last updated by  michael tegler 3 years, 9 months ago.

  • Author
  • #18352

    michael tegler


    Just looking for a bit of guidance. I'm trying to have PowerShell give me a list of rogue volumes (volumes not attached to any instance) but the example Amazon is giving isn't working:

    Get-EC2Volume -Filters @{ Name="status"; Values="available" }

    I get this:
    "Get-EC2Volume : Cannot bind parameter 'Filters'. Cannot convert the "System.Collections.Hashtable" value of type "Syste
    m.Collections.Hashtable" to type "Amazon.EC2.Model.Filter".
    At line:1 char:23
    + Get-EC2Volume -Filters <<<< @{ Name="status"; Values="available" } + CategoryInfo : InvalidArgument: (:) [Get-EC2Volume], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Amazon.PowerShell.Cmdlets.EC2.GetEC2VolumeCmdlet" Any help would be appreciated. Thanks

  • #18353

    Dave Wyatt

    Try this:

    $filter = New-Object Amazon.EC2.Model.Filter -Property @{ Name="status"; Values="available" }
    Get-EC2Volume -Filters $filter

    (I haven't used AWS to test this myself, but based it on documentation found at )

  • #18358

    michael tegler

    Thanks, Dave.

    But that is coming back with this error:

    New-Object : The value supplied is not valid, or the property is read-only. Change the value, and then try again.
    At line:1 char:21
    + $filter = New-Object <<<< Amazon.EC2.Model.Filter -Property @{ Name="status"; Values="available" } + CategoryInfo : InvalidData: (:) [New-Object], Exception + FullyQualifiedErrorId : InvalidValue,Microsoft.PowerShell.Commands.NewObjectCommand I tried "detached" as well and it came back with the same error.

  • #18359

    Dave Wyatt

    OK, did a bit more digging. I suspect you're using an older version of the AWS SDK (one of the v1.x versions.) The API changed a bit in v2, which you can download from

    Assuming you do need to use v1 for some reason, try changing "Values" to "Value" in your hashtable. Either syntax (passing the hashtable directly to the -Filters parameter, or using New-Object first) will probably work.

    Edit: Another v1 syntax which might help, if the hashtables don't:

    $filter = (New-Object Amazon.EC2.Model.Filter).WithName('status').WithValue('available')
  • #18360

    michael tegler

    Turns out the original script works under a different machine. Just need to figure out what's wrong with mine.

    Thanks again, Dave.

You must be logged in to reply to this topic.