Get-AuthenticodeSignature Passing an array

Welcome Forums General PowerShell Q&A Get-AuthenticodeSignature Passing an array

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

 
Participant
3 months, 2 weeks ago.

  • Author
    Posts
  • #110143
    Sam

    Participant
    Points: 0
    Rank: Member

    Hello, I'm new to PS and looking to past an array of items to Get-AuthenticodeSignature.

    The exception which is likely obvious to you.

    Get-ChildItem : The input object cannot be bound to any parameters for the command either because the command does not

    take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

    $files = @("C:\two.exe.exe","C:\one.exe") | Get-ChildItem $files | ForEach-object {Get-AuthenticodeSignature $_}

    Thank you

  • #110156

    Moderator
    Points: 102
    Team MemberHelping Hand
    Rank: Participant

    Yep! Try something like this:

    $Files = @("C:\one.exe") | Get-AuthenticodeSignature
    

    Should do the trick.

    Alternatively, if you want to iterate through all files in a directory, you could still use Get-ChildItem –

    $Files = @("C:\OneDir\") | Get-ChildItem -File -Recurse | Get-AuthenticodeSignature
    
  • #110174

    Participant
    Points: 878
    Helping Hand
    Rank: Major Contributor

    Above reply by James will server you requirement, I just wanted to add one more point.

    If you are having PowerShell version < 3.0 , -File switch parameter is not available. You will have to filter using Where-Object cmdlet.

    $Files = @("C:\OneDir\") | Get-ChildItem -File -Recurse | Where-Object -FilterScript { -not $_.PSIsContainer} | Get-AuthenticodeSignature

  • #110177

    Participant
    Points: 878
    Helping Hand
    Rank: Major Contributor

    Please ignore above post, there is some issue in code posting as footers became part of post and I'm not able to edit it.

    Above reply by James will server you requirement, I just wanted to add one more point.
    If you are having PowerShell version < 3.0 , -File switch parameter is not available. You will have to filter using Where-Object cmdlet.

    $Files = @("C:\OneDir\") | Get-ChildItem -File -Recurse | Where-Object -FilterScript { -not $_.PSIsContainer} | Get-AuthenticodeSignature

    Note: PS version 2.0 is no more recommended and supported by Microsoft due to various securty concerns.

The topic ‘Get-AuthenticodeSignature Passing an array’ is closed to new replies.