Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Coding for variable registry in powersehll

Posted on 2014-10-15
3
Medium Priority
?
159 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 41

Accepted Solution

by:
footech earned 2000 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 41

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

926 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