verify this script for removing all the values in this registry key

Welcome Forums General PowerShell Q&A verify this script for removing all the values in this registry key

This topic contains 3 replies, has 2 voices, and was last updated by

 
Participant
3 years, 1 month ago.

  • Author
    Posts
  • #31722

    Participant
    Points: -19
    Rank: Member

    I want to run a nightly PS script that will remove all the values from this key like so, but not the key itself:

    Remove-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff\* -whatif

    Is this the correct statement?? whatif returns nothing...

    My understanding is that the * prevents deleting the key itself (PurgeAtNextLogoff).

    Thank you, Tom

  • #31726

    Participant
    Points: 306
    Helping Hand
    Rank: Contributor

    I believe you are looking for Remove-ItemProperty. See: https://technet.microsoft.com/en-us/library/dd315394.aspx

  • #31728

    Participant
    Points: -19
    Rank: Member

    Yes, that's it but it wants a name parameter and I only want to delete the values not the key itself.

    Thank you...

  • #31729

    Participant
    Points: -19
    Rank: Member

    I got it:

    Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff\ -name s* -whatif

    Thank you for pointing me in the right direction!!

The topic ‘verify this script for removing all the values in this registry key’ is closed to new replies.