Powershell has a great CMDLET called Test-Path that can check to see if a registry key exists but unfortunately it does not have the ability to check for registry values. In order to get around this, I created the following function to check to see if a registry value exists. This can be extremely useful when you are using a registry key to verify if a script has already executed in the past.

Test-RegValue -Key “HKCU:\Control Panel\Desktop” -Value WallPaper
Test-RegValue -Key “HKLM:\SOFTWARE\Custom” -Value Test

Function Test-RegValue {
    Determine if a registry value exists

    Provide registry key path

    .PARAMETER Value
    Provide registry value that you would like to test

    Test-RegValue -Key "HKCU:\Control Panel\Desktop" -Value WallPaper

    Test-RegValue -Key "HKLM:\SOFTWARE\Custom" -Value Test
    param (

    Try {
        Get-ItemProperty "$Key" -ErrorAction Stop| Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null
        Return $True
    Catch [System.Management.Automation.ItemNotFoundException] {
        Write-Host "Please verify the registry key exists" -ForegroundColor Red 
        Return $False
    Catch {
        Return $False

Post your questions in the comments below!