Solved

Coding for variable registry in powersehll

Posted on 2014-10-15
3
143 Views
Last Modified: 2014-10-16
Hi everyone,

Basically, I am trying to disable Adobe updates in registry for Acrobat, Reader or anything that uses the method below. As per adobe documentation:

1. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\{product}\{version}\
FeatureLockdown.
2. Create the new DWord bUpdater.
3. Set the value to 0.

Below is what I think should be the solution and what I have tried. If there is a better way, please let me know.

What I have thought of so far is returning each name in parent ..\Adobe, and for each return the names and in each create the new DWord/set value to zero.

The python-esque/plain english logic would be:

path = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\"

for product in path:
  for version in product:
    finalPath = path + "FeatureLockDown"
    New-Item -Path finalPath bUpdater -Force
    Set-Item -Path finalPath -Value 0

So far, I haven't been able to store the individual products in the paths, let alone iterate, and repeat the process in the child, then set the variables.

The closest I've gotten:
$(Get-childItem HKLM:\SOFTWARE\Policies\Adobe\).Name | foreach {Write-Host $_}

This returns the name on one of my machines where there is only 1 product. When there is 2, it returns blank.

Any help would be greatly appreciated!

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Updates (Removed older updates):

foreach ($product in Get-childItem HKLM:\SOFTWARE\Policies\Adobe\ -Recurse) {
  If ($product.Name.Contains("FeatureLockDown") -and (-Not($product.Name.Contains("FeatureLockDown\")))) {
    Write-Host $product
  }
}

returns "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\{product}\{version}\
FeatureLockdown"
0
Comment
Question by:scsyeg
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 40383000
Well, the command to just set one would be like:
New-ItemProperty "HKLM:\SOFTWARE\Policies\Adobe\Acrobat Reader\10.0\FeatureLockDown" -Name bUpdater -propertyType DWORD -Value "0x00000000" -Force | Out-Null

Open in new window


I only have the one product installed, but I think the following would work for multiple.
Get-Item "HKLM:\SOFTWARE\Policies\Adobe\*\*\FeatureLockdown" | New-ItemProperty -Name bUpdater -PropertyType DWORD -Value "0x00000000" -Force | Out-Null

Open in new window

0
 

Author Comment

by:scsyeg
ID: 40383040
That might be a cleaner method than my own that ended up working:

foreach ($product in Get-childItem HKLM:\SOFTWARE\Policies\Adobe\ -Recurse) {
  If ($product.Name.Contains("FeatureLockDown") -and (!($product.Name.Contains("FeatureLockDown\")))) {
    $productPath = $product -replace "HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Adobe\\","HKLM:\SOFTWARE\Policies\Adobe\"
    New-ItemProperty -Path $productPath -Name "bUpdater" -PropertyType "DWORD" -Value 0 -force #-ErrorAction silentlycontinue
  }
}

Open in new window


Which do you like better? Why?
0
 
LVL 39

Expert Comment

by:footech
ID: 40383084
I like mine just because it's cleaner and I like to use the pipeline whenever I can.  There's also not as many operations.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
A procedure for exporting installed hotfix details of remote computers using powershell
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question