Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

New to ps object piping

Closed Thread
 
Thread Tools Display Modes
Old 09-13-2006   #1 (permalink)
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.


Old 09-13-2006   #2 (permalink)
=?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.
>
>
>

Old 09-14-2006   #3 (permalink)
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.
>>
>>
>>



Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Piping dir to tree Steven Smith PowerShell 2 05-14-2008 11:00 PM
What is the syntax for piping LiteralPath to Get-ChildItem Bob Landau PowerShell 6 10-05-2007 10:59 PM
piping/redirect to file slow Ben Schwehn PowerShell 10 09-19-2007 07:34 AM
All about piping Marco Shaw PowerShell 2 11-20-2006 11:20 AM
Adding canonical aliases for Compare-Object, Measure-Object, New-Object Alex K. Angelopoulos [MVP] PowerShell 2 05-26-2006 07:58 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50