# Delete Registry property

**URL:** <https://forums.powershell.org/t/delete-registry-property/20594>\
**Category:** PowerShell Help\
**Created:** [October 8, 2022, 10:54pm UTC](https://forums.powershell.org/t/delete-registry-property/20594 "2022-10-08T22:54:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crsty](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@crsty](https://forums.powershell.org/u/crsty)\
**Post date:** [October 8, 2022, 10:54pm UTC](https://forums.powershell.org/t/delete-registry-property/20594/1 "2022-10-08T22:54:35Z")

</div>

Hi, I am trying to delete some Item Properties inside a Key and I can’t figure out a way, i am fairly new to using powershell and can’t understand why

I am trying to remove every item property inside key SiS except Reg1, Reg5

 ![Error Regedit](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/b91e9db70c086d1f9c7935320cfb8a863fe46aaf.png)

the commands I tried:

> Remove-ItemProperty -path Registry::HKLM\SAM\SiS -name \* -exclude Reg1,Reg5

→ this deletes everything inside SiS -exclude doesn’t seem to work

> Get-ItemProperty Registry::HKLM\SAM\SiS | Select \* -exclude Reg1,Reg5 | Remove-ItemProperty -name \*

→ this doesn’t do anything

---

<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:** [October 9, 2022, 9:51pm UTC](https://forums.powershell.org/t/delete-registry-property/20594/2 "2022-10-09T21:51:02Z")

</div>

The problem is that `-Exclude` qualifies the path, not the properties.

Solution based on [this Reddit post](https://www.reddit.com/r/PowerShell/comments/j3dsjo/deleting_specific_values_in_getitemproperty_where/g7btje6/):

```auto
$path = 'HKLM:\SAM\SiS'
(Get-Item -Path $path).GetValueNames() | 
    Where-Object {$_ -notin 'Reg1','Reg5'} | 
       ForEach-Object { Remove-ItemProperty -Path $path -Name $_ }

```

---

<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:16pm UTC](https://forums.powershell.org/t/delete-registry-property/20594/3 "2024-05-16T20:16:33Z")

</div>


