# Get-ItemPropertyValue Property 2 does not exist path

**URL:** <https://forums.powershell.org/t/get-itempropertyvalue-property-2-does-not-exist-path/19324>\
**Category:** PowerShell Help\
**Created:** [May 16, 2022, 6:31am UTC](https://forums.powershell.org/t/get-itempropertyvalue-property-2-does-not-exist-path/19324 "2022-05-16T06:31:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doryshe](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@doryshe](https://forums.powershell.org/u/doryshe)\
**Post date:** [May 16, 2022, 6:31am UTC](https://forums.powershell.org/t/get-itempropertyvalue-property-2-does-not-exist-path/19324/1 "2022-05-16T06:31:11Z")

</div>

Hi  
when I using:

$val=Get-ItemPropertyValue ‘HKLM:\SYSTEM\Keyboard Layout\Preload’ -name ‘2’ -ErrorAction ignore

or

Get-ItemPropertyValue ‘HKLM:\SYSTEM\Keyboard Layout\Preload’ -name ‘2’ -ErrorAction ignore

I get an error that the “Get-ItemPropertyValue : Property 2 does not exist”

I need do to “if” the value exist then…

Is there a way to do it?

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 16, 2022, 4:17pm UTC](https://forums.powershell.org/t/get-itempropertyvalue-property-2-does-not-exist-path/19324/2 "2022-05-16T16:17:25Z")

</div>

Firstly, when posting code, data, and errors in the forum, please can you use the preformatted text \</\> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working).

[How to format code on PowerShell.org](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif)

You could do it with `try/catch` error handling:

```auto
try {
    Get-ItemPropertyValue -Path 'HKLM:\SYSTEM\Keyboard Layout\Preload' -Name '2'
    # Do stuff if property exists.
}
catch {
    # Do stuff if property doesn't exist.
}

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/get-itempropertyvalue-property-2-does-not-exist-path/19324/3 "2024-05-16T20:17:58Z")

</div>

Closed on May 16, 2024, 8:17pm UTC


