Windows Vista Forums

catch array from pipe

  1. #1


    ryan Guest

    catch array from pipe

    hello,

    i have a script to sign file. but it will only sign the last file passed
    down. (ls *.ps1 | sign) ps didn't show any syntax error. could you help
    point it out?


    function global:sign {

    param(
    [Parameter(mandatory=$true,ValueFromPipeline=$true)][System.io.fileinfo[]]$fileList
    );

    foreach ( $file in $fileList ) {
    set-authenticodesignature -filepath $file -certificate ( ls
    cert:\CurrentUser\my -codesigning );
    }

    }

      My System SpecsSystem Spec

  2. #2


    stej Guest

    Re: catch array from pipe

    I think this is a common trap (at least for me). You have to specify
    in the function that the block of code is process part:

    function global:sign {
    param([Parameter(mandatory=$true,ValueFromPipeline=$true)]
    [System.io.fileinfo[]]$fileList)
    process {
    foreach ( $file in $fileList ) {
    set-authenticodesignature -filepath $file -certificate ( ls cert:
    \CurrentUser\my -codesigning );
    }
    }
    }

    On Feb 23, 9:51*am, ryan <r...@newsgroup> wrote:

    > hello,
    >
    > i have a script to sign file. but it will only sign the last file passed
    > down. (ls *.ps1 | sign) ps didn't show any syntax error. could you help
    > point it out?
    >
    > function global:sign {
    >
    > * *param(
    > [Parameter(mandatory=$true,ValueFromPipeline=$true)][System.io.fileinfo[]]$fileList
    > );
    >
    > * *foreach ( $file in $fileList ) {
    > * * * set-authenticodesignature -filepath $file -certificate ( ls
    > cert:\CurrentUser\my -codesigning );
    > * *}
    >
    > }

      My System SpecsSystem Spec

  3. #3


    ryan Guest

    Re: catch array from pipe

    thank you

    On 02-23-2010 5:14 PM, stej wrote:

    > I think this is a common trap (at least for me). You have to specify
    > in the function that the block of code is process part:
    >
    > function global:sign {
    > param([Parameter(mandatory=$true,ValueFromPipeline=$true)]
    > [System.io.fileinfo[]]$fileList)
    > process {
    > foreach ( $file in $fileList ) {
    > set-authenticodesignature -filepath $file -certificate ( ls cert:
    > \CurrentUser\my -codesigning );
    > }
    > }
    > }
    >
    > On Feb 23, 9:51 am, ryan<r...@newsgroup> wrote:

    >> hello,
    >>
    >> i have a script to sign file. but it will only sign the last file passed
    >> down. (ls *.ps1 | sign) ps didn't show any syntax error. could you help
    >> point it out?
    >>
    >> function global:sign {
    >>
    >> param(
    >> [Parameter(mandatory=$true,ValueFromPipeline=$true)][System.io.fileinfo[]]$fileList
    >> );
    >>
    >> foreach ( $file in $fileList ) {
    >> set-authenticodesignature -filepath $file -certificate ( ls
    >> cert:\CurrentUser\my -codesigning );
    >> }
    >>
    >> }
    >

      My System SpecsSystem Spec


catch array from pipe
Similar Threads
Thread Forum
Fast copy method of sub array (=array range) possible? VB Script
How to create array without quotes? $array = (a,b,c) PowerShell
Stupid Array Tricks: Initializing an Array to a Certain Size PowerShell
Pipe a pipe command to a file VB Script
how to assign values to array and how to create array via variable PowerShell