You can use Set-ItemProperty as long as the -Value is a byte array (which it will be if fetched from an existing REG_BINARY value). Avoid removing-to-replace as it's non-atomic and might possibly run afoul of ACLs.
--Steve On Mon, Mar 26, 2012 at 9:51 PM, KenM <[email protected]> wrote: > By default set-itemproperty creates a REG_SZ value so to create a reg_binary > you will need to use new-itemproperty so try this > > > $path="Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet > Settings\Connections" > $path2="Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet > Settings\Connections" > $foo=Get-ItemProperty -Path $path -Name DefaultConnectionSettings > Remove-ItemProperty -Path $path2 -Name DefaultConnectionSettings -Force > new-ItemProperty $path2 DefaultConnectionSettings -Value > $foo.DefaultConnectionSettings -propertyType binary > > > > > > > > On Mon, Mar 26, 2012 at 9:16 PM, Joseph L. Casale > <[email protected]> wrote: >> >> Believe it or not, that was my very first attempt (hence the pipe inquiry >> in first email) but it errors out: >> >> Set-ItemProperty : The input object cannot be bound to any parameters for >> the command either because the command does not take pipeline input or the >> input and its properties do not >> match any of the parameters that take pipeline input. >> ________________________________________ >> From: Michael B. Smith [[email protected]] >> Sent: Monday, March 26, 2012 7:07 PM >> To: NT System Admin Issues >> Subject: RE: Powershell reg binary issue >> >> What has "$foo" got to do with anything? >> >> This is all you need based on what you've said so far: >> >> Get-ItemProperty -Path $path -Name DefaultConnectionSettings | >> Set-ItemProperty -Path $path2 -Name DefaultConnectionSettings >> >> -----Original Message----- >> From: Joseph L. Casale [mailto:[email protected]] >> Sent: Monday, March 26, 2012 8:56 PM >> To: NT System Admin Issues >> Subject: RE: Powershell reg binary issue >> >> There is a type mismatch, or its getting cast to a string as a result of >> the way i incorrectly call it: >> >> >> $path="Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet >> Settings\Connections" >> >> $path2="Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet >> Settings\Connections" >> >> $foo = Get-ItemProperty -Path $path -Name DefaultConnectionSettings >> Set-ItemProperty -Path $path2 -Name DefaultConnectionSettings -Value $foo >> >> See what I am doing wrong? >> jlc >> ________________________________________ >> From: Brian Desmond [[email protected]] >> Sent: Monday, March 26, 2012 6:40 PM >> To: NT System Admin Issues >> Subject: RE: Powershell reg binary issue >> >> You could just put it in $foo or some variable. No need to dump it to a >> temp file. >> >> Thanks, >> Brian Desmond >> [email protected] >> >> w - 312.625.1438 | c - 312.731.3132 >> >> >> -----Original Message----- >> From: Michael B. Smith [mailto:[email protected]] >> Sent: Monday, March 26, 2012 7:16 PM >> To: NT System Admin Issues >> Subject: RE: Powershell reg binary issue >> >> Out-file -encoding binary >> >> Or similar. >> >> -----Original Message----- >> From: Joseph L. Casale [mailto:[email protected]] >> Sent: Monday, March 26, 2012 8:01 PM >> To: NT System Admin Issues >> Subject: Powershell reg binary issue >> >> I am trying to save the result of a Reg Binary value from one key into the >> value of another key, any idea on how to save the output of get-itemproperty >> or pipe it into set-itemproperty for use with reg binary values? >> >> Thanks! >> jlc >> >> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ >> <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >> >> --- >> To manage subscriptions click here: >> http://lyris.sunbelt-software.com/read/my_forums/ >> or send an email to [email protected] >> with the body: unsubscribe ntsysadmin >> >> >> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ >> <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >> >> --- >> To manage subscriptions click here: >> http://lyris.sunbelt-software.com/read/my_forums/ >> or send an email to [email protected] >> with the body: unsubscribe ntsysadmin >> >> >> >> >> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ >> <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >> >> --- >> To manage subscriptions click here: >> http://lyris.sunbelt-software.com/read/my_forums/ >> or send an email to [email protected] >> with the body: unsubscribe ntsysadmin >> >> >> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ >> <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >> >> --- >> To manage subscriptions click here: >> http://lyris.sunbelt-software.com/read/my_forums/ >> or send an email to [email protected] >> with the body: unsubscribe ntsysadmin >> >> >> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ >> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >> >> --- >> To manage subscriptions click here: >> http://lyris.sunbelt-software.com/read/my_forums/ >> or send an email to [email protected] >> with the body: unsubscribe ntsysadmin >> > ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
