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?
Assume I want to copy the sub-array with the slots 234 until 789 from arrayone to the end of arraytwo I can do this step by step with ind = 234...
VB Script
Pipe response Yes to ALl
I'm trying to run the following command: Get-Mailbox | set-Mailbox -ManagedFolderMailboxPolicy "Retention Policy" How do I get it to...
PowerShell
How to create array without quotes? $array = (a,b,c)
Hi, I'm used to creating arrays in Perl such as: @array = (one, two, three); foreach $a (@array) { print "$a\n"; } In powershell, I...
PowerShell
Array indexing: Want to say "Item #2 through the rest of the array."
Let's say I have a text file called 'GetContentTest.txt' with the number 1 through 10 in it with each number on its own line. I'd like to skip...
PowerShell
Stupid Array Tricks: Initializing an Array to a Certain Size
Okay, so I'm trying to use the SqlDataReader.GetValues() method, and it wants me to pass it an array. The problem is that it wants the array to be...
PowerShell
Pipe a pipe command to a file
I couldn't find any better place to post this, so here it is: I'm trying to find a way to echo a pipe command (>>) to a file. Basically I'm...
VB Script
how to assign values to array and how to create array via variable
Hi, I need to assign values to an array, but they may not be in order. ie, $ar = "test" but I get the error: Array assignment failed...
PowerShell