EC2 Volumes detached list

Welcome Forums General PowerShell Q&A EC2 Volumes detached list

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
4 years, 6 months ago.

  • Author
    Posts
  • #18352

    Participant
    Points: 0
    Rank: Member

    Hi,

    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

    Member
    Points: 0
    Rank: Member

    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 http://docs.aws.amazon.com/powershell/latest/userguide/pstools-ec2-get-amis.html )

  • #18358

    Participant
    Points: 0
    Rank: Member

    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

    Member
    Points: 0
    Rank: Member

    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 http://aws.amazon.com/sdk-for-net/#version2

    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

    Participant
    Points: 0
    Rank: Member

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

    Thanks again, Dave.

The topic ‘EC2 Volumes detached list’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort