Solved

Coding for variable registry in powersehll

Posted on 2014-10-15
3
140 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now