Solved

Validate Registry Entry and Return the Values if available using Powershell

Posted on 2014-01-08
5
459 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

707 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

17 Experts available now in Live!

Get 1:1 Help Now