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 problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fast copy method of sub array (=array range) possible? Thomas Lebrecht VB Script 6 19 Mar 2009
How to create array without quotes? $array = (a,b,c) BenConrad PowerShell 5 04 Feb 2009
Stupid Array Tricks: Initializing an Array to a Certain Size tojo2000 PowerShell 2 09 Sep 2008
Pipe a pipe command to a file WB VB Script 2 15 Jul 2008
how to assign values to array and how to create array via variable Frank PowerShell 1 13 Mar 2007