Solved

Validate Registry Entry and Return the Values if available using Powershell

Posted on 2014-01-08
5
462 Views
Last Modified: 2014-01-20
I have to Validate Registry Value entry and need if entry is there, need to return the Registry Value Data.
So i have made an external Text file with Registry Path to be Validated.
Following is the Code to verify the Registry entry availability, but it does not work as expected.

Need Assistance in Validating and if Return the Value Data if Registry entry is available.

Code:
-------
function get
{
$RQ = Get-Content C:\Testing\PS\Reg.txt
foreach($RD in $RQ)
{
if(!(Test-Path -Path $rd))
{
Write-Host "RegValue Not Exists!"
}
else
{
Write-Host "RegValue Exists!"
}
}
}
get

Txt File having the registry path to validate:
-------------------------------------------------------
HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon
HKLM:\System\CurrentControlSet\Services\LanmanWorkstation\Parameters\RequireSecuritySignature
HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableCAD
HKLM:\System\CurrentControlSet\Services\LanManServer\Parameters\EnableForcedLogoff
0
Comment
Question by:nssasikumar
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 300 total points
ID: 39764568
Try this..

function get ($file) {
Get-Content $file | % {
$RD = $_
$Name = ($RD -split "\\")[-1]
$Key = $RD -replace "\\$Name$"
	Try{
	$Value = Get-ItemProperty -Path $Key -Name $Name -EA STOP | Select-Object -ExpandProperty $Name
	$Value | Select @{N="Key";E={$RD}},@{N="RegValue";E={$_}}
	}
	Catch{
	"" | Select @{N="Key";E={$RD}},@{N="RegValue";E={"Not Exists!"}}
	}
 }
}
get C:\Testing\PS\Reg.txt | FT -AutoSize

Open in new window


Ref : http://technet.microsoft.com/en-us/library/dd315394.aspx
0
 

Author Comment

by:nssasikumar
ID: 39774334
Works
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39775340
Any particular reason for B grade?

Please see the EE guidelines on grading..
http://support.experts-exchange.com/customer/portal/articles/481419
0
 

Author Comment

by:nssasikumar
ID: 39784444
Just noticed the Grading System, Let me know Is there any possibility of reassign.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

828 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