Created
March 23, 2017 02:49
-
-
Save Sh1n0g1/a2e4a4580251fca469ea7dd697e1944e to your computer and use it in GitHub Desktop.
Test-RegistryName
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.EXAMPLE | |
Test-RegistryName -Path "HKCU:\Software\Sysinternals\Strings" -Name "EulaAccepted" | |
#> | |
function Test-RegistryName { | |
param ( | |
[parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Path, | |
[parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Name | |
) | |
If (Test-Path $Path){ | |
if(Get-ItemProperty -Path $Path){ | |
Try { | |
Get-ItemProperty -Path $Path | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null | |
return $true | |
}Catch { | |
return $false | |
} | |
}else{ | |
return $false | |
} | |
}else{ | |
return $false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment