Windows Vista Forums

New to ps object piping
  1. #1


    Adam Murray Guest

    New to ps object piping

    Hi I am new to ps object piping and am just playing around.



    I am trying to modify some registry entries and wanted to be able to pipe
    all the registry item properties under a particular key through a where
    clause to the set-itemproperty cmdlet to modify the value. Below is the cmd.

    cd 'HKCU:\software\Policies\Microsoft\Internet Explorer\Control Panel'
    Get-ItemProperty 'HKCU:\software\Policies\Microsoft\Internet
    Explorer\Control Panel' | Get-Member | Where-Object {$_.name -like
    "Security*"} | Set-ItemProperty -name={$_.name} -value=1

    The error I am getting is "Set-ItemProperty : A parameter cannot be found
    that matches parameter name 'name='."

    Any suggestions? I don't understand why the property is available on the
    object in the second stage of the pipe but then is not available in the
    third stage.

    Cheers,

    Adam.



      My System SpecsSystem Spec

  2. #2


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    RE: New to ps object piping

    "Adam Murray" wrote:

    > Hi I am new to ps object piping and am just playing around.
    >
    > I am trying to modify some registry entries and wanted to be able to pipe
    > all the registry item properties under a particular key through a where
    > clause to the set-itemproperty cmdlet to modify the value. Below is the cmd.
    >
    > cd 'HKCU:\software\Policies\Microsoft\Internet Explorer\Control Panel'
    > Get-ItemProperty 'HKCU:\software\Policies\Microsoft\Internet
    > Explorer\Control Panel' | Get-Member | Where-Object {$_.name -like
    > "Security*"} | Set-ItemProperty -name={$_.name} -value=1
    >
    > The error I am getting is "Set-ItemProperty : A parameter cannot be found
    > that matches parameter name 'name='."
    >
    > Any suggestions? I don't understand why the property is available on the
    > object in the second stage of the pipe but then is not available in the
    > third stage.


    I'm impressed, for a beginner your syntax was almost perfect. ;-)
    I think this little modification will make it work:

    Set-Location 'HKCU:\software\Policies\Microsoft\Internet Explorer\Control
    Panel'
    Get-ItemProperty . | Get-Member | Where-Object {$_.name -like "Security*"} |
    ForEach-Object {Set-ItemProperty . -name $_.name -value 1}

    --
    greetings
    dreeschkind

    > Cheers,
    >
    > Adam.
    >
    >
    >


      My System SpecsSystem Spec

  3. #3


    Adam Murray Guest

    Re: New to ps object piping

    Thanks Dreeschkind,

    Worked like a gem. I get confused about when I need to use the foreach loop.

    Cheers,

    Adam.

    "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
    newsA4F646C-138C-4B58-804A-EB30967B9974@microsoft.com...
    > "Adam Murray" wrote:
    >
    >> Hi I am new to ps object piping and am just playing around.
    >>
    >> I am trying to modify some registry entries and wanted to be able to pipe
    >> all the registry item properties under a particular key through a where
    >> clause to the set-itemproperty cmdlet to modify the value. Below is the
    >> cmd.
    >>
    >> cd 'HKCU:\software\Policies\Microsoft\Internet Explorer\Control Panel'
    >> Get-ItemProperty 'HKCU:\software\Policies\Microsoft\Internet
    >> Explorer\Control Panel' | Get-Member | Where-Object {$_.name -like
    >> "Security*"} | Set-ItemProperty -name={$_.name} -value=1
    >>
    >> The error I am getting is "Set-ItemProperty : A parameter cannot be found
    >> that matches parameter name 'name='."
    >>
    >> Any suggestions? I don't understand why the property is available on the
    >> object in the second stage of the pipe but then is not available in the
    >> third stage.

    >
    > I'm impressed, for a beginner your syntax was almost perfect. ;-)
    > I think this little modification will make it work:
    >
    > Set-Location 'HKCU:\software\Policies\Microsoft\Internet Explorer\Control
    > Panel'
    > Get-ItemProperty . | Get-Member | Where-Object {$_.name -like "Security*"}
    > |
    > ForEach-Object {Set-ItemProperty . -name $_.name -value 1}
    >
    > --
    > greetings
    > dreeschkind
    >
    >> Cheers,
    >>
    >> Adam.
    >>
    >>
    >>




      My System SpecsSystem Spec

New to ps object piping problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Piping to a second script Paul Bergson [MVP-DS] PowerShell 5 08 May 2009
Piping and Functions Ripp PowerShell 2 08 Nov 2008
Piping dir to tree Steven Smith PowerShell 2 14 May 2008
All about piping Marco Shaw PowerShell 2 20 Nov 2006
Adding canonical aliases for Compare-Object, Measure-Object, New-Object Alex K. Angelopoulos [MVP] PowerShell 2 26 May 2006