Failed to run Get-S3Object: Method not found

Marcio's Avatar


04 Mar, 2021 03:09 AM


I am using Build Worker Image VS2019 but i cannot run Get-S3Object. It fails with the following message:
Get-S3Object : Method not found: 'Void Amazon.S3.Model.ListObjectsRequest.set_ExpectedBucketOwner(System.String)'.
At line:1 char:14
+ $exporteds = Get-S3Object -BucketName 'pdf2xl-vcpkg-exports' `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-S3Object], MissingMethodException
    + FullyQualifiedErrorId : System.MissingMethodException,Amazon.PowerShell.Cmdlets.S3.GetS3ObjectCmdlet

It is weird if I log in the machine and try to run manually, it succeeds.

I have already tried to Update-Module AWSPowerShell but the error persists.

All other S3 commands seems to succeed

  1. Support Staff 1 Posted by Feodor Fitsner on 04 Mar, 2021 03:23 AM

    Feodor Fitsner's Avatar

    The issue is that - ps: commands are running in the context of Build Agent .NET application which is referencing some AWS SDK assemblies.

    To fix this annoying issue you should wrap a call into another PowerShell, for example:

    - cmd: powershell -command Get-S3Object ...
  2. 2 Posted by Marcio on 04 Mar, 2021 07:48 PM

    Marcio's Avatar

    Thanks, that helped me.
    In the end, I managed to call the command with:

    $exports = powershell.exe -Command '(Get-S3Object -BucketName my-bucket-name).Key'
    $exports = $exports.split()
    Is there some other way to retrieve data without parsing it? I am throwing out object data and parsing the string by doing that way.
  3. Support Staff 3 Posted by Feodor Fitsner on 04 Mar, 2021 09:19 PM

    Feodor Fitsner's Avatar

    Well, good questions. Parsing is probably the easiest unless you put all the logic into a single build.ps1 and run it.

  4. Feodor Fitsner closed this discussion on 05 May, 2021 09:03 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac